Skip to content

feat: warn about legacy experiments.cache config under rspack 2#1399

Open
dannyhw wants to merge 2 commits into
feat/rspack-2-types-test-infrafrom
feat/rspack-2-cache-warning
Open

feat: warn about legacy experiments.cache config under rspack 2#1399
dannyhw wants to merge 2 commits into
feat/rspack-2-types-test-infrafrom
feat/rspack-2-cache-warning

Conversation

@dannyhw

@dannyhw dannyhw commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

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/bundle commands when running under Rspack 2 with a legacy experiments.cache value in the config, pointing the user at the top-level cache option. The config is left untouched — no value is copied or deleted.

Why

Rspack 2 moved persistent cache configuration from experiments.cache to the top-level cache option 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 the RspackConfigurationWithLegacyCache type introduced with the cache accessor
  • commands/common/index.ts — export
  • commands/rspack/start.ts / bundle.ts — call sites only, gated on isRspack2; the diff is kept to the minimal wiring (the helper lives in commands/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 changeset

Stack 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 green
  • packages/repack: pnpm test and pnpm test:rspack1 — 282/282 under both Rspack majors
  • pnpm lint:ci — clean

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.
@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
repack-website Ready Ready Preview, Comment Jul 6, 2026 7:28pm

Request Review

@changeset-bot

changeset-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c90a677

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@callstack/repack Patch
@callstack/repack-plugin-expo-modules Patch
@callstack/repack-plugin-nativewind Patch
@callstack/repack-plugin-reanimated Patch
@callstack/repack-dev-server Patch
@callstack/repack-init Patch

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 dannyhw left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codex review: I reviewed this against the stacked base branch feat/rspack-2-types-test-infra. I’m leaving the concrete issues inline.

Comment thread packages/repack/src/commands/common/warnLegacyRspackCacheConfig.ts Outdated
Comment thread packages/repack/src/commands/common/warnLegacyRspackCacheConfig.ts
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).
@dannyhw

dannyhw commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

Both inline review points addressed in c90a677:

  • False "NOT enabled" claim: the warning is now gated on top-level persistent cache being absent in the same config that carries the legacy key, so a migrated config with a leftover 'experiments.cache' no longer gets a false warning. It still fires for the shapes where the claim is true (legacy-only, 'cache: true' + legacy key, memory-only top-level cache).
  • Test coverage: added a helper test matrix in packages/repack/src/commands/common/tests/warnLegacyRspackCacheConfig.test.ts (7 cases, including the migrated shape and the once-only latch).

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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant