Skip to content

feat: add Rspack 2 config and cache compatibility#1401

Open
dannyhw wants to merge 6 commits into
feat/rspack-2-node-guardfrom
feat/rspack-2-config-routing
Open

feat: add Rspack 2 config and cache compatibility#1401
dannyhw wants to merge 6 commits into
feat/rspack-2-node-guardfrom
feat/rspack-2-config-routing

Conversation

@dannyhw

@dannyhw dannyhw commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Combines Rspack-major configuration compatibility into one review unit:

This PR targets the combined runtime-foundations PR #1397. After #1397 lands, it will retarget to dannyhw/rspack-2-support.

What changed

  • Keep experiments.parallelLoader only for Rspack 1.
  • Default Rspack 2 exportsPresence to the React Native-friendly auto behavior.
  • Skip the obsolete global parallel-loader warning probe under Rspack 2.
  • Route profiling to the logger trace layer for published Rspack 2 builds.
  • Warn once when Rspack 2 sees legacy experiments.cache, without mutating user configuration.
  • Preserve reset-cache support for both legacy and top-level cache locations.

Detailed review history for the absorbed cache slice remains in #1399.

References

Validation

The component branches previously passed:

  • pnpm turbo run typecheck test --force — 17/17 tasks
  • Re.Pack unit tests under Rspack 1 and Rspack 2
  • pnpm lint:ci

The combined branch will run the same GitHub checks before merging.

@changeset-bot

changeset-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25c39de

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

@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 26, 2026 8:47pm

Request Review

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

@dannyhw

This comment has been minimized.

@dannyhw

This comment has been minimized.

Base automatically changed from feat/rspack-2-types-test-infra to feat/rspack-2-node-guard July 26, 2026 20:37
@dannyhw dannyhw changed the title feat: route rspack config by major (parallelLoader, exportsPresence, profiling) feat: add Rspack 2 config and cache compatibility Jul 26, 2026
@dannyhw
dannyhw force-pushed the feat/rspack-2-node-guard branch from 649c9e5 to 7554f51 Compare July 26, 2026 20:45
dannyhw added 6 commits July 26, 2026 21:45
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.
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