Skip to content

fix: inner graph class static block usage#12114

Merged
ahabhgk merged 1 commit intomainfrom
fix-class-static-block
Nov 7, 2025
Merged

fix: inner graph class static block usage#12114
ahabhgk merged 1 commit intomainfrom
fix-class-static-block

Conversation

@ahabhgk
Copy link
Copy Markdown
Contributor

@ahabhgk ahabhgk commented Nov 7, 2025

Summary

fix inner graph class static block usage, checkout added test case and #12114 (comment) for more detail

Related links

Checklist

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

Copilot AI review requested due to automatic review settings November 7, 2025 11:43
@netlify
Copy link
Copy Markdown

netlify bot commented Nov 7, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 84e8a5a
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/690ddb6d6ddcd600083e4e7e

@ahabhgk ahabhgk enabled auto-merge (squash) November 7, 2025 11:43
@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: bug fix release: bug related release(mr only) labels Nov 7, 2025
Copy link
Copy Markdown
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 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 this expression hook to accept a for_name parameter for name-based dependency tracking
  • Updated static block purity analysis to correctly mark them as potentially having side effects
  • Implemented aliasing of this and 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.

@ahabhgk ahabhgk requested a review from h-a-n-a November 7, 2025 11:53
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 7, 2025

📦 Binary Size-limit

Comparing 84e8a5a to refactor: remove support for nested importModule usage (#12111) by jinrui

❌ Size increased by 1.75KB from 47.90MB to 47.90MB (⬆️0.00%)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 7, 2025

CodSpeed Performance Report

Merging #12114 will not alter performance

Comparing fix-class-static-block (84e8a5a) with main (a2ba295)

Summary

✅ 17 untouched

@ahabhgk ahabhgk merged commit c12e9a0 into main Nov 7, 2025
57 checks passed
@ahabhgk ahabhgk deleted the fix-class-static-block branch November 7, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) 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