fix: new URL("", import.meta.url) should be pure#12076
Merged
LingyuCoder merged 1 commit intomainfrom Nov 5, 2025
Merged
Conversation
✅ Deploy Preview for rspack canceled.
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enables side-effects detection for new URL() expressions by implementing the is_pure hook in the URL plugin. The change allows the bundler to mark unused URL imports as orphan modules and potentially exclude them during tree-shaking.
Key changes:
- Added a new
is_puretrait method to theJavascriptParserPlugintrait - Implemented
is_pureinURLPluginto identify purenew URL()expressions - Updated all side-effects checking functions to thread the
parserparameter through the call chain
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/rspack-test/configCases/side-effects/url/test.filter.js | Removed FIXME filter, enabling the test now that the feature is implemented |
| crates/rspack_plugin_javascript/src/parser_plugin/url_plugin.rs | Implemented is_pure method to detect pure new URL() expressions |
| crates/rspack_plugin_javascript/src/parser_plugin/trait.rs | Added is_pure method to the JavascriptParserPlugin trait |
| crates/rspack_plugin_javascript/src/parser_plugin/side_effects_parser_plugin.rs | Updated all purity checking functions to accept and pass through the parser parameter |
| crates/rspack_plugin_javascript/src/parser_plugin/inner_graph/plugin.rs | Updated calls to purity checking functions to include the parser parameter |
| crates/rspack_plugin_javascript/src/parser_plugin/drive.rs | Implemented plugin driver logic for the is_pure hook |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
📦 Binary Size-limit
❌ Size increased by 1.63KB from 47.86MB to 47.86MB (⬆️0.00%) |
Contributor
|
📝 Benchmark detail: Open
|
CodSpeed Performance ReportMerging #12076 will not alter performanceComparing Summary
|
JSerFeng
approved these changes
Nov 5, 2025
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
The
new URL("", import.meta.url)should be pure to inner graph plugin.is_pureto parser driver which will be called inis_pure_expressionRelated links
Checklist