-
-
Notifications
You must be signed in to change notification settings - Fork 754
refactor: split module_graph_mut #12295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for rspack canceled.
|
📦 Binary Size-limit
🎉 Size decreased by 640bytes from 47.66MB to 47.66MB (⬇️0.00%) |
|
📝 Benchmark detail: Open task failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the module graph mutation API by splitting get_module_graph_mut() into two distinct methods: get_make_module_graph_mut() and get_seal_module_graph_mut(). This separation aligns with the compilation lifecycle phases and enables more granular control over module graph access without requiring a mutable reference to the entire Compilation during the make phase.
Key changes:
- Introduced
get_make_module_graph_mut()as a static method that operates onBuildModuleGraphArtifactfor use during make/finish_make/finish_modules phases - Introduced
get_seal_module_graph_mut()as an instance method that operates onseal_module_graph_partialfor use during seal phase hooks (optimize_dependencies, optimize_chunk_modules, etc.) - Renamed
other_module_graphtoseal_module_graph_partialto clarify its purpose
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/rspack_core/src/compilation/mod.rs | Core refactoring: splits get_module_graph_mut() into get_make_module_graph_mut() and get_seal_module_graph_mut(), renames field to seal_module_graph_partial |
| crates/rspack_plugin_rslib/src/import_external.rs | Updates to use get_make_module_graph_mut() for dependency replacement during finish_make hook |
| crates/rspack_plugin_library/src/modern_module_library_plugin.rs | BUG: Incorrectly uses get_seal_module_graph_mut() during finish_make hook |
| crates/rspack_plugin_library/src/export_property_library_plugin.rs | Correctly updates to use get_make_module_graph_mut() during finish_modules hook |
| crates/rspack_plugin_library/src/assign_library_plugin.rs | Correctly updates to use get_make_module_graph_mut() during finish_modules hook |
| crates/rspack_plugin_lazy_compilation/src/plugin.rs | Correctly updates to use get_make_module_graph_mut() during make hook |
| crates/rspack_plugin_javascript/src/plugin/side_effects_flag_plugin.rs | Correctly updates to use get_seal_module_graph_mut() during optimize_dependencies hook |
| crates/rspack_plugin_javascript/src/plugin/module_concatenation_plugin.rs | Correctly updates multiple usages to get_seal_module_graph_mut() during optimize_chunk_modules hook |
| crates/rspack_plugin_javascript/src/plugin/mangle_exports_plugin.rs | Correctly updates to use get_seal_module_graph_mut() during optimize_code_generation hook |
| crates/rspack_plugin_javascript/src/plugin/inline_exports_plugin.rs | Correctly updates to use get_seal_module_graph_mut() during optimize_dependencies hook |
| crates/rspack_plugin_javascript/src/plugin/flag_dependency_usage_plugin.rs | Correctly updates to use get_seal_module_graph_mut() during optimize_dependencies hook |
| crates/rspack_plugin_javascript/src/plugin/flag_dependency_exports_plugin.rs | Correctly updates to use get_make_module_graph_mut() during finish_modules hook |
| crates/rspack_plugin_esm_library/src/plugin.rs | Correctly updates to use get_make_module_graph_mut() during finish_modules hook |
| crates/rspack_plugin_dll/src/flag_all_modules_as_used_plugin.rs | Correctly updates to use get_seal_module_graph_mut() during optimize_dependencies hook |
| crates/rspack_core/src/module_graph/mod.rs | Updates clone_module_attributes() to use get_seal_module_graph_mut() (called during seal phase) |
| crates/rspack_core/src/compilation/build_chunk_graph/new_code_splitter.rs | Correctly updates to use get_seal_module_graph_mut() during chunk graph building in seal phase |
| crates/rspack_core/src/compilation/build_chunk_graph/code_splitter.rs | Correctly updates to use get_seal_module_graph_mut() during chunk graph building in seal phase |
| crates/rspack_core/src/compilation/build_chunk_graph/artifact.rs | Correctly updates to use get_seal_module_graph_mut() during chunk graph building in seal phase |
| crates/rspack_binding_api/src/exports_info.rs | Updates to use get_make_module_graph_mut() for JS binding API access |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/rspack_plugin_library/src/modern_module_library_plugin.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
CodSpeed Performance ReportMerging #12295 will degrade performances by 11.5%Comparing Summary
Benchmarks breakdown
|
|
this is expected since ModuleGraph performance regression casued by adding another seal_module_graph_partial https://github.com/web-infra-dev/rspack/pull/12295/files#diff-49667efb7ffa54ffd58f91bc842dc73e9be1e6c901e1638a47e4f2292c16d822R178 |
Summary
split module_graph_mut into get_make_module_graph_mut and get_ seal_module_graph
so we don't need to hold &mut Compilation for make_module_graph
Related links
Checklist