Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: f7265b5 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 |
8454e13 to
23a654c
Compare
b1b83ac to
d21991b
Compare
Raise the @rspack/core peer to >=2 and build and test against 2.2.8. Map the options Rspack 2 renamed or removed: - Stop setting experiments.parallelLoader, which Rspack 2 removed. Parallel loading is opted into per rule with `parallel: true`. The babel-swc-loader warning about it could no longer fire, so it is removed together with the hideParallelModeWarning option. - Rspack 2 passes parallel loaders a correct rootContext and the compiler's bundled SWC, so the babel-swc-loader uses both directly. - REPACK_EXPERIMENTAL_CACHE sets and --reset-cache reads the top-level `cache` option, as Rspack 2 silently ignores experiments.cache. - Fix the type fallout: a non-union SwcConfig for the babel-swc-loader, InputFileSystem-typed reads in the assets loader, and narrowing the now `false | DevServer` devServer option. Jest loads the ESM-only core through a custom test environment, and the integration markers and snapshots follow Rspack 2's output. # Conflicts: # packages/repack/src/loaders/babelSwcLoader/babelSwcLoader.ts # pnpm-lock.yaml # tests/integration/src/loaders/react-native-parser.test.ts
Rspack 2 changed the default of module.parser.javascript.exportsPresence to 'error', which fails builds on missing-export imports that React Native itself ships, such as `React.unstable_Activity` in renderApplication.js. Default it to 'auto', matching webpack and Rspack 1. Projects can still override it.
Published Rspack 2 binaries are built without the perfetto trace layer, so `RSPACK_PROFILE` crashed `start` unless RSPACK_TRACE_LAYER was set. Default to the logger layer, and drop the handler for Rspack < 1.4.
The SWC minimizer was only picked for Rspack 1.4.11, which Re.Pack no longer supports, so the minimizer no longer depends on the bundler.
Rspack 2's stats.toJson() leaves out assets, chunks, chunk groups, entrypoints and modules unless they are asked for, even with the `normal` preset. When the project has no stats config, request them explicitly so `bundle --json` writes the same stats as before.
Rspack 2 joins a module's absoluteResourcePath from the context without resolving it, so files outside the project root, such as hoisted node_modules in a monorepo, were named `<context>/../../...` in source maps built without a dev server. Normalize the path.
…e source Rspack 2 percent-encodes the resource path of the Module Federation runtime `data:` module, so the malformed `webpack://` source it produces no longer matched the raw prefix and was not renamed to `webpack://module-federation/virtual-runtime-<hash>.js`.
Replace experiments.parallelLoader with per-rule `parallel: true`, drop hideParallelModeWarning, list the exportsPresence default, and add a Rspack 2 section to the Re.Pack 5 migration guide.
…lugin snapshots Rspack 2 inlines the MF v2 bundler runtime as a URL-encoded data: URI, which put an absolute local path in the snapshot, and colors inlined error messages when color output is enabled, as it is on CI.
d21991b to
f7265b5
Compare
Apex SentinelVerdict: 4 finding(s): 4 minor. 🟡 Minor (4)
6 findings below Not in the reviewers' prompt (3 files)
Reviewed with this repository's own Sentinel configuration ( Feedback goes in the review comment threads, as a reply under the inline comment of a finding: Reply Useful? Reply Comment |
There was a problem hiding this comment.
Apex Sentinel: 4 new findings on f7265b5. The verdict and the full list are in the summary comment.
| // Rspack 2 leaves these out of `stats.toJson()` unless asked for, | ||
| // webpack includes them by default | ||
| const DEFAULT_JSON_STATS_OPTIONS = { | ||
| assets: true, | ||
| chunks: true, | ||
| chunkGroups: true, | ||
| chunkModules: true, | ||
| entrypoints: true, | ||
| modules: true, | ||
| }; |
There was a problem hiding this comment.
🟡 Minor · Rspack-only stats workaround now also overrides webpack's default stats
A webpack project with no stats config gets chunkModules: true from the hard-coded six-key object in normalizeStatsOptions, so bundle --json output gains per-chunk nested module arrays that webpack's normal preset does not enable. bundle.ts calls normalizeStatsOptions regardless of bundler, so the Rspack-only workaround overrides webpack's default stats for all projects. Gate the workaround at the bundle.ts call site or pass the bundler in.
Details
Also raised here
Also raised at this location by persona javascript: bundle --json stats fallback now overrides webpack's own default stats too — Running bundle --json on a webpack project with no stats config used to call stats.toJson(undefined) and get webpack's own default JSON (which includes errors, warnings, hash, time, version alongside assets/chunks/modules). normalizeStatsOptions now returns the six-key DEFAULT_JSON_STATS_OPTIONS whenever options is undefined or an empty object, and the function has no bundler parameter, so the same explicit partial options object is handed to webpack's toJson — every key the comment says webpack "includes by default" but that is not listed (errors, warnings, hash, time, version, reasons…) is now filtered out of the written JSON, contradicting the PR's claim that webpack is unaffected. The new branch is also inconsistent for the neighbouring case: { assets: false } is non-empty so it passes through unchanged and still loses the six defaults for the user's own config, while {} silently gains them.
persona: senior-developer, javascript
|
|
||
| const lazyImports = options.lazyImports ?? false; | ||
| const projectRoot = getProjectRootPath(this); | ||
| const projectRoot = this.rootContext; |
There was a problem hiding this comment.
🟡 Minor · root: projectRoot drops the babelConfig.root fallback for files at the project root
A file at the project root where rootContext === context (e.g. App.tsx) now passes root: this.rootContext to both Babel and SWC calls; previously this case returned undefined and let Babel resolve the root itself. If the Babel config lives above rootContext and rootMode: 'upward' is not set, Babel now stops its config-file search at rootContext, so presets/plugins from the outer config are silently not applied. The rootContext !== context guard existed specifically to avoid this; removing it also silently changes behavior for webpack + thread-loader users, which the changeset claims are unaffected.
| const projectRoot = this.rootContext; | |
| const projectRoot = | |
| this.rootContext !== this.context ? this.rootContext : undefined; |
Suggested change
Either restore the rootContext !== context guard (or the babelConfig.root ?? undefined fallback) for the ambiguous case, or state in the v6 migration guide that babel-swc-loader now always pins Babel/SWC root to rootContext so monorepo projects with an outer Babel config must set rootMode: 'upward'.
Details
persona: senior-developer, maintainability
| async function getSwcModule(loaderContext: LoaderContext): Promise<Swc | null> { | ||
| const projectRoot = getProjectRootPath(loaderContext) ?? process.cwd(); | ||
| const isWebpack = isWebpackBackend(loaderContext); | ||
| if (!isWebpack) { | ||
| // happy path - rspack & exposed swc | ||
| // use optional chaining to avoid type errors when using parallel loader | ||
| if (loaderContext._compiler.rspack?.experiments?.swc) { | ||
| return loaderContext._compiler.rspack.experiments.swc; | ||
| } | ||
| // fallback to checking for `@rspack/core` installed in the project | ||
| // use optional chaining to avoid type errors when there is no experiments.swc | ||
| const rspackCorePath = safelyResolve('@rspack/core', projectRoot); | ||
| if (rspackCorePath && !isWebpack) { | ||
| const rspack = await importDefaultESM<typeof Rspack>(rspackCorePath); | ||
| return rspack.experiments?.swc ?? null; | ||
| } | ||
| if (!isWebpackBackend(loaderContext)) { | ||
| // Rspack exposes its bundled SWC, also to parallel loaders | ||
| return loaderContext._compiler.rspack.experiments.swc; | ||
| } | ||
| // fallback to checking for `@swc/core` installed in the project | ||
| // this can be in both webpack & rspack projects | ||
| const swcCorePath = safelyResolve('@swc/core', projectRoot); | ||
| // webpack - use `@swc/core` installed in the project | ||
| const swcCorePath = safelyResolve('@swc/core', loaderContext.rootContext); |
There was a problem hiding this comment.
🟡 Minor · Unchained _compiler.rspack.experiments.swc throws when backend detection falls through
When isWebpackBackend returns false (detection falls through) and the loader context's compiler lacks rspack or experiments.swc (e.g. a mocked or older compiler), the unchained loaderContext._compiler.rspack.experiments.swc throws TypeError: Cannot read properties of undefined (reading 'experiments') instead of returning null to fall back to Babel. The predecessor's optional chaining and @rspack/core resolution fallback are both gone, changing the failure mode from a Babel fallback to a build crash.
| async function getSwcModule(loaderContext: LoaderContext): Promise<Swc | null> { | |
| const projectRoot = getProjectRootPath(loaderContext) ?? process.cwd(); | |
| const isWebpack = isWebpackBackend(loaderContext); | |
| if (!isWebpack) { | |
| // happy path - rspack & exposed swc | |
| // use optional chaining to avoid type errors when using parallel loader | |
| if (loaderContext._compiler.rspack?.experiments?.swc) { | |
| return loaderContext._compiler.rspack.experiments.swc; | |
| } | |
| // fallback to checking for `@rspack/core` installed in the project | |
| // use optional chaining to avoid type errors when there is no experiments.swc | |
| const rspackCorePath = safelyResolve('@rspack/core', projectRoot); | |
| if (rspackCorePath && !isWebpack) { | |
| const rspack = await importDefaultESM<typeof Rspack>(rspackCorePath); | |
| return rspack.experiments?.swc ?? null; | |
| } | |
| if (!isWebpackBackend(loaderContext)) { | |
| // Rspack exposes its bundled SWC, also to parallel loaders | |
| return loaderContext._compiler.rspack.experiments.swc; | |
| } | |
| // fallback to checking for `@swc/core` installed in the project | |
| // this can be in both webpack & rspack projects | |
| const swcCorePath = safelyResolve('@swc/core', projectRoot); | |
| // webpack - use `@swc/core` installed in the project | |
| const swcCorePath = safelyResolve('@swc/core', loaderContext.rootContext); | |
| if (!isWebpackBackend(loaderContext)) { | |
| // Rspack exposes its bundled SWC, also to parallel loaders | |
| return loaderContext._compiler.rspack?.experiments?.swc ?? null; | |
| } |
Details
Also raised here
Also raised at this location by persona javascript: getSwcModule throws instead of falling back when _compiler.rspack is missing — The loader now reads loaderContext._compiler.rspack.experiments.swc with no optional chaining and no fallback, so any context whose mocked _compiler lacks a rspack property throws TypeError: Cannot read properties of undefined (reading 'experiments') inside babelSwcLoader's try block and fails the module build. isWebpackBackend in this same file ends with "if both checks fail, we assume it's a Rspack compiler" and its own comment records that "parallel loader in Rspack has mocked compiler object without most props", so a context where neither _compiler.webpack.version nor loaderContext.webpack is present (the webpack thread-loader worker shape it was written for, or any future mock) is routed into the Rspack branch with no rspack on it. The predecessor resolved @rspack/core from the project and then @swc/core in that situation and returned null, which fell back to a Babel-only transform instead of erroring; that recovery path is gone. …
persona: senior-developer, javascript
| @@ -60,8 +60,9 @@ function defaultModuleFilenameTemplateHandler( | |||
| return `inlined-${info.hash}`; | |||
There was a problem hiding this comment.
🟡 Minor · path.normalize rewrites non-filesystem source names, not just Rspack's unjoined path
On Windows, path.normalize converts / to \ in non-filesystem source names like data: URIs, mangling them (e.g. data:text\javascript,...); SourceMapPlugin consumers that match on the original prefix stop matching.
Suggested change
Normalize only when path.isAbsolute(info.absoluteResourcePath) and pass pseudo-paths through unchanged.
// use absolute path for all other modules - Rspack 2 joins it from the context
// without resolving, e.g. `<context>/../../node_modules/...`
if (path.isAbsolute(info.absoluteResourcePath)) {
return path.normalize(info.absoluteResourcePath);
}
return info.absoluteResourcePath;
}
Details
persona: javascript
Stacked on #1487 (
dannyhw/v6).Summary
Re.Pack 6 requires
@rspack/core2 (peer>=2) and drops Rspack 1. There's no runtime branching on the Rspack major. The change maps the options Rspack 2 renamed or moved, fixes the type fallout, and removes the Rspack 1 workarounds. webpack is unaffected. New projects from@callstack/repack-initget@rspack/core@^2.Mapped options
experiments.parallelLoader: Rspack 2 removed it, so Re.Pack no longer sets it. Loaders run in parallel when their rule setsparallel: true, which the templates and tester apps already do.hideParallelModeWarningoption are removed.experiments.cache: Rspack 2 ignores it silently, soREPACK_EXPERIMENTAL_CACHEproduced no persistent cache. It now sets top-levelcache: { type: 'persistent' }.--reset-cachereads top-levelcachefor both bundlers.resetPersistentCachelost its per-bundler overloads and casts.exportsPresence: Rspack 2's default is'error', which fails on missing-export imports that React Native itself ships (React.unstable_ActivityinrenderApplication.js). Re.Pack setsmodule.parser.javascript.exportsPresence: 'auto'for Rspack.RSPACK_PROFILE: it crashedstartbecause published v2 binaries have no perfetto layer. It now defaults to theloggerlayer. The pre-1.4 profile handler is gone.Rspack 2 behaviour changes handled
bundle --json:stats.toJson()now leaves out assets, chunks, chunk groups, entrypoints and modules unless asked for, even withpreset: 'normal'. With no stats config, Re.Pack requests them explicitly. User presets are passed through.absoluteResourcePathis now<context>/../../...and isn't resolved.SourceMapPluginnormalizes it.repack-expo: the Module Federation runtimedata:module's resource path is now percent-encoded. The Expo source map fix matches the encoded form.Types
SwcLoaderOptionsis now a union ondetectSyntax, so the loader uses its own non-unionSwcConfig.assetsLoader: it reads through small promise wrappers typed againstInputFileSystem, becauseutil.promisifypicks the wrong overload of the v2 types.RepackTargetPlugin:devServeris nowfalse | DevServer, so it's narrowed before readinghot.Rspack 1 workarounds removed
rootContextworkaround and the@rspack/corefallback lookup for SWC. Rspack 2 passes parallel loaders the rightrootContextand_compiler.rspack.experiments.swc(checked in serial and parallel mode).Tests and infra
jest.environment.jsplus amoduleNameMapperbridge).// repack/polyfillsembed_federation_runtime. MF still initializes in__webpack_require__.x(), after the polyfills, in both the test bundle and the real host bundle (MF 2.9.2).exportsPresencedefaultSourceMapPluginpath normalization: a real Rspack compile that fails without the fix^2.2.8. The old "1.6.2+ breaks MF v2 polyfill ordering; 1.6.4+ fails typecheck" notes don't apply to 2.2.8.@swc/helpersis^0.5.23, the Rspack 2 peer.Docs
parallelLoader→ per-ruleparallel: truein the configuration guide and the babel-loader / babel-swc-loader pagesexportsPresenceagent_contextdesign doc rewritten for the single-major approachKnown issue (upstream, not fixed here)
In tester-app production bundles, 9 of about 1100 source map sources point one directory too shallow, e.g.
apps/packages/repack/dist/modules/InitializeScriptManager.js. The affected sources are Re.Pack's own runtime modules, reached through the workspace symlinkapps/tester-app/node_modules/@callstack/repack -> ../../../../packages/repack.resourcePathfor these modules. The wrong path is what you get by resolving the link target against the link instead of its directory.require.contextmodule that was already wrong on 1.6.[projectRoot]sources resolve.Verification
Run on Rspack 2.2.8, Node 26:
Checks:
pnpm build,pnpm typecheck,pnpm lint:ciandpnpm test, all with--force. All pass, including:Bundles:
apps/tester-federation-v2/configs/*.mts, iOS + Android each: Rspack host, mini and expo-host-widget, webpack host and minibundle --jsonwrites assets/chunks/modules again, and--stats minimalis respectedDev server:
startserves iOS + AndroidREPACK_EXPERIMENTAL_CACHE=1writesnode_modules/.cache/rspack: cold compile 11.2s, warm 2.7s--reset-cachedeletes that directoryRSPACK_PROFILE=OVERVIEWemits logger traces with no perfetto crashNative apps: tester-app Debug ran against the Rspack 2 dev server on the iOS simulator (iPhone 17 Pro, iOS 27) and the Android emulator (Pixel 9).
src/App.tsxhot-updated the screen in place on both platforms, with component state kept.main.<hash>.hot-update.json, with no bundle reload.[HMRClient] Processing bundle update.I also checked out the first commit on its own: it typechecks and passes its Jest suite (340).