Skip to content

chore(clerk-js,ui): upgrade to Rspack 2#8382

Open
jacekradko wants to merge 3 commits intomainfrom
jacek/rspack-2
Open

chore(clerk-js,ui): upgrade to Rspack 2#8382
jacekradko wants to merge 3 commits intomainfrom
jacek/rspack-2

Conversation

@jacekradko
Copy link
Copy Markdown
Member

Description

WIP — do not merge yet. First pass at upgrading the monorepo from Rspack 1.7.x to Rspack 2.0.0 so we can evaluate the migration end to end.

Both @clerk/clerk-js and @clerk/ui build green on Rspack 2 across every variant (7 for clerk-js: browser, legacy browser, native, esm, esm-no-rhc, cjs, cjs-no-rhc; 3 for ui: browser, legacy, shared).

What's in the diff

  • Node minimum bumped to 22.12.0 (Rspack 2 requirement; previously 22.11.0) in .nvmrc and root engines.node.
  • Rspack catalog2.0.0 for @rspack/cli, @rspack/core, @rspack/plugin-react-refresh. Added @rspack/dev-server@2.0.0 — it's no longer bundled with @rspack/cli in v2.
  • @rsdoctor/rspack-plugin bumped ^0.4.13 → ^1.5.9 in both packages for v2 compat.
  • packages/clerk-js/rspack.config.js.mjs with a CJS→ESM conversion. Rspack 2 core is pure ESM, and mixing require('@rspack/core') with the v2 shape is the exact pattern most likely to misbehave.
  • output.libraryTarget: 'x'output.library: { type: 'x' } across both configs (8 call sites) — the v1 shorthand is removed in v2.
  • experiments.cache → top-level cache — the option graduated out of experiments in v2.
  • Dropped the --analyze CLI flag from the build:analyze scripts — removed in v2. Rsdoctor remains the analysis path.

