Skip to content

fix: new URL("", import.meta.url) should be pure#12076

Merged
LingyuCoder merged 1 commit intomainfrom
fix/pure-new-url
Nov 5, 2025
Merged

fix: new URL("", import.meta.url) should be pure#12076
LingyuCoder merged 1 commit intomainfrom
fix/pure-new-url

Conversation

@LingyuCoder
Copy link
Contributor

@LingyuCoder LingyuCoder commented Nov 4, 2025

Summary

The new URL("", import.meta.url) should be pure to inner graph plugin.

  • Add is_pure to parser driver which will be called in is_pure_expression

Related links

Checklist

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

Copilot AI review requested due to automatic review settings November 4, 2025 06:03
@netlify
Copy link

netlify bot commented Nov 4, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit e357113
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6909972f1a48a200088b83a6

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Nov 4, 2025
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 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_pure trait method to the JavascriptParserPlugin trait
  • Implemented is_pure in URLPlugin to identify pure new URL() expressions
  • Updated all side-effects checking functions to thread the parser parameter 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.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

📦 Binary Size-limit

Comparing e357113 to chore: improve struct type and remove some useless fields (#12071) by Fy

❌ Size increased by 1.63KB from 47.86MB to 47.86MB (⬆️0.00%)

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

📝 Benchmark detail: Open

Name Base (2025-11-04 2d78ee6) Current Change
10000_big_production-mode_disable-minimize + exec 25.7 s ± 648 ms 25.5 s ± 615 ms -0.57 %
10000_development-mode + exec 1.31 s ± 32 ms 1.29 s ± 39 ms -1.67 %
10000_development-mode_hmr + exec 631 ms ± 12 ms 622 ms ± 13 ms -1.40 %
10000_development-mode_noop-loader + exec 2.26 s ± 132 ms 2.22 s ± 25 ms -1.88 %
10000_production-mode + exec 1.39 s ± 14 ms 1.4 s ± 103 ms +0.23 %
10000_production-mode_persistent-cold + exec 1.52 s ± 45 ms 1.51 s ± 18 ms -1.01 %
10000_production-mode_persistent-hot + exec 1.06 s ± 12 ms 1.04 s ± 15 ms -2.26 %
arco-pro_development-mode + exec 1.58 s ± 93 ms 1.6 s ± 98 ms +1.22 %
arco-pro_development-mode_hmr + exec 358 ms ± 2 ms 359 ms ± 1.2 ms +0.14 %
arco-pro_production-mode + exec 2.91 s ± 78 ms 2.88 s ± 100 ms -1.15 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 2.99 s ± 151 ms 2.92 s ± 84 ms -2.31 %
arco-pro_production-mode_persistent-cold + exec 3.01 s ± 82 ms 2.99 s ± 69 ms -0.61 %
arco-pro_production-mode_persistent-hot + exec 1.68 s ± 89 ms 1.66 s ± 72 ms -1.44 %
arco-pro_production-mode_traverse-chunk-modules + exec 2.95 s ± 109 ms 2.95 s ± 146 ms +0.06 %
large-dyn-imports_development-mode + exec 1.59 s ± 28 ms 1.58 s ± 89 ms -0.16 %
large-dyn-imports_production-mode + exec 1.62 s ± 22 ms 1.61 s ± 38 ms -0.64 %
threejs_development-mode_10x + exec 1.35 s ± 145 ms 1.29 s ± 31 ms -3.88 %
threejs_development-mode_10x_hmr + exec 921 ms ± 11 ms 905 ms ± 27 ms -1.70 %
threejs_production-mode_10x + exec 3.97 s ± 24 ms 3.98 s ± 56 ms +0.35 %
threejs_production-mode_10x_persistent-cold + exec 4.15 s ± 221 ms 4.12 s ± 49 ms -0.84 %
threejs_production-mode_10x_persistent-hot + exec 3.63 s ± 136 ms 3.59 s ± 26 ms -1.12 %
10000_big_production-mode_disable-minimize + rss memory 5837 MiB ± 140 MiB 5903 MiB ± 315 MiB +1.14 %
10000_development-mode + rss memory 586 MiB ± 25.4 MiB 592 MiB ± 34.9 MiB +1.00 %
10000_development-mode_hmr + rss memory 740 MiB ± 20.6 MiB 741 MiB ± 16.3 MiB +0.12 %
10000_development-mode_noop-loader + rss memory 898 MiB ± 21.2 MiB 886 MiB ± 21.7 MiB -1.33 %
10000_production-mode + rss memory 583 MiB ± 97.7 MiB 566 MiB ± 37.4 MiB -2.97 %
10000_production-mode_persistent-cold + rss memory 647 MiB ± 20.1 MiB 658 MiB ± 57.8 MiB +1.69 %
10000_production-mode_persistent-hot + rss memory 670 MiB ± 99.1 MiB 631 MiB ± 25.1 MiB -5.91 %
arco-pro_development-mode + rss memory 487 MiB ± 42.2 MiB 476 MiB ± 69.2 MiB -2.37 %
arco-pro_development-mode_hmr + rss memory 382 MiB ± 13.4 MiB 383 MiB ± 8.4 MiB +0.25 %
arco-pro_production-mode + rss memory 622 MiB ± 53 MiB 621 MiB ± 18.9 MiB -0.05 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 628 MiB ± 84.6 MiB 623 MiB ± 57.7 MiB -0.85 %
arco-pro_production-mode_persistent-cold + rss memory 673 MiB ± 60.3 MiB 697 MiB ± 28.4 MiB +3.57 %
arco-pro_production-mode_persistent-hot + rss memory 512 MiB ± 46.7 MiB 538 MiB ± 82.4 MiB +4.93 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 615 MiB ± 38.5 MiB 596 MiB ± 65.1 MiB -3.05 %
large-dyn-imports_development-mode + rss memory 611 MiB ± 11.5 MiB 608 MiB ± 8.7 MiB -0.59 %
large-dyn-imports_production-mode + rss memory 555 MiB ± 6.64 MiB 552 MiB ± 5.69 MiB -0.50 %
threejs_development-mode_10x + rss memory 525 MiB ± 31.4 MiB 524 MiB ± 18.2 MiB -0.23 %
threejs_development-mode_10x_hmr + rss memory 729 MiB ± 37.5 MiB 725 MiB ± 45.7 MiB -0.54 %
threejs_production-mode_10x + rss memory 742 MiB ± 156 MiB 732 MiB ± 172 MiB -1.26 %
threejs_production-mode_10x_persistent-cold + rss memory 788 MiB ± 30.9 MiB 764 MiB ± 25.6 MiB -3.12 %
threejs_production-mode_10x_persistent-hot + rss memory 639 MiB ± 42.3 MiB 623 MiB ± 20 MiB -2.47 %

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 4, 2025

CodSpeed Performance Report

Merging #12076 will not alter performance

Comparing fix/pure-new-url (e357113) with main (2dc64de)

Summary

✅ 17 untouched

@LingyuCoder LingyuCoder requested a review from JSerFeng November 4, 2025 07:00
@LingyuCoder LingyuCoder merged commit 498466d into main Nov 5, 2025
55 checks passed
@LingyuCoder LingyuCoder deleted the fix/pure-new-url branch November 5, 2025 07:25
@h-a-n-a h-a-n-a mentioned this pull request Nov 5, 2025
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.

2 participants

Comments