-
-
Notifications
You must be signed in to change notification settings - Fork 758
feat: add support for readonly persistent cache #12902
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
base: main
Are you sure you want to change the base?
feat: add support for readonly persistent cache #12902
Conversation
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 support for a readonly option to the persistent filesystem cache, enabling CI workflows to load cached build artifacts from ancestor commits without incurring I/O costs of writing cache updates. This mirrors webpack's cache.readonly feature.
Changes:
- Added
readonlyboolean property to cache configuration types across TypeScript and Rust layers - Modified persistent cache implementation to skip all write operations when readonly mode is enabled
- Added comprehensive end-to-end test validating that cache files remain unmodified during readonly builds
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/rspack/src/config/types.ts | Added readonly property to PersistentCacheOptions type definition |
| packages/rspack/src/config/normalization.ts | Added normalization logic to default readonly to false |
| packages/rspack/etc/core.api.md | Updated public API documentation to include readonly property |
| crates/rspack_binding_api/src/raw_options/raw_cache/mod.rs | Added readonly field to Rust binding options and conversion logic |
| crates/rspack_core/src/cache/persistent/mod.rs | Implemented readonly guards in save operations and compilation hooks |
| crates/rspack_core/src/cache/persistent/build_dependencies/mod.rs | Added readonly mode to skip build dependency validation |
| tests/e2e/cases/persistent-cache/readonly/rspack.config.js | Test configuration with readonly cache setup |
| tests/e2e/cases/persistent-cache/readonly/index.test.ts | E2E test verifying cache files are not modified in readonly mode |
| tests/e2e/cases/persistent-cache/readonly/module.js | Test module for cache validation |
| tests/e2e/cases/persistent-cache/readonly/index.js | Test entry point displaying module value |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// If any build dependencies have changed, this method will reset storage. | ||
| pub async fn validate(&mut self) -> Result<()> { | ||
| if self.readonly { | ||
| tracing::info!("BuildDependencies: validation skipped because readonly mode is enabled"); |
Copilot
AI
Jan 30, 2026
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.
Corrected spelling of 'BuildDependencies' to 'Build dependencies'.
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.
Perhaps this tracing info is not necessary
Summary
This adds support for a
readonlyoption for the persistent filesystem cache. The equivalent webpack feature is documented here.A readonly cache supports CI workflows where branch builds load in a filesystem cache from the a recent ancestor commit on the trunk branch. In many cases, these branch builds happen too often and are too ephemeral to justify storing the build cache results. Adding a
readonlyoption allows such builds to avoid I/O costs of writing the cache to disk.Checklist