feat: warn about legacy experiments.cache config under rspack 2#1399
feat: warn about legacy experiments.cache config under rspack 2#1399dannyhw wants to merge 2 commits into
Conversation
Rspack 2 moved persistent cache configuration from `experiments.cache` to the top-level `cache` option and silently ignores the legacy key - users migrating a Rspack 1 config would lose persistent caching without any signal. Emit a one-time actionable warning from the rspack start/bundle commands when running under Rspack 2 with a legacy `experiments.cache` value, pointing at the top-level `cache` option. The config is left untouched: migrating it is the user's move, and mutating it would make Re.Pack behave differently from bare Rspack given the same config.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: c90a677 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
dannyhw
left a comment
There was a problem hiding this comment.
codex review: I reviewed this against the stacked base branch feat/rspack-2-types-test-infra. I’m leaving the concrete issues inline.
The warning claimed persistent caching is NOT enabled whenever
'experiments.cache' was present, which is false for a migrated config
that sets top-level 'cache: { type: 'persistent' }' and only leaves the
inert legacy key behind. Gate the warning on the top-level persistent
cache being absent in the same config, and cover the helper with a test
matrix (legacy-only, typical Rspack 1 shape with 'cache: true',
memory-only top-level cache, migrated leftover key, multi-config, and
the once-only latch).
|
Both inline review points addressed in c90a677:
Validated with turbo typecheck/test across the monorepo, the rspack 1 jest lane in packages/repack, and biome. |
| const misconfigured = configs.some( | ||
| (config) => | ||
| config.experiments?.cache !== undefined && | ||
| !hasPersistentCacheEnabled(config) |
There was a problem hiding this comment.
codex review: This now suppresses the warning as soon as top-level cache.type is persistent, but that also hides partially migrated configs where the ignored legacy value still carries options that are not present at the top level, e.g. experiments.cache.storage or buildDependencies. Rspack 2 would use the top-level persistent cache and silently drop those legacy options, so the user gets no signal even though there is still legacy cache config to migrate. The new test asserts silence for the broad cache: { type: "persistent" } + experiments.cache shape, so it would miss this partial-migration regression. Please either keep warning when experiments.cache contains ignored options with wording that does not claim persistent caching is disabled, or only suppress when the legacy cache value is known to be fully represented by the top-level cache.
Part of the Rspack 2 support PR stack (reference implementation: #1393, design doc:
agent_context/rspackv2-jul2026/design.md).What
Emits a one-time warning from the rspack
start/bundlecommands when running under Rspack 2 with a legacyexperiments.cachevalue in the config, pointing the user at the top-levelcacheoption. The config is left untouched — no value is copied or deleted.Why
Rspack 2 moved persistent cache configuration from
experiments.cacheto the top-levelcacheoption and silently ignores the legacy key (validation is loose). A user migrating a Rspack 1 config would lose persistent caching with no signal at all.Warn-only (rather than auto-migrating the value) follows the explicit maintainer guidance on #1393: users migrate their own config, and mutating it at runtime would make Re.Pack behave differently from bare Rspack given the same config. This behavior was verified against the built dist on the reference branch: warns exactly once, config untouched.
Changes
commands/common/warnLegacyRspackCacheConfig.ts(new) — the one-time warning, keyed off theRspackConfigurationWithLegacyCachetype introduced with the cache accessorcommands/common/index.ts— exportcommands/rspack/start.ts/bundle.ts— call sites only, gated onisRspack2; the diff is kept to the minimal wiring (the helper lives incommands/common/so it could serve a webpack counterpart if one ever existed, per the command-path-convergence feedback on feat: support Rspack 2 alongside Rspack 1 - reference implementation (to be broken down) #1393).changeset/rspack-2-cache-warning.md— patch changesetStack position
Parallel set — based on PR 2c (#1398) ← 2b (#1397) ← 2a (#1394). No shared files with the other parallel-set PRs (this is the only one touching
start.ts/bundle.ts).Validation
pnpm turbo run typecheck test --force— 17/17 tasks greenpackages/repack:pnpm testandpnpm test:rspack1— 282/282 under both Rspack majorspnpm lint:ci— clean