What I deliberately didn't touch

  • scripts/rspack-common.js stays CJS. Node's CJS→ESM named-export interop handles it from both configs fine.
  • webpackChunkName magic comments are still supported in v2 — no changes to the ~50 call sites in packages/ui/src/** and packages/clerk-js/src/core/auth/cookieSuffix.ts.
  • Integration templates under integration/templates/** keep their own engines.node pins — they aren't in the pnpm workspace.

Known WIP items before this can merge

  • Temporary minimumReleaseAgeExclude: ['@rspack/*'] entry in pnpm-workspace.yaml — Rspack 2.0.0 was published 16h before this PR and the repo requires 48h. Either wait out the window and drop the exclusion, or keep a justified exclusion.
  • Sandbox dev smoke test not yet run. The recent fix(clerk-js,ui): Pin rspack to 1.7.x and disable lazy compilation #8378 regression was specifically in sandbox dev mode, so pnpm --filter @clerk/clerk-js dev:sandbox:serve needs to be validated before landing.
  • Rsdoctor analyzer smoke test — the 0.4 → 1.5 bump is a major version on its own; build:rsdoctor should be exercised.
  • Bundle size comparison via bundlewatch — the Rspack runtime change may move the numbers.
  • Unit + integration tests haven't been run against the upgraded bundles.

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation

Bumps the Rspack catalog to 2.0.0 and applies the migration:
- Node minimum bumped to 22.12.0 (Rspack 2 requirement)
- Convert clerk-js rspack.config.js to .mjs (Rspack 2 core is pure ESM)
- Rename output.libraryTarget to output.library.type (8 sites)
- Move experiments.cache to top-level cache
- Drop --analyze CLI flag (removed in v2; Rsdoctor remains for analysis)
- Bump @rsdoctor/rspack-plugin to 1.5.x
- Add @rspack/dev-server as a direct dep (no longer bundled with @rspack/cli)

Both packages build green across all variants.
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 22, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Apr 22, 2026 9:55pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 22, 2026

🦋 Changeset detected

Latest commit: 2188490

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

This PR includes changesets to release 4 packages
Name Type
@clerk/clerk-js Patch
@clerk/ui Patch
@clerk/chrome-extension Patch
@clerk/expo 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

@jacekradko jacekradko marked this pull request as ready for review April 22, 2026 21:50
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 22, 2026

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8382

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8382

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8382

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8382

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8382

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8382

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8382

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8382

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8382

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8382

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8382

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8382

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8382

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8382

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8382

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8382

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8382

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8382

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8382

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8382

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8382

commit: 2188490

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

📝 Walkthrough

Walkthrough

This pull request upgrades the project to Rspack 2 and updates the minimum Node.js version to 22.12.0. It includes updating Node version requirements in .nvmrc and package.json, creating a changeset documenting the upgrade, migrating the clerk-js Rspack configuration from CommonJS to ES modules, updating build scripts and dependencies in both clerk-js and ui packages, updating the turbo.json configuration to reference the new .mjs config file, and upgrading Rspack-related dependencies in pnpm-workspace.yaml to version 2.0.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore(clerk-js,ui): upgrade to Rspack 2' accurately and concisely summarizes the primary change—upgrading the Rspack dependency to version 2 across the listed packages.
Description check ✅ Passed The description is highly detailed and directly related to the changeset, explaining the upgrade rationale, all modifications made, deliberately unchanged items, and known WIP items pending before merge.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/clerk-js/rspack.config.mjs (1)

2-518: ⚠️ Potential issue | 🟠 Major

Merge blocker: no test coverage/verification for a build-system migration

This PR changes core bundling behavior (Rspack major version, config format, output library config, cache semantics) but includes no added/updated tests or automated verification in the change set. Please add and run migration-focused build/test coverage (at least smoke coverage across the declared variants) before merge.

As per coding guidelines, "If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/clerk-js/rspack.config.mjs` around lines 2 - 518, The PR introduces
a major rspack-based bundling change but lacks migration/verification tests; add
automated smoke tests that build and validate each declared variant (use
variants object keys and entryForVariant, prodConfig and devConfig outputs) to
CI: create test scripts that invoke the rspack build for clerkBrowser,
clerkLegacyBrowser, clerkNative, clerk (ESM/CJS) and clerkNoRHC variants, assert
successful exit and presence of expected output files (check
output.filename/library type for commonjs/module/umd and chunking behavior), and
add these tests to the repository CI pipeline so they run on PRs before merge.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/rspack-2-upgrade.md:
- Line 6: Add a CI-backed smoke test that verifies the Rspack 2 build/runtime
produces working bundles for the changed packages (`@clerk/clerk-js` and
`@clerk/ui`): create a new lightweight workflow or job (e.g.,
.github/workflows/smoke-rspack2.yml) that installs Node 22.12.0, runs the repo
build (npm/yarn build), runs a small script or test (e.g., a new script
"smoke:rspack2" in package.json) that imports the built bundles and asserts
basic runtime behavior (bundle loads without runtime errors and exports expected
symbols), and fail the job on any error; ensure the workflow runs on PRs and
include the new smoke script and any minimal test file under test/smoke or
tests/smoke so the CI actually exercises the new Rspack 2 output before merging.

In `@pnpm-workspace.yaml`:
- Around line 50-51: The exception currently whitelists the entire scope token
'@rspack/*', which is too broad; replace that entry with explicit
package+version pins for only the four newly added 2.0.0 packages (e.g.,
'@rspack/package-name@2.0.0') so only those exact artifacts bypass the 48h gate,
and keep the existing TODO comment about removing the pins once 2.0.0 is older
than 48h.

---

Outside diff comments:
In `@packages/clerk-js/rspack.config.mjs`:
- Around line 2-518: The PR introduces a major rspack-based bundling change but
lacks migration/verification tests; add automated smoke tests that build and
validate each declared variant (use variants object keys and entryForVariant,
prodConfig and devConfig outputs) to CI: create test scripts that invoke the
rspack build for clerkBrowser, clerkLegacyBrowser, clerkNative, clerk (ESM/CJS)
and clerkNoRHC variants, assert successful exit and presence of expected output
files (check output.filename/library type for commonjs/module/umd and chunking
behavior), and add these tests to the repository CI pipeline so they run on PRs
before merge.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 28eb5570-4ee1-4362-ae85-fc2dc0f1f50b

📥 Commits

Reviewing files that changed from the base of the PR and between 8a25c6a and 0b488fe.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • .changeset/rspack-2-upgrade.md
  • .nvmrc
  • package.json
  • packages/clerk-js/package.json
  • packages/clerk-js/rspack.config.mjs
  • packages/clerk-js/turbo.json
  • packages/ui/package.json
  • packages/ui/rspack.config.js
  • pnpm-workspace.yaml

'@clerk/ui': patch
---

Upgrade build tooling to Rspack 2. No user-facing API changes; the compiled bundle output is produced by Rspack 2's runtime. Also bumps the repo's minimum Node to 22.12.0 (Rspack 2 requirement).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add smoke coverage for the Rspack 2 migration before merge.

This PR changes the toolchain/runtime that emits published @clerk/clerk-js and @clerk/ui bundles, but no tests were added or updated in the diff. Please land at least one CI-backed smoke path for the upgraded build/dev/analyzer flow before merging.

As per coding guidelines, "If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/rspack-2-upgrade.md at line 6, Add a CI-backed smoke test that
verifies the Rspack 2 build/runtime produces working bundles for the changed
packages (`@clerk/clerk-js` and `@clerk/ui`): create a new lightweight workflow or
job (e.g., .github/workflows/smoke-rspack2.yml) that installs Node 22.12.0, runs
the repo build (npm/yarn build), runs a small script or test (e.g., a new script
"smoke:rspack2" in package.json) that imports the built bundles and asserts
basic runtime behavior (bundle loads without runtime errors and exports expected
symbols), and fail the job on any error; ensure the workflow runs on PRs and
include the new smoke script and any minimal test file under test/smoke or
tests/smoke so the CI actually exercises the new Rspack 2 output before merging.

Comment thread pnpm-workspace.yaml
Comment on lines +50 to +51
# TODO: remove once rspack 2.0.0 is >48h old (published 2026-04-22)
- '@rspack/*'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Don't exempt the entire @rspack/* scope from the 48h quarantine.

This bypass is broader than the four 2.0.0 packages introduced here. If the TODO is missed, any freshly published @rspack/* package will skip the release-age gate as well.

Narrow the exception to the exact versions in this PR
-  # TODO: remove once rspack 2.0.0 is >48h old (published 2026-04-22)
-  - '@rspack/*'
+  # TODO: remove once rspack 2.0.0 is >48h old (published 2026-04-22)
+  - '@rspack/cli@2.0.0'
+  - '@rspack/core@2.0.0'
+  - '@rspack/dev-server@2.0.0'
+  - '@rspack/plugin-react-refresh@2.0.0'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# TODO: remove once rspack 2.0.0 is >48h old (published 2026-04-22)
- '@rspack/*'
# TODO: remove once rspack 2.0.0 is >48h old (published 2026-04-22)
- '@rspack/cli@2.0.0'
- '@rspack/core@2.0.0'
- '@rspack/dev-server@2.0.0'
- '@rspack/plugin-react-refresh@2.0.0'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pnpm-workspace.yaml` around lines 50 - 51, The exception currently whitelists
the entire scope token '@rspack/*', which is too broad; replace that entry with
explicit package+version pins for only the four newly added 2.0.0 packages
(e.g., '@rspack/package-name@2.0.0') so only those exact artifacts bypass the
48h gate, and keep the existing TODO comment about removing the pins once 2.0.0
is older than 48h.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant