Skip to content

Conversation

@hardfist
Copy link
Contributor

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

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link

netlify bot commented Nov 26, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 60ab910
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/692696ca4fab250008894740

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: refactor labels Nov 26, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

📦 Binary Size-limit

Comparing 60ab910 to refactor: render __webpack_require__ in static code by runtime template (#12284) by harpsealjs

🎉 Size decreased by 640bytes from 47.66MB to 47.66MB (⬇️0.00%)

@hardfist hardfist marked this pull request as ready for review November 26, 2025 03:59
Copilot AI review requested due to automatic review settings November 26, 2025 03:59
@hardfist hardfist enabled auto-merge (squash) November 26, 2025 04:02
@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

📝 Benchmark detail: Open

task failure

Copy link
Contributor

Copilot AI left a 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 on BuildModuleGraphArtifact for use during make/finish_make/finish_modules phases
  • Introduced get_seal_module_graph_mut() as an instance method that operates on seal_module_graph_partial for use during seal phase hooks (optimize_dependencies, optimize_chunk_modules, etc.)
  • Renamed other_module_graph to seal_module_graph_partial to 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.

hardfist and others added 2 commits November 26, 2025 12:11
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
stormslowly
stormslowly previously approved these changes Nov 26, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 26, 2025

CodSpeed Performance Report

Merging #12295 will degrade performances by 11.5%

Comparing yj/split-graph (60ab910) with main (0d8196c)

Summary

❌ 2 regressions
✅ 15 untouched

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
rust@build_chunk_graph 101.9 ms 113.6 ms -10.3%
rust@build_chunk_graph_parallel 92.4 ms 104.4 ms -11.5%

@hardfist
Copy link
Contributor Author

hardfist commented Nov 26, 2025

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

@hardfist hardfist requested a review from stormslowly November 26, 2025 06:26
@hardfist hardfist disabled auto-merge November 26, 2025 06:27
@hardfist hardfist merged commit a2b4f68 into main Nov 26, 2025
45 of 47 checks passed
@hardfist hardfist deleted the yj/split-graph branch November 26, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: refactor team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants