-
-
Notifications
You must be signed in to change notification settings - Fork 746
fix: track package.json files in node_modules as build dependencies #12274
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.
|
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 adds tracking of package.json files in node_modules as build dependencies to ensure proper cache invalidation when package metadata changes. This is important for build correctness as changes to package.json files (such as version updates or exports field modifications) can affect module resolution and should trigger cache invalidation.
Key changes:
- Modified build dependency tracking to include
package.jsonfiles for resolved modules innode_modules - Refactored
is_node_package_pathutility function frombuild_dependencies/utils.rstobuild_dependencies/helper/utils.rs - Extended test coverage to verify cache invalidation behavior for both library and project
package.jsonchanges
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
crates/rspack_core/src/cache/persistent/build_dependencies/mod.rs |
Updated import to use is_node_package_path from helper module |
crates/rspack_core/src/cache/persistent/build_dependencies/helper/mod.rs |
Added logic to track package.json files for resolved modules in node_modules; added test case |
crates/rspack_core/src/cache/persistent/build_dependencies/helper/utils.rs |
Refactored utility function location; changed parameter type from &ArcPath to &Path |
tests/rspack-test/cacheCases/common/build-dependencies-resolve/rspack.config.js |
Extended test to cover package.json modification scenarios |
tests/rspack-test/cacheCases/common/build-dependencies-resolve/package.json |
Added project package.json test fixture |
tests/rspack-test/cacheCases/common/build-dependencies-resolve/other.config.js |
Added dependency and comments for clarity |
tests/rspack-test/cacheCases/common/build-dependencies-resolve/node_modules/lib/package.json |
Added version field for testing |
tests/rspack-test/cacheCases/common/build-dependencies-resolve/index.js |
Extended test assertions for new compilation runs |
tests/rspack-test/cacheCases/common/build-dependencies-resolve/file.js |
Added new test data versions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Binary Size-limit
❌ Size increased by 7.50KB from 47.63MB to 47.64MB (⬆️0.02%) |
CodSpeed Performance ReportMerging #12274 will not alter performanceComparing Summary
|
Summary
When recursively resolve BuildDependencies, for performance reasons, resolver will stop when it reaches files within node_modules. This may cause problems when users upgrade dependencies, so package.json needs to be added to buildDependencies.
Related links
Checklist