fix: wasm plugin panic when use persistent cache#12455
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a panic that occurs when using the WASM plugin with persistent cache enabled. The root cause was that AsyncWasmParserAndGenerator contained a non-cacheable field (ModuleIdToFileName, which was a DashMap), making the entire structure incompatible with the caching mechanism. The fix restructures the code to compute WASM module filenames on-demand during the render manifest phase instead of pre-computing and storing them.
Key changes:
- Removed the
ModuleIdToFileNamefield fromAsyncWasmPluginandAsyncWasmParserAndGenerator, making them cacheable - Moved filename generation logic from the
generatephase to therender_manifestphase - Changed from computing hash via
hash_for_source(source)to using the pre-computedbuild_info().hash
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rspack_plugin_wasm/src/wasm_plugin.rs | Removed ModuleIdToFileName field from plugin struct; moved filename generation logic from generator to render_manifest hook; changed from parallel to sequential processing |
| crates/rspack_plugin_wasm/src/parser_and_generator.rs | Removed ModuleIdToFileName field; simplified struct to unit struct; changed to use build_info().hash instead of hash_for_source; removed render_wasm_name helper function; fixed hash string formatting in instantiate call |
| crates/rspack_plugin_wasm/src/lib.rs | Removed ModuleIdToFileName type alias and related imports |
| crates/rspack_plugin_wasm/Cargo.toml | Removed unused dependencies: dashmap, rayon, serde_json |
| Cargo.lock | Updated to reflect removed dependencies from rspack_plugin_wasm |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Binary Size-limit
🎉 Size decreased by 20.75KB from 48.21MB to 48.19MB (⬇️0.04%) |
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📁 react-10kPath:
📁 react-1kPath:
📁 react-5kPath:
📁 romePath:
📁 ui-componentsPath:
Generated by Rsdoctor GitHub Action |
CodSpeed Performance ReportMerging #12455 will not alter performanceComparing Summary
Footnotes |
Summary
render_manifestand was not cached. Considering the small final number of wasm files, this part has little impact on performance.Related links
Checklist