Architecture: How to serve @rspack/browser WASM in the Angular dev server?

Documentation for Sessions

🏗️ Architecture: How to serve @rspack/browser WASM in the Angular dev server?

Date: 2026-03-15
Time: 18:07:50 UTC
Session: gspace1-224.5
Agent: angular
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

How to serve @rspack/browser WASM in the Angular dev server?

Task: Fix preview pipeline — rspack WASM compilation in browser


🎯 Decision Made

Chosen:

Serve @rspack/browser/dist as a static asset at /rspack-browser/ via project.json assets config, import from absolute URL /rspack-browser/index.mjs

Options Considered:

  1. Add to Vite optimizeDeps config
  2. Serve as static asset from node_modules
  3. Use esm.sh CDN for @rspack/browser
  4. Pre-bundle with esbuild into a single file

💭 Reasoning

Vite's esbuild pre-bundler cannot handle @rspack/browser's top-level await and WASM/WASI worker dependencies. The bare module specifier 'import("@rspack/browser")' fails at runtime. Serving the dist as static assets preserves the import.meta.url-relative paths for WASM and worker files, which rspack relies on internally.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation