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:
- Add to Vite optimizeDeps config
- Serve as static asset from node_modules
- Use esm.sh CDN for @rspack/browser
- 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
apps/gograb-space/project.jsonlibs/libs-structural/platform-preview/src/lib/services/bundler.service.tslibs/libs-structural/platform-preview/src/lib/services/bundler-filesystem.service.ts
🔗 Related
- Decision ID:
dev_1773598070305_doqvi80 - Session: 224
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation