fix(wasm): strip dead env import from wasm-bindgen JS#41
Merged
Conversation
wasm-opt removes unused C stdlib imports from the WASM binary, but wasm-bindgen generates the JS *before* wasm-opt runs. This leaves a dead `import * from "env"` in the JS that browsers cannot resolve. Add a sed post-processing step in both pages.yml and release.yml to strip these dead references after the build. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
JuanMarchetto
approved these changes
Feb 26, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #41 +/- ##
=======================================
Coverage 77.65% 77.65%
=======================================
Files 50 50
Lines 4408 4408
=======================================
Hits 3423 3423
Misses 985 985 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The playground still throws
Failed to resolve module specifier "env"despite PR #40 providing Rust implementations for all 12 C stdlib functions.Root cause: The build pipeline runs in this order:
cargo build→ WASM binary (1 residual env import)wasm-bindgen→ generates JS withimport * from "env"wasm-opt→ optimizes WASM binary, removes the dead importSo the final WASM has zero env imports, but wasm-bindgen already wrote the JS before wasm-opt ran. The JS has a dead reference the browser can't resolve.
Fix: Add a
sedpost-processing step afterwasm-pack buildin bothpages.ymlandrelease.ymlto strip the deadimport * from "env"and"env":lines.Test plan
🤖 Generated with Claude Code