-
-
Notifications
You must be signed in to change notification settings - Fork 733
fix: should update alias resolution when a higher-priority file is created in watch mode #11643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for rspack canceled.
|
📦 Binary Size-limit
❌ Size increased by 10.50KB from 47.41MB to 47.42MB (⬆️0.02%) |
CodSpeed Performance ReportMerging #11643 will not alter performanceComparing 🎉 Hooray!
|
6b92f27 to
194ae49
Compare
crates/rspack_core/src/compilation/make/graph_updater/cutout/mod.rs
Outdated
Show resolved
Hide resolved
267ad8e to
446b9b3
Compare
b5e315a to
2616215
Compare
2616215 to
2ee5f28
Compare
2ee5f28 to
c55840b
Compare
There was a problem hiding this 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
FactorizeInfofields from all dependency structs and related traits - Adds centralized factorize info storage in
ModuleGraphPartialwith 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.
crates/rspack_core/src/compilation/make/graph_updater/repair/factorize.rs
Outdated
Show resolved
Hide resolved
18cb898 to
4c62c58
Compare
|
📝 Benchmark detail: Open
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"] |
f7063f8 to
497c56f
Compare
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.jsonexports), 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:
Where
a.jshas higher priority thanb.js, if a user addsa.jsafter the initial build, the bundler should update the resolution fromb.jstoa.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
Extension priority: For extensions like
['js', 'ts', 'tsx'], ifa.tsis added aftera.jswas resolved, the resolver will now correctly update to usea.ts(iftshas higher priority).Directory index resolution: When
a/index.jsexists anda.jsis added, the resolution updates from the index file to the higher-prioritya.js.package.jsontracking: Adding or modifying package.json (e.g., changing"main"or"exports") now triggers re-resolution for modules that depend on it.Related links
Checklist