feat: add Rspack 2 config and cache compatibility#1401
Conversation
🦋 Changeset detectedLatest commit: 25c39de 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
dannyhw
left a comment
There was a problem hiding this comment.
codex review: The main behavior in this PR is major-based routing, but the diff does not add direct assertions for that matrix. getRepackConfig should have tests proving Rspack 1 still emits experiments.parallelLoader, Rspack 2 omits it and sets module.parser.javascript.exportsPresence: 'auto', and webpack remains unchanged. The same gap exists for the new v2 profiling router/default and the Rspack 2 loader-warning skip. Without those tests, the stated compatibility guarantee can regress without the current suite catching it.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
649c9e5 to
7554f51
Compare
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.
…profiling) Adapt the generated defaults to the installed @rspack/core major: - getRepackConfig only sets experiments.parallelLoader under Rspack 1; Rspack 2 removed the flag (parallel loading is stable and opt-in per rule via use[].parallel), so it is no longer injected there - under Rspack 2, module.parser.javascript.exportsPresence defaults to 'auto' to keep Metro-like tolerance for invalid imports inside node_modules (Rspack 2 changed the default to 'error') - checkParallelModeAvailable in babelSwcLoader skips its parallel-mode probe under Rspack 2: the probe's signal was the global flag, which no longer exists, so running non-parallel is a valid choice there rather than a misconfiguration - RSPACK_PROFILE profiling routes to a new profile-2 handler under Rspack 2 that defaults the trace layer to 'logger' (published Rspack 2 binaries do not include the perfetto layer)
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).
…ning Add direct assertions for the version-routing matrix introduced in this branch: - getRepackConfig: Rspack 1 emits experiments.parallelLoader, Rspack 2 omits it and relaxes module.parser.javascript.exportsPresence to 'auto', webpack gets neither and never probes the rspack version; unresolvable versions fall back to Rspack 1 behavior - profiling: the handler router picks profile-2 for major >= 2 (including prereleases), profile-1.4 for >= 1.4, legacy otherwise; profile-2 defaults to the logger trace layer, still accepts an explicit perfetto layer, and rejects unsupported layers - babelSwcLoader: the parallel-mode warning fires under Rspack 1 with a global parallelLoader flag, and is skipped under Rspack 2, webpack, and mocked parallel-mode compilers Dynamic import() cannot execute in Jest's CJS runtime without --experimental-vm-modules (which breaks other tests), so the test env now transforms dynamic imports to require via @babel/plugin-transform-dynamic-import - this also makes jest module mocks apply to lazily-imported modules.
d21a4a0 to
25c39de
Compare
Summary
Combines Rspack-major configuration compatibility into one review unit:
experiments.cachehandling from feat: warn about legacy experiments.cache config under rspack 2 #1399.This PR targets the combined runtime-foundations PR #1397. After #1397 lands, it will retarget to
dannyhw/rspack-2-support.What changed
experiments.parallelLoaderonly for Rspack 1.exportsPresenceto the React Native-friendlyautobehavior.experiments.cache, without mutating user configuration.Detailed review history for the absorbed cache slice remains in #1399.
References
agent_context/rspackv2-jul2026/design.mdValidation
The component branches previously passed:
pnpm turbo run typecheck test --force— 17/17 taskspnpm lint:ciThe combined branch will run the same GitHub checks before merging.