Conversation
✅ Deploy Preview for rspack canceled.
|
📦 Binary Size-limit
❌ Size increased by 4.25KB from 47.70MB to 47.70MB (⬆️0.01%) |
CodSpeed Performance ReportMerging #12302 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Pull request overview
This PR implements two key features for rstest plugin hoisting: 1) rs.hoisted() method that hoists code to the top of the module along with its statement declaration if present, and 2) dedicated hoisting of @rstest/core imports to ensure they appear before hoisted code that depends on them.
- Adds
statement_spantracking to distinguish between standalone calls and variable declaration hoisting - Implements
@rstest/coreimport hoisting by inserting a higher-priority fragment with the same key - Updates parser plugin to pass statement context through method call chain
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
tests/rspack-test/configCases/rstest/mock/rspack.config.js |
Adds rstest_hoisted runtime function and test configuration for hoisted functionality |
tests/rspack-test/configCases/rstest/mock/node_modules/@rstest/core/package.json |
Creates mock @rstest/core package for testing |
tests/rspack-test/configCases/rstest/mock/node_modules/@rstest/core/index.js |
Implements mock @rstest/core module with rs.hoisted() and rs.fn() methods |
tests/rspack-test/configCases/rstest/mock/hoisted.js |
Adds test case for rs.hoisted() with variable declaration and rs.fn() usage |
crates/rspack_plugin_rstest/src/plugin.rs |
Updates regex pattern to recognize HOISTED markers |
crates/rspack_plugin_rstest/src/parser_plugin.rs |
Adds statement_span parameter to hoisted() and handle_rstest_method_call() methods for statement-level hoisting |
crates/rspack_plugin_rstest/src/mock_method_dependency.rs |
Implements statement-level hoisting, @rstest/core import hoisting, and refactors code generation into helper methods |
crates/rspack_core/src/init_fragment.rs |
Adds content() getter method to ConditionalInitFragment |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📁 react-1kPath:
📁 react-10kPath:
📁 react-5kPath:
📁 romePath:
📁 ui-componentsPath:
Generated by Rsdoctor GitHub Action |
Summary
this PR mainly did two features:
rs.hoisted, will be hoisting to the top of the module. if there's a statement declaration, it will be hoisted alongside.@rstest/coreto the top of the module, this is for the common use withrs.hoisted.the implementation is to find the
@rstest/coreESM import init fragment. then, copy the content and insert the fragment with the same key at the beginning of the init fragments (-1 position), using the key deduplication principle of init fragments. this way, the init fragment corresponding to the@rstest/coreESM dependency will be placed beforers.hoisted(0 position).it might be a bit hacky to find the target init fragment by key (although the key is consistent).
Related links
Checklist