Skip to content

fix(wasm): strip dead env import from wasm-bindgen JS#41

Merged
JuanMarchetto merged 1 commit into
mainfrom
fix/wasm-strip-dead-env-import
Feb 26, 2026
Merged

fix(wasm): strip dead env import from wasm-bindgen JS#41
JuanMarchetto merged 1 commit into
mainfrom
fix/wasm-strip-dead-env-import

Conversation

@jeanclawdbotdamn

Copy link
Copy Markdown
Collaborator

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:

  1. cargo build → WASM binary (1 residual env import)
  2. wasm-bindgen → generates JS with import * from "env"
  3. wasm-opt → optimizes WASM binary, removes the dead import

So 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 sed post-processing step after wasm-pack build in both pages.yml and release.yml to strip the dead import * from "env" and "env": lines.

Test plan

🤖 Generated with Claude Code

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 JuanMarchetto merged commit c090f90 into main Feb 26, 2026
8 checks passed
@codecov

codecov Bot commented Feb 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.65%. Comparing base (7394162) to head (f11d7ea).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JuanMarchetto JuanMarchetto deleted the fix/wasm-strip-dead-env-import branch February 26, 2026 18:51
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.

2 participants