Skip to content

Fix PackageToJS plugin wasm-opt fallback when output file exists #401

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

Merged
merged 1 commit into from
Aug 9, 2025

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Aug 9, 2025

Fixes a bug where PackageToJS builds fail when wasm-opt is not installed and the output file already exists.

The plugin falls back to copying the input file when wasm-opt is unavailable, but FileManager.copyItem throws an error if the destination exists. This causes "File exists" build failures.

The fix removes any existing output file before copying, matching wasm-opt's overwrite behavior. Also makes DefaultPackagingSystem injectable for cleaner testing.

@kateinoigakukun kateinoigakukun force-pushed the fix-packagetojs-wasm-opt-fallback branch 3 times, most recently from 6dca4f7 to 40c79f7 Compare August 9, 2025 07:41
When wasm-opt is not installed, DefaultPackagingSystem falls back to copying
the input Wasm file directly to output. However, FileManager.copyItem
fails if the destination file already exists, while wasm-opt overwrites
existing files.

Changes:
- Remove existing output file before copying in wasm-opt fallback
- Make DefaultPackagingSystem injectable for testing with custom which function
- Add focused tests for DefaultPackagingSystem fallback behavior
- Test both new and existing output file scenarios

Fixes issue where builds fail with 'File exists' error when wasm-opt
is unavailable and output file already exists from previous builds.
@kateinoigakukun kateinoigakukun force-pushed the fix-packagetojs-wasm-opt-fallback branch from 40c79f7 to b579fb1 Compare August 9, 2025 07:47
@kateinoigakukun kateinoigakukun merged commit a1e6905 into main Aug 9, 2025
8 checks passed
@kateinoigakukun kateinoigakukun deleted the fix-packagetojs-wasm-opt-fallback branch August 9, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant