Skip to content

Conversation

@SyMind
Copy link
Member

@SyMind SyMind commented Sep 11, 2025

Summary

This PR enhances alias resolution in watch mode by ensuring that successful factorizations track missing dependencies. This allows the bundler to properly re-resolve and update module paths when higher-priority alias files or new resolution-relevant files (such as package.json) are created or modified.

Problem

In watch mode, when a user adds or modifies a file that could affect module resolution (e.g., adding a higher-priority alias file or changing package.json exports), the resolver should re-resolve affected dependencies to ensure correctness. Previously, the bundler did not track these resolution dependencies, leading to outdated references.

Example

Given the alias configuration:

alias: ["a.js", "b.js"]

Where a.js has higher priority than b.js, if a user adds a.js after the initial build, the bundler should update the resolution from b.js to a.js. Without tracking missing dependencies during resolution, this update did not occur.

Implementation Details

The fix tracks missing dependencies during alias resolution. When a module is resolved, the resolver records any missing paths that, if created, would change the resolution outcome. This allows the watcher to trigger re-resolution when those files are added.

Additional Cases Handled

  1. Extension priority: For extensions like ['js', 'ts', 'tsx'], if a.ts is added after a.js was resolved, the resolver will now correctly update to use a.ts (if ts has higher priority).

  2. Directory index resolution: When a/index.js exists and a.js is added, the resolution updates from the index file to the higher-priority a.js.

  3. package.json tracking: Adding or modifying package.json (e.g., changing "main" or "exports") now triggers re-resolution for modules that depend on it.

Related links

Checklist

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

@netlify
Copy link

netlify bot commented Sep 11, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 67e1896
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/68d64109045b9a0008ce5a6d

@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 Sep 11, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 11, 2025

📦 Binary Size-limit

Comparing 67e1896 to perf: rspack sources buffer function (#11749) by Cong-Cong Pan

❌ Size increased by 10.50KB from 47.41MB to 47.42MB (⬆️0.02%)

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 11, 2025

CodSpeed Performance Report

Merging #11643 will not alter performance

Comparing fix-resolve-alias (67e1896) with main (1ceac70)

🎉 Hooray! codspeed-rust just leveled up to 2.7.2!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

✅ 17 untouched

@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 11, 2025
@SyMind SyMind force-pushed the fix-resolve-alias branch 2 times, most recently from 6b92f27 to 194ae49 Compare September 11, 2025 07:52
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 12, 2025
@SyMind SyMind force-pushed the fix-resolve-alias branch 2 times, most recently from 267ad8e to 446b9b3 Compare September 15, 2025 02:57
@jerrykingxyz jerrykingxyz mentioned this pull request Sep 18, 2025
2 tasks
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 19, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 19, 2025
@SyMind SyMind force-pushed the fix-resolve-alias branch 2 times, most recently from b5e315a to 2616215 Compare September 19, 2025 12:39
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 19, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 19, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 22, 2025
@SyMind SyMind marked this pull request as ready for review September 24, 2025 02:18
Copilot AI review requested due to automatic review settings September 24, 2025 02:18
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 enhances alias resolution in watch mode by transitioning from storing FactorizeInfo on individual dependencies to centralizing it in the module graph. This change allows successful factorizations to track missing dependencies, enabling proper re-resolution when higher-priority alias files are created.

  • Removes FactorizeInfo fields from all dependency structs and related traits
  • Adds centralized factorize info storage in ModuleGraphPartial with dedicated APIs
  • Updates successful factorizations to track missing dependencies for watch mode re-resolution

Reviewed Changes

Copilot reviewed 73 out of 73 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/* Test cases demonstrating alias resolution updates in watch mode
crates//dependency/.rs Removes factorize_info fields and related methods from all dependency types
crates/rspack_core/src/module_graph/mod.rs Adds centralized factorize info storage and iterator APIs
crates/rspack_core/src/dependency/*.rs Updates dependency traits and factorize info structure
crates/rspack_core/src/compilation/make/*.rs Updates factorization result handling and dependency tracking
crates/rspack_core/src/cache/*.rs Updates persistent cache to handle centralized factorize info
crates/rspack_binding_api/src/compilation/mod.rs Updates API bindings to use centralized factorize info access

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 25, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 25, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 25, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 25, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 25, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 25, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 25, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 25, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 25, 2025
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 25, 2025
@SyMind SyMind marked this pull request as draft September 26, 2025 02:35
@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 26, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 26, 2025

📝 Benchmark detail: Open

Name Base (2025-09-26 6c1a40e) Current Change
10000_big_production-mode_disable-minimize + exec 27.8 s ± 531 ms 28.4 s ± 988 ms +2.17 %
10000_development-mode + exec 1.62 s ± 22 ms 1.71 s ± 59 ms +5.61 %
10000_development-mode_hmr + exec 690 ms ± 4.2 ms 700 ms ± 2.2 ms +1.45 %
10000_development-mode_noop-loader + exec 2.59 s ± 113 ms 2.66 s ± 48 ms +2.93 %
10000_production-mode + exec 1.63 s ± 15 ms 1.72 s ± 117 ms +5.91 %
10000_production-mode_persistent-cold + exec 1.81 s ± 47 ms 1.9 s ± 18 ms +5.37 %
10000_production-mode_persistent-hot + exec 1.32 s ± 24 ms 1.43 s ± 46 ms +9.00 %
arco-pro_development-mode + exec 1.75 s ± 36 ms 1.78 s ± 99 ms +1.61 %
arco-pro_development-mode_hmr + exec 369 ms ± 1.6 ms 379 ms ± 1.4 ms +2.87 %
arco-pro_production-mode + exec 3.21 s ± 68 ms 3.2 s ± 143 ms -0.40 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.31 s ± 89 ms 3.27 s ± 130 ms -1.20 %
arco-pro_production-mode_persistent-cold + exec 3.31 s ± 100 ms 3.3 s ± 127 ms -0.27 %
arco-pro_production-mode_persistent-hot + exec 1.95 s ± 39 ms 2 s ± 62 ms +2.61 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.27 s ± 141 ms 3.23 s ± 42 ms -0.97 %
large-dyn-imports_development-mode + exec 1.82 s ± 38 ms 1.92 s ± 32 ms +5.84 %
large-dyn-imports_production-mode + exec 1.83 s ± 29 ms 1.92 s ± 144 ms +4.93 %
threejs_development-mode_10x + exec 1.46 s ± 21 ms 1.5 s ± 26 ms +2.72 %
threejs_development-mode_10x_hmr + exec 934 ms ± 35 ms 953 ms ± 21 ms +2.07 %
threejs_production-mode_10x + exec 4.46 s ± 71 ms 4.5 s ± 109 ms +0.70 %
threejs_production-mode_10x_persistent-cold + exec 4.56 s ± 63 ms 4.66 s ± 348 ms +2.20 %
threejs_production-mode_10x_persistent-hot + exec 4.1 s ± 158 ms 4.16 s ± 200 ms +1.67 %
10000_big_production-mode_disable-minimize + rss memory 8634 MiB ± 156 MiB 8648 MiB ± 470 MiB +0.16 %
10000_development-mode + rss memory 675 MiB ± 24.2 MiB 765 MiB ± 30 MiB +13.39 %
10000_development-mode_hmr + rss memory 831 MiB ± 35.8 MiB 941 MiB ± 22.1 MiB +13.30 %
10000_development-mode_noop-loader + rss memory 971 MiB ± 22.3 MiB 1062 MiB ± 15.8 MiB +9.30 %
10000_production-mode + rss memory 635 MiB ± 41.4 MiB 681 MiB ± 35.5 MiB +7.14 %
10000_production-mode_persistent-cold + rss memory 744 MiB ± 9.87 MiB 845 MiB ± 40.6 MiB +13.67 %
10000_production-mode_persistent-hot + rss memory 746 MiB ± 37.3 MiB 844 MiB ± 31.2 MiB +13.15 %
arco-pro_development-mode + rss memory 571 MiB ± 58.6 MiB 572 MiB ± 74.7 MiB +0.27 %
arco-pro_development-mode_hmr + rss memory 471 MiB ± 16 MiB 508 MiB ± 24 MiB +7.81 %
arco-pro_production-mode + rss memory 651 MiB ± 104 MiB 690 MiB ± 70.5 MiB +5.88 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 713 MiB ± 101 MiB 713 MiB ± 53.1 MiB +0.01 %
arco-pro_production-mode_persistent-cold + rss memory 791 MiB ± 72 MiB 793 MiB ± 50.7 MiB +0.30 %
arco-pro_production-mode_persistent-hot + rss memory 607 MiB ± 127 MiB 624 MiB ± 63.2 MiB +2.88 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 683 MiB ± 83.7 MiB 687 MiB ± 42.3 MiB +0.68 %
large-dyn-imports_development-mode + rss memory 692 MiB ± 5.69 MiB 781 MiB ± 4.39 MiB +12.85 %
large-dyn-imports_production-mode + rss memory 590 MiB ± 5.86 MiB 619 MiB ± 4.18 MiB +4.88 %
threejs_development-mode_10x + rss memory 595 MiB ± 23.1 MiB 596 MiB ± 15 MiB +0.15 %
threejs_development-mode_10x_hmr + rss memory 841 MiB ± 44.7 MiB 843 MiB ± 49.7 MiB +0.29 %
threejs_production-mode_10x + rss memory 798 MiB ± 197 MiB 867 MiB ± 12.5 MiB +8.70 %
threejs_production-mode_10x_persistent-cold + rss memory 820 MiB ± 9.98 MiB 821 MiB ± 28.5 MiB +0.14 %
threejs_production-mode_10x_persistent-hot + rss memory 720 MiB ± 36.2 MiB 728 MiB ± 50.6 MiB +1.18 %

Threshold exceeded: ["10000_development-mode + exec","10000_production-mode + exec","10000_production-mode_persistent-cold + exec","10000_production-mode_persistent-hot + exec","large-dyn-imports_development-mode + exec"]

@web-infra-dev web-infra-dev deleted a comment from github-actions bot Sep 26, 2025
@SyMind SyMind marked this pull request as ready for review September 26, 2025 07:33
@SyMind SyMind merged commit b5fc80f into main Sep 26, 2025
68 of 70 checks passed
@SyMind SyMind deleted the fix-resolve-alias branch September 26, 2025 08:01
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