-
Notifications
You must be signed in to change notification settings - Fork 0
Dev #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev #172
Changes from all commits
67eb30e
66dbcea
530c66a
5990a9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -42,6 +42,7 @@ | |||||
| "semantic-release": "^24.1.2", | ||||||
| "typescript": "^5.8.3", | ||||||
| "vite": "^6.0.0", | ||||||
| "vite-plugin-compression": "^0.5.1", | ||||||
|
||||||
| "vite-plugin-compression": "^0.5.1", | |
| "vite-plugin-compression": "^0.6.0", |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,16 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { defineConfig } from 'vite'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import viteCompression from 'vite-plugin-compression'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| export default defineConfig({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| plugins: [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| viteCompression({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| algorithm: 'brotliCompress', | ||||||||||||||||||||||||||||||||||||||||||||||||
| ext: '.br', | ||||||||||||||||||||||||||||||||||||||||||||||||
| filter: /\.(wasm|js)$/i, | ||||||||||||||||||||||||||||||||||||||||||||||||
| threshold: 1024, // Only compress files > 1KB | ||||||||||||||||||||||||||||||||||||||||||||||||
| deleteOriginFile: false, // Keep original files for compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+6
to
+12
|
||||||||||||||||||||||||||||||||||||||||||||||||
| viteCompression({ | |
| algorithm: 'brotliCompress', | |
| ext: '.br', | |
| filter: /\.(wasm|js)$/i, | |
| threshold: 1024, // Only compress files > 1KB | |
| deleteOriginFile: false, // Keep original files for compatibility | |
| }), | |
| // Compress WASM files > 10KB | |
| viteCompression({ | |
| algorithm: 'brotliCompress', | |
| ext: '.br', | |
| filter: /\.(wasm)$/i, | |
| threshold: 10240, // Only compress WASM files > 10KB | |
| deleteOriginFile: false, // Keep original files for compatibility | |
| }), | |
| // Compress JS files > 5KB | |
| viteCompression({ | |
| algorithm: 'brotliCompress', | |
| ext: '.br', | |
| filter: /\.(js)$/i, | |
| threshold: 5120, // Only compress JS files > 5KB | |
| deleteOriginFile: false, // Keep original files for compatibility | |
| }), |
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern /pdf2svg/ will match any module path containing "pdf2svg" anywhere in the string. This might be overly broad and could unintentionally externalize modules that happen to have "pdf2svg" in their path but aren't the intended pdf2svg package.
Consider making the pattern more specific, such as /^pdf2svg/ to only match modules that start with "pdf2svg", or use a string 'pdf2svg' if you want to match the exact package name. The current pattern could match paths like 'node_modules/some-package/pdf2svg-utils/index.js' which may not be intended.
| /pdf2svg/, // Externalize pdf2svg wasm bindings to prevent inline base64 bundling | |
| 'pdf2svg', // Externalize pdf2svg wasm bindings to prevent inline base64 bundling |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #!/usr/bin/env node | ||
| /** | ||
| * Updates the 'duc' dependency version in a Cargo.toml file. | ||
| * Used during semantic-release to set the duc dependency to a crates.io-compatible version. | ||
| * | ||
| * Usage: node scripts/cargo-set-duc-dep-version.js <cargoTomlPath> <version> | ||
| * Example: node scripts/cargo-set-duc-dep-version.js packages/ducpdf/src/duc2pdf/Cargo.toml 2 | ||
| */ | ||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
|
|
||
| const cargoTomlPath = process.argv[2]; | ||
| const version = process.argv[3]; | ||
|
|
||
| if (!cargoTomlPath || !version) { | ||
| console.error("Usage: node scripts/cargo-set-duc-dep-version.js <cargoTomlPath> <version>"); | ||
| console.error("Example: node scripts/cargo-set-duc-dep-version.js packages/ducpdf/src/duc2pdf/Cargo.toml 2"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| let fullPath = path.resolve(process.cwd(), cargoTomlPath); | ||
|
|
||
| // If path is a directory, append Cargo.toml | ||
| if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) { | ||
| fullPath = path.join(fullPath, "Cargo.toml"); | ||
| } | ||
|
|
||
| if (!fs.existsSync(fullPath)) { | ||
| console.error(`File not found: ${fullPath}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| let content = fs.readFileSync(fullPath, "utf8"); | ||
|
|
||
| // Match entire duc dependency line and replace with version-only format | ||
| // Handles variations like: | ||
| // duc = { version = "0.0.0-development", path = "..." } | ||
| // duc = { path = "...", version = "..." } | ||
| // Replaces with: duc = "VERSION" | ||
| const ducDepRegex = /^(#[^\n]*\n)*duc\s*=\s*\{[^}]+\}/m; | ||
|
|
||
| if (!ducDepRegex.test(content)) { | ||
| console.error("Could not find duc dependency with version/path in Cargo.toml"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| // Replace the entire duc dependency (including any comment above it) with simple version | ||
| content = content.replace(ducDepRegex, `duc = "${version}"`); | ||
|
Comment on lines
+40
to
+48
|
||
|
|
||
| fs.writeFileSync(fullPath, content); | ||
| console.log(`Updated duc dependency to "${version}" (removed path) in ${fullPath}`); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version "2" is hardcoded in the release script. This creates a tight coupling between the release configuration and the actual version of the 'duc' dependency available on crates.io. If the duc package version changes, this hardcoded value will need to be manually updated in the release config.
Consider making this configurable, either through an environment variable or by determining the version dynamically (e.g., reading from a configuration file or using a semantic version range like "^2.0.0" if appropriate for crates.io compatibility).