fix: inner graph class static block usage#12114
Merged
Conversation
✅ Deploy Preview for rspack canceled.
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for class static blocks in the inner graph optimization system. Static blocks can reference this and the class identifier, which need to be tracked as dependencies on the enclosing class variable for proper tree-shaking.
Key Changes:
- Modified the
thisexpression hook to accept afor_nameparameter for name-based dependency tracking - Updated static block purity analysis to correctly mark them as potentially having side effects
- Implemented aliasing of
thisand class identifiers to top-level symbols within static blocks - Fixed scope parameter handling to only include class expression identifiers (not declarations)
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tests/rspack-test/normalCases/inner-graph/class-static-block/module.js |
Test module exporting functions used in static blocks |
tests/rspack-test/normalCases/inner-graph/class-static-block/index.js |
Test case validating static block behavior for classes |
tests/rspack-test/normalCases/inner-graph/class-static-block/class.js |
Test classes with static blocks using this and class identifiers |
crates/rspack_plugin_javascript/src/visitors/dependency/parser/walk.rs |
Updated walk_this_expression to use name-based hooks; fixed class scope params to only include expression identifiers |
crates/rspack_plugin_javascript/src/parser_plugin/trait.rs |
Added for_name parameter to this hook signature |
crates/rspack_plugin_javascript/src/parser_plugin/side_effects_parser_plugin.rs |
Marked static blocks and auto accessors as non-pure |
crates/rspack_plugin_javascript/src/parser_plugin/inner_graph/plugin.rs |
Implemented static block handling with variable aliasing for dependency tracking |
crates/rspack_plugin_javascript/src/parser_plugin/esm_top_level_this_plugin.rs |
Updated to match new this hook signature |
crates/rspack_plugin_javascript/src/parser_plugin/drive.rs |
Updated to pass for_name parameter to this hook implementations |
crates/rspack_plugin_javascript/src/parser_plugin/common_js_exports_parse_plugin.rs |
Updated to match new this hook signature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
h-a-n-a
approved these changes
Nov 7, 2025
Contributor
📦 Binary Size-limit
❌ Size increased by 1.75KB from 47.90MB to 47.90MB (⬆️0.00%) |
CodSpeed Performance ReportMerging #12114 will not alter performanceComparing Summary
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fix inner graph class static block usage, checkout added test case and #12114 (comment) for more detail
Related links
Checklist