perf: add support for module.unsafeCache configuration#11898
Merged
Conversation
✅ Deploy Preview for rspack canceled.
|
Contributor
📦 Binary Size-limit
🎉 Size decreased by 5.00KB from 47.67MB to 47.67MB (⬇️0.01%) |
CodSpeed Performance ReportMerging #11898 will not alter performanceComparing Summary
Footnotes |
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds support for module.unsafeCache to control resolver dependency tracking for performance, with boolean and RegExp options, wired through schema, normalization, defaults, adapter, bindings, and core, plus docs and tests.
- Schema/types accept boolean | RegExp; normalization/adapter pass-through to core
- Defaults gate unsafeCache on cache, with node_modules-only behavior when true
- Core applies predicate to skip resolver file/context/missing deps for matched modules; docs and tests added
Reviewed Changes
Copilot reviewed 22 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/zh/config/module.mdx | Documents module.unsafeCache behavior and defaults in Chinese |
| website/docs/en/config/module.mdx | Documents module.unsafeCache behavior and defaults in English |
| tests/rspack-test/defaultsCases/mode/development.js | Updates defaults snapshot to reflect unsafeCache in development with cache |
| tests/rspack-test/defaultsCases/default/base.js | Asserts unsafeCache defaults to false when cache is disabled |
| tests/rspack-test/defaultsCases/cache/non-root.js | Updates snapshot: unsafeCache true when cache filesystem enabled non-root |
| tests/rspack-test/defaultsCases/cache/cache.js | Updates snapshot: unsafeCache true when cache enabled |
| tests/rspack-test/defaultsCases/cache/cache-filesystem.js | Updates snapshot: unsafeCache true with filesystem cache |
| tests/rspack-test/configCases/unsafe-cache/regExp/rspack.config.js | Adds test for RegExp predicate behavior on missingDependencies |
| tests/rspack-test/configCases/unsafe-cache/regExp/index.js | Test entry for RegExp case |
| tests/rspack-test/configCases/unsafe-cache/enabled/rspack.config.js | Adds test for boolean true behavior on dependency tracking |
| tests/rspack-test/configCases/unsafe-cache/enabled/index.js | Test entry for boolean true case |
| packages/rspack/src/schema/config.ts | Adds unsafeCache schema (boolean |
| packages/rspack/src/config/types.ts | Adds unsafeCache to ModuleOptions type |
| packages/rspack/src/config/normalization.ts | Wires unsafeCache through normalization |
| packages/rspack/src/config/defaults.ts | Sets unsafeCache default based on cache setting |
| packages/rspack/src/config/adapter.ts | Passes unsafeCache through to raw options |
| crates/rspack_core/src/options/module.rs | Introduces UnsafeCachePredicate and field; debug adjustments |
| crates/rspack_core/src/compilation/make/graph_updater/repair/factorize.rs | Applies predicate to elide resolver deps in FactorizeInfo |
| crates/rspack_binding_api/src/raw_options/raw_module/mod.rs | Adds unsafe_cache to RawModuleOptions; implements predicate mapping and node_modules default |
| crates/rspack/src/builder/mod.rs | Wires unsafe_cache in ModuleOptionsBuilder; debug macro import |
| crates/rspack/Cargo.toml | Adds derive_more dependency |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Contributor
|
📝 Benchmark detail: Open
|
472de9a to
4bf039e
Compare
4ec6b73 to
cc180c2
Compare
ahabhgk
previously approved these changes
Oct 17, 2025
stormslowly
previously approved these changes
Oct 17, 2025
e3ad8ee to
ab5e366
Compare
hardfist
approved these changes
Oct 20, 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
Add support for
module.unsafeCacheconfigurationThis PR implements the
module.unsafeCacheoption to optimize build performance by controlling dependency tracking fornode_modules.Behavior
When
module.unsafeCacheis disabled (false)missingDependencies,fileDependencies, andcontextDependenciesreturned by the resolverWhen
module.unsafeCacheis enabled (default:/[\\/]node_modules[\\/]/)node_modulesfiles are stable and won't change pathsmissingDependencies,fileDependencies,contextDependencies) fornode_modulesmodulesDifferences from webpack
1. Incremental Module Graph Rebuilding
module.unsafeCache: false, Rspack still caches the Dependency-Module relationship2. Configuration Support
module.unsafeCache(to avoid frequent Rust-JavaScript communication overhead)true/false)Checklist