Skip to content

Bundle mappings.wasm locally instead of loading it from unpkg - #34

Merged
rmuratov merged 1 commit into
mainfrom
bundle-mappings-wasm
Jul 5, 2026
Merged

Bundle mappings.wasm locally instead of loading it from unpkg#34
rmuratov merged 1 commit into
mainfrom
bundle-mappings-wasm

Conversation

@rmuratov

@rmuratov rmuratov commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Closes #29

What

SourceMapConsumer.initialize was pointing at https://unpkg.com/source-map@0.7.6/lib/mappings.wasm. The wasm file is now imported via Vite's ?url asset import and served from our own origin (dist/assets/mappings-*.wasm, ~48 kB / 18.7 kB gzip).

Why

  • The app claims to run entirely client-side, but broke offline, behind corporate proxies, or whenever unpkg was down.
  • Removes a third-party dependency from a tool where users paste potentially sensitive source maps.
  • The wasm version can no longer drift from the installed source-map package version.

Changes

  • src/main.tsx — import source-map/lib/mappings.wasm?url and pass the bundled URL to initialize.
  • src/vite-env.d.ts — module declaration for *.wasm?url imports.
  • src/__tests__/main.test.tsx — test that the entry point initializes the consumer with a local (non-http) wasm URL.

Verification

  • All 23 tests pass; tsc, eslint, prettier, and the production build are clean.
  • Verified the production build in Chrome against vite preview: pasted a stack trace and a fixture source map, the trace resolved to original positions, and the network panel shows mappings-Dhu04MXZ.wasm served from localhost with no requests to unpkg.

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying sourcemap-tools with  Cloudflare Pages  Cloudflare Pages

Latest commit: f592b88
Status: ✅  Deploy successful!
Preview URL: https://e21b7fa2.sourcemap-tools.pages.dev
Branch Preview URL: https://bundle-mappings-wasm.sourcemap-tools.pages.dev

View logs

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ce8c959) to head (f592b88).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #34   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         9           
  Lines          203       203           
  Branches        49        49           
=========================================
  Hits           203       203           

☔ View full report in Codecov by Harness.
📢 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.

@rmuratov
rmuratov merged commit 6c700e3 into main Jul 5, 2026
4 checks passed
@rmuratov
rmuratov deleted the bundle-mappings-wasm branch July 5, 2026 16:19
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.

Bundle mappings.wasm locally instead of loading from unpkg

1 participant