Skip to content

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

Merged
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2
Jun 12, 2026
Merged

chore(clerk-js,ui): upgrade to Rspack 2#8382
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2

Conversation

@jacekradko

@jacekradkojacekradko commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Upgrades @clerk/clerk-js and @clerk/ui bundling from Rspack 1.7.x to Rspack 2 (2.0.6). Every variant builds (7 for clerk-js, 3 for ui), and the unit + integration matrix and bundlewatch are all green. Node minimum moves to 22.12.0, a Rspack 2 requirement.

The part worth real scrutiny is the config migration in packages/clerk-js/rspack.config.mjs and packages/ui/rspack.config.js: the config moves to ESM (Rspack 2 core is pure ESM), output.libraryTarget: 'x' is rewritten to output.library: { type: 'x' } across both configs, and experiments.cache graduates to a top-level cache. Since clerk-js/ui load into apps pinned on older SDK versions, the thing to confirm is that the per-variant bundle shape (library type, chunking) is unchanged.

Two small riders come along: bundlewatch budgets nudged up for Rspack 2's marginally larger gzip (clerk.browser.js 70→72KB, base-account-sdk 203→205KB, otherwise within ~0.1KB), and two @clerk/shared typecheck fixes, dropping the now-built-in NoInfer import from @tanstack/query-core and guarding script.nonce in loadScript.ts (matching #8177).

Holding the merge while the TS 6.0 work (#8177) settles, since the two overlap in the bundlewatch config and @clerk/ui's build.

Summary by CodeRabbit

  • Chores
    • Upgraded build infrastructure to Rspack 2 with optimized bundle handling
    • Updated minimum Node.js version requirement to 22.12.0
    • Adjusted bundle size to 72KB

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

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentJun 12, 2026 12:05pm
swingsetReadyReadyPreview, CommentJun 12, 2026 12:05pm

Request Review

@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c31eb18

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

This PR includes changesets to release 5 packages
NameType
@clerk/clerk-jsPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/swingsetPatch

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

pkg-pr-newBot commented Apr 22, 2026

Copy link
Copy Markdown

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/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: c31eb18

@coderabbitai

coderabbitaiBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR upgrades Rspack to version 2 across the workspace and migrates the clerk-js build configuration from CommonJS to ESM. The core change replaces deprecated libraryTarget API with the modern library.type format, consolidates cache configuration, and updates all related npm scripts and workspace dependencies.

Changes

Rspack 2.0 Upgrade and Configuration Updates

Layer / File(s)Summary
ESM imports, module interop, and config export
packages/clerk-js/rspack.config.mjs
Replace CommonJS requires with ESM imports, add createRequire and __dirname compatibility shims from import.meta.url, import package.json as JSON module, and switch config export from module.exports to export default.
Output library API migration
packages/clerk-js/rspack.config.mjs
Replace deprecated output.libraryTarget with output.library: { type: ... } across all bundle variants (UMD production, ESM/CJS variants, and dev builds).
Development cache consolidation
packages/clerk-js/rspack.config.mjs
Simplify dev caching by removing cache: true plus experiments.cache.type and replacing with cache: { type: 'memory' }.
Package scripts and devDependencies
packages/clerk-js/package.json
Update clerk-js npm scripts to reference rspack.config.mjs, remove --analyze CLI flag from build:analyze, upgrade @rsdoctor/rspack-plugin to ^1.5.9, and add @rspack/dev-server.
Workspace catalogs, bundle threshold, and type imports
pnpm-workspace.yaml, packages/clerk-js/bundlewatch.config.json, packages/shared/src/react/query/useQuery.ts
Update pnpm rspack catalog versions to 2.0.x range, extend trustPolicyExclude with tinyclip, increase clerk-js bundlewatch maxSize threshold, and remove NoInfer from @tanstack/query-core import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • dstaley
  • wobsoriano

Poem

🐰 With Rspack 2.0 and files in ESM flow,
The bundle output now gleams in runtime glow,
Libraries restructured from target to type so clean,
Cache consolidated—the smoothest build scene!
TypeScript imports refined, thresholds adjusted right,
Modernization complete, the config shines bright! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'chore(clerk-js,ui): upgrade to Rspack 2' accurately and specifically summarizes the main change—upgrading Rspack to version 2 for the clerk-js and ui packages.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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.

@coderabbitaicoderabbitaiBot left a comment

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.

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

Comment thread.changeset/rspack-2-upgrade.md Outdated
Comment threadpnpm-workspace.yaml Outdated
@github-actions

github-actionsBot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Break Check: no API changes detected across the tracked packages.

Last ran on 94cc5fb. Pushes that change no tracked declarations (no API surface change vs. base) are skipped and don't update this comment.

Drop the NoInfer import from @tanstack/query-core (removed in 5.100.14;
TS provides NoInfer as a built-in) and guard the script.nonce assignment
for stricter typecheck, matching #8177. Bump clerk.browser.js and
base-account-sdk bundlewatch budgets for rspack 2's slightly larger gzip output.

@coderabbitaicoderabbitaiBot left a comment

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.

🧹 Nitpick comments (1)
packages/shared/src/react/query/useQuery.ts (1)

36-41: ⚡ Quick win

Add JSDoc documentation for the public API function.

The useClerkQuery function is exported and part of the public API, but currently has an empty JSDoc comment. As per coding guidelines, public APIs should be documented with @param, @returns, and @example tags.

📝 Suggested JSDoc documentation
 /**
- *+ * Hook to execute a Clerk-specific query using TanStack Query patterns.+ *+ * `@param` options - Query configuration options including queryKey, queryFn, and other TanStack Query options+ * `@returns` Query result with data, error, loading, and fetching states+ *+ * `@example`+ * ```tsx+ * const { data, error, isLoading } = useClerkQuery({+ * queryKey: ['user', userId],+ * queryFn: () => fetchUserData(userId),+ * enabled: !!userId,+ * });+ * ```
*/
export function useClerkQuery(options: UseQueryOptions) {
return useBaseQuery(options, QueryObserver);
}

As per coding guidelines: "All public APIs must be documented with JSDoc".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/shared/src/react/query/useQuery.ts` around lines 36 - 41, Add a
proper JSDoc block above the exported function useClerkQuery describing its
purpose, a `@param` for the options parameter (type UseQueryOptions), a `@returns`
describing the query result shape, and an `@example` showing typical usage (e.g.,
queryKey, queryFn, enabled). Reference the implementation details by mentioning
useBaseQuery and QueryObserver so the docs note that useClerkQuery delegates to
useBaseQuery(options, QueryObserver). Keep the comment concise and follow
existing project JSDoc style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/shared/src/react/query/useQuery.ts`:
- Around line 36-41: Add a proper JSDoc block above the exported function
useClerkQuery describing its purpose, a `@param` for the options parameter (type
UseQueryOptions), a `@returns` describing the query result shape, and an `@example`
showing typical usage (e.g., queryKey, queryFn, enabled). Reference the
implementation details by mentioning useBaseQuery and QueryObserver so the docs
note that useClerkQuery delegates to useBaseQuery(options, QueryObserver). Keep
the comment concise and follow existing project JSDoc style.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: eed67afe-f65b-45d3-b58c-ec5a0a59ad5e

📥 Commits

Reviewing files that changed from the base of the PR and between 8fd4764 and 71991d7.

📒 Files selected for processing (3)
  • packages/clerk-js/bundlewatch.config.json
  • packages/shared/src/loadScript.ts
  • packages/shared/src/react/query/useQuery.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

Bump @rspack/core and @rspack/cli to 2.0.6, @rspack/dev-server to 2.0.3,
and @rspack/plugin-react-refresh to 2.0.1 (each package's latest in the
2.0.x line). All four are now >48h old, so drop the temporary @rspack/*
entry from minimumReleaseAgeExclude, restoring the release-age quarantine.
# Conflicts:
#	packages/clerk-js/bundlewatch.config.json
#	pnpm-lock.yaml

@coderabbitaicoderabbitaiBot left a comment

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.

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/package.json (1)

120-122: ⚠️ Potential issue | 🟠 Major

Fix engines.node to match Rspack 2’s required minimum.

packages/clerk-js/package.json sets engines.node to >=20.9.0, but Rspack 2 requires Node minimum 20.19.0 (or 22.12.0). Update the engines.node range to match (either >=20.19.0 or your chosen >=22.12.0 standard).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/clerk-js/package.json` around lines 120 - 122, Update the
package.json engines.node field to meet Rspack 2’s minimum: change the
"engines.node" value from ">=20.9.0" to either ">=20.19.0" (or your chosen
stricter baseline like ">=22.12.0") so the project declares a compatible Node.js
range; locate and edit the "engines.node" entry in the package.json manifest
(key: engines.node) and commit the updated range.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/clerk-js/package.json`:
- Around line 120-122: Update the package.json engines.node field to meet Rspack
2’s minimum: change the "engines.node" value from ">=20.9.0" to either
">=20.19.0" (or your chosen stricter baseline like ">=22.12.0") so the project
declares a compatible Node.js range; locate and edit the "engines.node" entry in
the package.json manifest (key: engines.node) and commit the updated range.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: dd59d800-11e7-4b80-9ac8-656f48f8b059

📥 Commits

Reviewing files that changed from the base of the PR and between e1714aa and 61d422e.

📒 Files selected for processing (2)
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/package.json
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

@github-actions

github-actionsBot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-06-12T12:06:36.032Z

Summary

MetricCount
Packages analyzed19
Packages with changes0
🔴 Breaking changes0
🟡 Non-breaking changes0
🟢 Additions0

Note
Break Check could not snapshot 1 subpath; the diff below excludes them.

  • @clerk/astro ./env: Internal Error: Unable to determine module for: /home/runner/_work/javascript/javascript/packages/astro/env.d.ts You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on c31eb18.

@dstaleydstaley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm :shipit:

Comment thread.changeset/rspack-2-upgrade.md Outdated
Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jacekradko@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
chore(clerk-js,ui): upgrade to Rspack 2 by jacekradko · Pull Request #8382 · clerk/javascript · GitHub
Skip to content

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

Merged
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2
Jun 12, 2026
Merged

chore(clerk-js,ui): upgrade to Rspack 2#8382
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2

Conversation

@jacekradko

@jacekradkojacekradko commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Upgrades @clerk/clerk-js and @clerk/ui bundling from Rspack 1.7.x to Rspack 2 (2.0.6). Every variant builds (7 for clerk-js, 3 for ui), and the unit + integration matrix and bundlewatch are all green. Node minimum moves to 22.12.0, a Rspack 2 requirement.

The part worth real scrutiny is the config migration in packages/clerk-js/rspack.config.mjs and packages/ui/rspack.config.js: the config moves to ESM (Rspack 2 core is pure ESM), output.libraryTarget: 'x' is rewritten to output.library: { type: 'x' } across both configs, and experiments.cache graduates to a top-level cache. Since clerk-js/ui load into apps pinned on older SDK versions, the thing to confirm is that the per-variant bundle shape (library type, chunking) is unchanged.

Two small riders come along: bundlewatch budgets nudged up for Rspack 2's marginally larger gzip (clerk.browser.js 70→72KB, base-account-sdk 203→205KB, otherwise within ~0.1KB), and two @clerk/shared typecheck fixes, dropping the now-built-in NoInfer import from @tanstack/query-core and guarding script.nonce in loadScript.ts (matching #8177).

Holding the merge while the TS 6.0 work (#8177) settles, since the two overlap in the bundlewatch config and @clerk/ui's build.

Summary by CodeRabbit

  • Chores
    • Upgraded build infrastructure to Rspack 2 with optimized bundle handling
    • Updated minimum Node.js version requirement to 22.12.0
    • Adjusted bundle size to 72KB

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

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentJun 12, 2026 12:05pm
swingsetReadyReadyPreview, CommentJun 12, 2026 12:05pm

Request Review

@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c31eb18

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

This PR includes changesets to release 5 packages
NameType
@clerk/clerk-jsPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/swingsetPatch

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

pkg-pr-newBot commented Apr 22, 2026

Copy link
Copy Markdown

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/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: c31eb18

@coderabbitai

coderabbitaiBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR upgrades Rspack to version 2 across the workspace and migrates the clerk-js build configuration from CommonJS to ESM. The core change replaces deprecated libraryTarget API with the modern library.type format, consolidates cache configuration, and updates all related npm scripts and workspace dependencies.

Changes

Rspack 2.0 Upgrade and Configuration Updates

Layer / File(s)Summary
ESM imports, module interop, and config export
packages/clerk-js/rspack.config.mjs
Replace CommonJS requires with ESM imports, add createRequire and __dirname compatibility shims from import.meta.url, import package.json as JSON module, and switch config export from module.exports to export default.
Output library API migration
packages/clerk-js/rspack.config.mjs
Replace deprecated output.libraryTarget with output.library: { type: ... } across all bundle variants (UMD production, ESM/CJS variants, and dev builds).
Development cache consolidation
packages/clerk-js/rspack.config.mjs
Simplify dev caching by removing cache: true plus experiments.cache.type and replacing with cache: { type: 'memory' }.
Package scripts and devDependencies
packages/clerk-js/package.json
Update clerk-js npm scripts to reference rspack.config.mjs, remove --analyze CLI flag from build:analyze, upgrade @rsdoctor/rspack-plugin to ^1.5.9, and add @rspack/dev-server.
Workspace catalogs, bundle threshold, and type imports
pnpm-workspace.yaml, packages/clerk-js/bundlewatch.config.json, packages/shared/src/react/query/useQuery.ts
Update pnpm rspack catalog versions to 2.0.x range, extend trustPolicyExclude with tinyclip, increase clerk-js bundlewatch maxSize threshold, and remove NoInfer from @tanstack/query-core import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • dstaley
  • wobsoriano

Poem

🐰 With Rspack 2.0 and files in ESM flow,
The bundle output now gleams in runtime glow,
Libraries restructured from target to type so clean,
Cache consolidated—the smoothest build scene!
TypeScript imports refined, thresholds adjusted right,
Modernization complete, the config shines bright! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'chore(clerk-js,ui): upgrade to Rspack 2' accurately and specifically summarizes the main change—upgrading Rspack to version 2 for the clerk-js and ui packages.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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.

@coderabbitaicoderabbitaiBot left a comment

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.

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

Comment thread.changeset/rspack-2-upgrade.md Outdated
Comment threadpnpm-workspace.yaml Outdated
@github-actions

github-actionsBot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Break Check: no API changes detected across the tracked packages.

Last ran on 94cc5fb. Pushes that change no tracked declarations (no API surface change vs. base) are skipped and don't update this comment.

Drop the NoInfer import from @tanstack/query-core (removed in 5.100.14;
TS provides NoInfer as a built-in) and guard the script.nonce assignment
for stricter typecheck, matching #8177. Bump clerk.browser.js and
base-account-sdk bundlewatch budgets for rspack 2's slightly larger gzip output.

@coderabbitaicoderabbitaiBot left a comment

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.

🧹 Nitpick comments (1)
packages/shared/src/react/query/useQuery.ts (1)

36-41: ⚡ Quick win

Add JSDoc documentation for the public API function.

The useClerkQuery function is exported and part of the public API, but currently has an empty JSDoc comment. As per coding guidelines, public APIs should be documented with @param, @returns, and @example tags.

📝 Suggested JSDoc documentation
 /**
- *+ * Hook to execute a Clerk-specific query using TanStack Query patterns.+ *+ * `@param` options - Query configuration options including queryKey, queryFn, and other TanStack Query options+ * `@returns` Query result with data, error, loading, and fetching states+ *+ * `@example`+ * ```tsx+ * const { data, error, isLoading } = useClerkQuery({+ * queryKey: ['user', userId],+ * queryFn: () => fetchUserData(userId),+ * enabled: !!userId,+ * });+ * ```
*/
export function useClerkQuery(options: UseQueryOptions) {
return useBaseQuery(options, QueryObserver);
}

As per coding guidelines: "All public APIs must be documented with JSDoc".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/shared/src/react/query/useQuery.ts` around lines 36 - 41, Add a
proper JSDoc block above the exported function useClerkQuery describing its
purpose, a `@param` for the options parameter (type UseQueryOptions), a `@returns`
describing the query result shape, and an `@example` showing typical usage (e.g.,
queryKey, queryFn, enabled). Reference the implementation details by mentioning
useBaseQuery and QueryObserver so the docs note that useClerkQuery delegates to
useBaseQuery(options, QueryObserver). Keep the comment concise and follow
existing project JSDoc style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/shared/src/react/query/useQuery.ts`:
- Around line 36-41: Add a proper JSDoc block above the exported function
useClerkQuery describing its purpose, a `@param` for the options parameter (type
UseQueryOptions), a `@returns` describing the query result shape, and an `@example`
showing typical usage (e.g., queryKey, queryFn, enabled). Reference the
implementation details by mentioning useBaseQuery and QueryObserver so the docs
note that useClerkQuery delegates to useBaseQuery(options, QueryObserver). Keep
the comment concise and follow existing project JSDoc style.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: eed67afe-f65b-45d3-b58c-ec5a0a59ad5e

📥 Commits

Reviewing files that changed from the base of the PR and between 8fd4764 and 71991d7.

📒 Files selected for processing (3)
  • packages/clerk-js/bundlewatch.config.json
  • packages/shared/src/loadScript.ts
  • packages/shared/src/react/query/useQuery.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

Bump @rspack/core and @rspack/cli to 2.0.6, @rspack/dev-server to 2.0.3,
and @rspack/plugin-react-refresh to 2.0.1 (each package's latest in the
2.0.x line). All four are now >48h old, so drop the temporary @rspack/*
entry from minimumReleaseAgeExclude, restoring the release-age quarantine.
# Conflicts:
#	packages/clerk-js/bundlewatch.config.json
#	pnpm-lock.yaml

@coderabbitaicoderabbitaiBot left a comment

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.

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/package.json (1)

120-122: ⚠️ Potential issue | 🟠 Major

Fix engines.node to match Rspack 2’s required minimum.

packages/clerk-js/package.json sets engines.node to >=20.9.0, but Rspack 2 requires Node minimum 20.19.0 (or 22.12.0). Update the engines.node range to match (either >=20.19.0 or your chosen >=22.12.0 standard).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/clerk-js/package.json` around lines 120 - 122, Update the
package.json engines.node field to meet Rspack 2’s minimum: change the
"engines.node" value from ">=20.9.0" to either ">=20.19.0" (or your chosen
stricter baseline like ">=22.12.0") so the project declares a compatible Node.js
range; locate and edit the "engines.node" entry in the package.json manifest
(key: engines.node) and commit the updated range.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/clerk-js/package.json`:
- Around line 120-122: Update the package.json engines.node field to meet Rspack
2’s minimum: change the "engines.node" value from ">=20.9.0" to either
">=20.19.0" (or your chosen stricter baseline like ">=22.12.0") so the project
declares a compatible Node.js range; locate and edit the "engines.node" entry in
the package.json manifest (key: engines.node) and commit the updated range.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: dd59d800-11e7-4b80-9ac8-656f48f8b059

📥 Commits

Reviewing files that changed from the base of the PR and between e1714aa and 61d422e.

📒 Files selected for processing (2)
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/package.json
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

@github-actions

github-actionsBot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-06-12T12:06:36.032Z

Summary

MetricCount
Packages analyzed19
Packages with changes0
🔴 Breaking changes0
🟡 Non-breaking changes0
🟢 Additions0

Note
Break Check could not snapshot 1 subpath; the diff below excludes them.

  • @clerk/astro ./env: Internal Error: Unable to determine module for: /home/runner/_work/javascript/javascript/packages/astro/env.d.ts You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on c31eb18.

@dstaleydstaley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm :shipit:

Comment thread.changeset/rspack-2-upgrade.md Outdated
Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jacekradko@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(clerk-js,ui): upgrade to Rspack 2 by jacekradko · Pull Request #8382 · clerk/javascript · GitHub
Skip to content

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

Merged
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2
Jun 12, 2026
Merged

chore(clerk-js,ui): upgrade to Rspack 2#8382
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2

Conversation

@jacekradko

@jacekradkojacekradko commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Upgrades @clerk/clerk-js and @clerk/ui bundling from Rspack 1.7.x to Rspack 2 (2.0.6). Every variant builds (7 for clerk-js, 3 for ui), and the unit + integration matrix and bundlewatch are all green. Node minimum moves to 22.12.0, a Rspack 2 requirement.

The part worth real scrutiny is the config migration in packages/clerk-js/rspack.config.mjs and packages/ui/rspack.config.js: the config moves to ESM (Rspack 2 core is pure ESM), output.libraryTarget: 'x' is rewritten to output.library: { type: 'x' } across both configs, and experiments.cache graduates to a top-level cache. Since clerk-js/ui load into apps pinned on older SDK versions, the thing to confirm is that the per-variant bundle shape (library type, chunking) is unchanged.

Two small riders come along: bundlewatch budgets nudged up for Rspack 2's marginally larger gzip (clerk.browser.js 70→72KB, base-account-sdk 203→205KB, otherwise within ~0.1KB), and two @clerk/shared typecheck fixes, dropping the now-built-in NoInfer import from @tanstack/query-core and guarding script.nonce in loadScript.ts (matching #8177).

Holding the merge while the TS 6.0 work (#8177) settles, since the two overlap in the bundlewatch config and @clerk/ui's build.

Summary by CodeRabbit

  • Chores
    • Upgraded build infrastructure to Rspack 2 with optimized bundle handling
    • Updated minimum Node.js version requirement to 22.12.0
    • Adjusted bundle size to 72KB

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

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentJun 12, 2026 12:05pm
swingsetReadyReadyPreview, CommentJun 12, 2026 12:05pm

Request Review

@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c31eb18

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

This PR includes changesets to release 5 packages
NameType
@clerk/clerk-jsPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/swingsetPatch

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

pkg-pr-newBot commented Apr 22, 2026

Copy link
Copy Markdown

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/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: c31eb18

@coderabbitai

coderabbitaiBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR upgrades Rspack to version 2 across the workspace and migrates the clerk-js build configuration from CommonJS to ESM. The core change replaces deprecated libraryTarget API with the modern library.type format, consolidates cache configuration, and updates all related npm scripts and workspace dependencies.

Changes

Rspack 2.0 Upgrade and Configuration Updates

Layer / File(s)Summary
ESM imports, module interop, and config export
packages/clerk-js/rspack.config.mjs
Replace CommonJS requires with ESM imports, add createRequire and __dirname compatibility shims from import.meta.url, import package.json as JSON module, and switch config export from module.exports to export default.
Output library API migration
packages/clerk-js/rspack.config.mjs
Replace deprecated output.libraryTarget with output.library: { type: ... } across all bundle variants (UMD production, ESM/CJS variants, and dev builds).
Development cache consolidation
packages/clerk-js/rspack.config.mjs
Simplify dev caching by removing cache: true plus experiments.cache.type and replacing with cache: { type: 'memory' }.
Package scripts and devDependencies
packages/clerk-js/package.json
Update clerk-js npm scripts to reference rspack.config.mjs, remove --analyze CLI flag from build:analyze, upgrade @rsdoctor/rspack-plugin to ^1.5.9, and add @rspack/dev-server.
Workspace catalogs, bundle threshold, and type imports
pnpm-workspace.yaml, packages/clerk-js/bundlewatch.config.json, packages/shared/src/react/query/useQuery.ts
Update pnpm rspack catalog versions to 2.0.x range, extend trustPolicyExclude with tinyclip, increase clerk-js bundlewatch maxSize threshold, and remove NoInfer from @tanstack/query-core import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • dstaley
  • wobsoriano

Poem

🐰 With Rspack 2.0 and files in ESM flow,
The bundle output now gleams in runtime glow,
Libraries restructured from target to type so clean,
Cache consolidated—the smoothest build scene!
TypeScript imports refined, thresholds adjusted right,
Modernization complete, the config shines bright! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'chore(clerk-js,ui): upgrade to Rspack 2' accurately and specifically summarizes the main change—upgrading Rspack to version 2 for the clerk-js and ui packages.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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.

@coderabbitaicoderabbitaiBot left a comment

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.

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

Comment thread.changeset/rspack-2-upgrade.md Outdated
Comment threadpnpm-workspace.yaml Outdated
@github-actions

github-actionsBot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Break Check: no API changes detected across the tracked packages.

Last ran on 94cc5fb. Pushes that change no tracked declarations (no API surface change vs. base) are skipped and don't update this comment.

Drop the NoInfer import from @tanstack/query-core (removed in 5.100.14;
TS provides NoInfer as a built-in) and guard the script.nonce assignment
for stricter typecheck, matching #8177. Bump clerk.browser.js and
base-account-sdk bundlewatch budgets for rspack 2's slightly larger gzip output.

@coderabbitaicoderabbitaiBot left a comment

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.

🧹 Nitpick comments (1)
packages/shared/src/react/query/useQuery.ts (1)

36-41: ⚡ Quick win

Add JSDoc documentation for the public API function.

The useClerkQuery function is exported and part of the public API, but currently has an empty JSDoc comment. As per coding guidelines, public APIs should be documented with @param, @returns, and @example tags.

📝 Suggested JSDoc documentation
 /**
- *+ * Hook to execute a Clerk-specific query using TanStack Query patterns.+ *+ * `@param` options - Query configuration options including queryKey, queryFn, and other TanStack Query options+ * `@returns` Query result with data, error, loading, and fetching states+ *+ * `@example`+ * ```tsx+ * const { data, error, isLoading } = useClerkQuery({+ * queryKey: ['user', userId],+ * queryFn: () => fetchUserData(userId),+ * enabled: !!userId,+ * });+ * ```
*/
export function useClerkQuery(options: UseQueryOptions) {
return useBaseQuery(options, QueryObserver);
}

As per coding guidelines: "All public APIs must be documented with JSDoc".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/shared/src/react/query/useQuery.ts` around lines 36 - 41, Add a
proper JSDoc block above the exported function useClerkQuery describing its
purpose, a `@param` for the options parameter (type UseQueryOptions), a `@returns`
describing the query result shape, and an `@example` showing typical usage (e.g.,
queryKey, queryFn, enabled). Reference the implementation details by mentioning
useBaseQuery and QueryObserver so the docs note that useClerkQuery delegates to
useBaseQuery(options, QueryObserver). Keep the comment concise and follow
existing project JSDoc style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/shared/src/react/query/useQuery.ts`:
- Around line 36-41: Add a proper JSDoc block above the exported function
useClerkQuery describing its purpose, a `@param` for the options parameter (type
UseQueryOptions), a `@returns` describing the query result shape, and an `@example`
showing typical usage (e.g., queryKey, queryFn, enabled). Reference the
implementation details by mentioning useBaseQuery and QueryObserver so the docs
note that useClerkQuery delegates to useBaseQuery(options, QueryObserver). Keep
the comment concise and follow existing project JSDoc style.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: eed67afe-f65b-45d3-b58c-ec5a0a59ad5e

📥 Commits

Reviewing files that changed from the base of the PR and between 8fd4764 and 71991d7.

📒 Files selected for processing (3)
  • packages/clerk-js/bundlewatch.config.json
  • packages/shared/src/loadScript.ts
  • packages/shared/src/react/query/useQuery.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

Bump @rspack/core and @rspack/cli to 2.0.6, @rspack/dev-server to 2.0.3,
and @rspack/plugin-react-refresh to 2.0.1 (each package's latest in the
2.0.x line). All four are now >48h old, so drop the temporary @rspack/*
entry from minimumReleaseAgeExclude, restoring the release-age quarantine.
# Conflicts:
#	packages/clerk-js/bundlewatch.config.json
#	pnpm-lock.yaml

@coderabbitaicoderabbitaiBot left a comment

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.

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/package.json (1)

120-122: ⚠️ Potential issue | 🟠 Major

Fix engines.node to match Rspack 2’s required minimum.

packages/clerk-js/package.json sets engines.node to >=20.9.0, but Rspack 2 requires Node minimum 20.19.0 (or 22.12.0). Update the engines.node range to match (either >=20.19.0 or your chosen >=22.12.0 standard).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/clerk-js/package.json` around lines 120 - 122, Update the
package.json engines.node field to meet Rspack 2’s minimum: change the
"engines.node" value from ">=20.9.0" to either ">=20.19.0" (or your chosen
stricter baseline like ">=22.12.0") so the project declares a compatible Node.js
range; locate and edit the "engines.node" entry in the package.json manifest
(key: engines.node) and commit the updated range.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/clerk-js/package.json`:
- Around line 120-122: Update the package.json engines.node field to meet Rspack
2’s minimum: change the "engines.node" value from ">=20.9.0" to either
">=20.19.0" (or your chosen stricter baseline like ">=22.12.0") so the project
declares a compatible Node.js range; locate and edit the "engines.node" entry in
the package.json manifest (key: engines.node) and commit the updated range.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: dd59d800-11e7-4b80-9ac8-656f48f8b059

📥 Commits

Reviewing files that changed from the base of the PR and between e1714aa and 61d422e.

📒 Files selected for processing (2)
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/package.json
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

@github-actions

github-actionsBot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-06-12T12:06:36.032Z

Summary

MetricCount
Packages analyzed19
Packages with changes0
🔴 Breaking changes0
🟡 Non-breaking changes0
🟢 Additions0

Note
Break Check could not snapshot 1 subpath; the diff below excludes them.

  • @clerk/astro ./env: Internal Error: Unable to determine module for: /home/runner/_work/javascript/javascript/packages/astro/env.d.ts You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on c31eb18.

@dstaleydstaley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm :shipit:

Comment thread.changeset/rspack-2-upgrade.md Outdated
Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jacekradko@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(clerk-js,ui): upgrade to Rspack 2 by jacekradko · Pull Request #8382 · clerk/javascript · GitHub
Skip to content

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

Merged
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2
Jun 12, 2026
Merged

chore(clerk-js,ui): upgrade to Rspack 2#8382
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2

Conversation

@jacekradko

@jacekradkojacekradko commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Upgrades @clerk/clerk-js and @clerk/ui bundling from Rspack 1.7.x to Rspack 2 (2.0.6). Every variant builds (7 for clerk-js, 3 for ui), and the unit + integration matrix and bundlewatch are all green. Node minimum moves to 22.12.0, a Rspack 2 requirement.

The part worth real scrutiny is the config migration in packages/clerk-js/rspack.config.mjs and packages/ui/rspack.config.js: the config moves to ESM (Rspack 2 core is pure ESM), output.libraryTarget: 'x' is rewritten to output.library: { type: 'x' } across both configs, and experiments.cache graduates to a top-level cache. Since clerk-js/ui load into apps pinned on older SDK versions, the thing to confirm is that the per-variant bundle shape (library type, chunking) is unchanged.

Two small riders come along: bundlewatch budgets nudged up for Rspack 2's marginally larger gzip (clerk.browser.js 70→72KB, base-account-sdk 203→205KB, otherwise within ~0.1KB), and two @clerk/shared typecheck fixes, dropping the now-built-in NoInfer import from @tanstack/query-core and guarding script.nonce in loadScript.ts (matching #8177).

Holding the merge while the TS 6.0 work (#8177) settles, since the two overlap in the bundlewatch config and @clerk/ui's build.

Summary by CodeRabbit

  • Chores
    • Upgraded build infrastructure to Rspack 2 with optimized bundle handling
    • Updated minimum Node.js version requirement to 22.12.0
    • Adjusted bundle size to 72KB

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

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentJun 12, 2026 12:05pm
swingsetReadyReadyPreview, CommentJun 12, 2026 12:05pm

Request Review

@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c31eb18

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

This PR includes changesets to release 5 packages
NameType
@clerk/clerk-jsPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/swingsetPatch

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

pkg-pr-newBot commented Apr 22, 2026

Copy link
Copy Markdown

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/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: c31eb18

@coderabbitai

coderabbitaiBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR upgrades Rspack to version 2 across the workspace and migrates the clerk-js build configuration from CommonJS to ESM. The core change replaces deprecated libraryTarget API with the modern library.type format, consolidates cache configuration, and updates all related npm scripts and workspace dependencies.

Changes

Rspack 2.0 Upgrade and Configuration Updates

Layer / File(s)Summary
ESM imports, module interop, and config export
packages/clerk-js/rspack.config.mjs
Replace CommonJS requires with ESM imports, add createRequire and __dirname compatibility shims from import.meta.url, import package.json as JSON module, and switch config export from module.exports to export default.
Output library API migration
packages/clerk-js/rspack.config.mjs
Replace deprecated output.libraryTarget with output.library: { type: ... } across all bundle variants (UMD production, ESM/CJS variants, and dev builds).
Development cache consolidation
packages/clerk-js/rspack.config.mjs
Simplify dev caching by removing cache: true plus experiments.cache.type and replacing with cache: { type: 'memory' }.
Package scripts and devDependencies
packages/clerk-js/package.json
Update clerk-js npm scripts to reference rspack.config.mjs, remove --analyze CLI flag from build:analyze, upgrade @rsdoctor/rspack-plugin to ^1.5.9, and add @rspack/dev-server.
Workspace catalogs, bundle threshold, and type imports
pnpm-workspace.yaml, packages/clerk-js/bundlewatch.config.json, packages/shared/src/react/query/useQuery.ts
Update pnpm rspack catalog versions to 2.0.x range, extend trustPolicyExclude with tinyclip, increase clerk-js bundlewatch maxSize threshold, and remove NoInfer from @tanstack/query-core import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • dstaley
  • wobsoriano

Poem

🐰 With Rspack 2.0 and files in ESM flow,
The bundle output now gleams in runtime glow,
Libraries restructured from target to type so clean,
Cache consolidated—the smoothest build scene!
TypeScript imports refined, thresholds adjusted right,
Modernization complete, the config shines bright! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'chore(clerk-js,ui): upgrade to Rspack 2' accurately and specifically summarizes the main change—upgrading Rspack to version 2 for the clerk-js and ui packages.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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.

@coderabbitaicoderabbitaiBot left a comment

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.

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

Comment thread.changeset/rspack-2-upgrade.md Outdated
Comment threadpnpm-workspace.yaml Outdated
@github-actions

github-actionsBot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Break Check: no API changes detected across the tracked packages.

Last ran on 94cc5fb. Pushes that change no tracked declarations (no API surface change vs. base) are skipped and don't update this comment.

Drop the NoInfer import from @tanstack/query-core (removed in 5.100.14;
TS provides NoInfer as a built-in) and guard the script.nonce assignment
for stricter typecheck, matching #8177. Bump clerk.browser.js and
base-account-sdk bundlewatch budgets for rspack 2's slightly larger gzip output.

@coderabbitaicoderabbitaiBot left a comment

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.

🧹 Nitpick comments (1)
packages/shared/src/react/query/useQuery.ts (1)

36-41: ⚡ Quick win

Add JSDoc documentation for the public API function.

The useClerkQuery function is exported and part of the public API, but currently has an empty JSDoc comment. As per coding guidelines, public APIs should be documented with @param, @returns, and @example tags.

📝 Suggested JSDoc documentation
 /**
- *+ * Hook to execute a Clerk-specific query using TanStack Query patterns.+ *+ * `@param` options - Query configuration options including queryKey, queryFn, and other TanStack Query options+ * `@returns` Query result with data, error, loading, and fetching states+ *+ * `@example`+ * ```tsx+ * const { data, error, isLoading } = useClerkQuery({+ * queryKey: ['user', userId],+ * queryFn: () => fetchUserData(userId),+ * enabled: !!userId,+ * });+ * ```
*/
export function useClerkQuery(options: UseQueryOptions) {
return useBaseQuery(options, QueryObserver);
}

As per coding guidelines: "All public APIs must be documented with JSDoc".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/shared/src/react/query/useQuery.ts` around lines 36 - 41, Add a
proper JSDoc block above the exported function useClerkQuery describing its
purpose, a `@param` for the options parameter (type UseQueryOptions), a `@returns`
describing the query result shape, and an `@example` showing typical usage (e.g.,
queryKey, queryFn, enabled). Reference the implementation details by mentioning
useBaseQuery and QueryObserver so the docs note that useClerkQuery delegates to
useBaseQuery(options, QueryObserver). Keep the comment concise and follow
existing project JSDoc style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/shared/src/react/query/useQuery.ts`:
- Around line 36-41: Add a proper JSDoc block above the exported function
useClerkQuery describing its purpose, a `@param` for the options parameter (type
UseQueryOptions), a `@returns` describing the query result shape, and an `@example`
showing typical usage (e.g., queryKey, queryFn, enabled). Reference the
implementation details by mentioning useBaseQuery and QueryObserver so the docs
note that useClerkQuery delegates to useBaseQuery(options, QueryObserver). Keep
the comment concise and follow existing project JSDoc style.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: eed67afe-f65b-45d3-b58c-ec5a0a59ad5e

📥 Commits

Reviewing files that changed from the base of the PR and between 8fd4764 and 71991d7.

📒 Files selected for processing (3)
  • packages/clerk-js/bundlewatch.config.json
  • packages/shared/src/loadScript.ts
  • packages/shared/src/react/query/useQuery.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

Bump @rspack/core and @rspack/cli to 2.0.6, @rspack/dev-server to 2.0.3,
and @rspack/plugin-react-refresh to 2.0.1 (each package's latest in the
2.0.x line). All four are now >48h old, so drop the temporary @rspack/*
entry from minimumReleaseAgeExclude, restoring the release-age quarantine.
# Conflicts:
#	packages/clerk-js/bundlewatch.config.json
#	pnpm-lock.yaml

@coderabbitaicoderabbitaiBot left a comment

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.

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/package.json (1)

120-122: ⚠️ Potential issue | 🟠 Major

Fix engines.node to match Rspack 2’s required minimum.

packages/clerk-js/package.json sets engines.node to >=20.9.0, but Rspack 2 requires Node minimum 20.19.0 (or 22.12.0). Update the engines.node range to match (either >=20.19.0 or your chosen >=22.12.0 standard).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/clerk-js/package.json` around lines 120 - 122, Update the
package.json engines.node field to meet Rspack 2’s minimum: change the
"engines.node" value from ">=20.9.0" to either ">=20.19.0" (or your chosen
stricter baseline like ">=22.12.0") so the project declares a compatible Node.js
range; locate and edit the "engines.node" entry in the package.json manifest
(key: engines.node) and commit the updated range.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/clerk-js/package.json`:
- Around line 120-122: Update the package.json engines.node field to meet Rspack
2’s minimum: change the "engines.node" value from ">=20.9.0" to either
">=20.19.0" (or your chosen stricter baseline like ">=22.12.0") so the project
declares a compatible Node.js range; locate and edit the "engines.node" entry in
the package.json manifest (key: engines.node) and commit the updated range.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: dd59d800-11e7-4b80-9ac8-656f48f8b059

📥 Commits

Reviewing files that changed from the base of the PR and between e1714aa and 61d422e.

📒 Files selected for processing (2)
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/package.json
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

@github-actions

github-actionsBot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-06-12T12:06:36.032Z

Summary

MetricCount
Packages analyzed19
Packages with changes0
🔴 Breaking changes0
🟡 Non-breaking changes0
🟢 Additions0

Note
Break Check could not snapshot 1 subpath; the diff below excludes them.

  • @clerk/astro ./env: Internal Error: Unable to determine module for: /home/runner/_work/javascript/javascript/packages/astro/env.d.ts You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on c31eb18.

@dstaleydstaley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm :shipit:

Comment thread.changeset/rspack-2-upgrade.md Outdated
Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jacekradko@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' chore(clerk-js,ui): upgrade to Rspack 2 by jacekradko · Pull Request #8382 · clerk/javascript · GitHub
Skip to content

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

Merged
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2
Jun 12, 2026
Merged

chore(clerk-js,ui): upgrade to Rspack 2#8382
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2

Conversation

@jacekradko

@jacekradkojacekradko commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Upgrades @clerk/clerk-js and @clerk/ui bundling from Rspack 1.7.x to Rspack 2 (2.0.6). Every variant builds (7 for clerk-js, 3 for ui), and the unit + integration matrix and bundlewatch are all green. Node minimum moves to 22.12.0, a Rspack 2 requirement.

The part worth real scrutiny is the config migration in packages/clerk-js/rspack.config.mjs and packages/ui/rspack.config.js: the config moves to ESM (Rspack 2 core is pure ESM), output.libraryTarget: 'x' is rewritten to output.library: { type: 'x' } across both configs, and experiments.cache graduates to a top-level cache. Since clerk-js/ui load into apps pinned on older SDK versions, the thing to confirm is that the per-variant bundle shape (library type, chunking) is unchanged.

Two small riders come along: bundlewatch budgets nudged up for Rspack 2's marginally larger gzip (clerk.browser.js 70→72KB, base-account-sdk 203→205KB, otherwise within ~0.1KB), and two @clerk/shared typecheck fixes, dropping the now-built-in NoInfer import from @tanstack/query-core and guarding script.nonce in loadScript.ts (matching #8177).

Holding the merge while the TS 6.0 work (#8177) settles, since the two overlap in the bundlewatch config and @clerk/ui's build.

Summary by CodeRabbit

  • Chores
    • Upgraded build infrastructure to Rspack 2 with optimized bundle handling
    • Updated minimum Node.js version requirement to 22.12.0
    • Adjusted bundle size to 72KB

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

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentJun 12, 2026 12:05pm
swingsetReadyReadyPreview, CommentJun 12, 2026 12:05pm

Request Review

@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c31eb18

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

This PR includes changesets to release 5 packages
NameType
@clerk/clerk-jsPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/swingsetPatch

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

pkg-pr-newBot commented Apr 22, 2026

Copy link
Copy Markdown

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/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: c31eb18

@coderabbitai

coderabbitaiBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR upgrades Rspack to version 2 across the workspace and migrates the clerk-js build configuration from CommonJS to ESM. The core change replaces deprecated libraryTarget API with the modern library.type format, consolidates cache configuration, and updates all related npm scripts and workspace dependencies.

Changes

Rspack 2.0 Upgrade and Configuration Updates

Layer / File(s)Summary
ESM imports, module interop, and config export
packages/clerk-js/rspack.config.mjs
Replace CommonJS requires with ESM imports, add createRequire and __dirname compatibility shims from import.meta.url, import package.json as JSON module, and switch config export from module.exports to export default.
Output library API migration
packages/clerk-js/rspack.config.mjs
Replace deprecated output.libraryTarget with output.library: { type: ... } across all bundle variants (UMD production, ESM/CJS variants, and dev builds).
Development cache consolidation
packages/clerk-js/rspack.config.mjs
Simplify dev caching by removing cache: true plus experiments.cache.type and replacing with cache: { type: 'memory' }.
Package scripts and devDependencies
packages/clerk-js/package.json
Update clerk-js npm scripts to reference rspack.config.mjs, remove --analyze CLI flag from build:analyze, upgrade @rsdoctor/rspack-plugin to ^1.5.9, and add @rspack/dev-server.
Workspace catalogs, bundle threshold, and type imports
pnpm-workspace.yaml, packages/clerk-js/bundlewatch.config.json, packages/shared/src/react/query/useQuery.ts
Update pnpm rspack catalog versions to 2.0.x range, extend trustPolicyExclude with tinyclip, increase clerk-js bundlewatch maxSize threshold, and remove NoInfer from @tanstack/query-core import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • dstaley
  • wobsoriano

Poem

🐰 With Rspack 2.0 and files in ESM flow,
The bundle output now gleams in runtime glow,
Libraries restructured from target to type so clean,
Cache consolidated—the smoothest build scene!
TypeScript imports refined, thresholds adjusted right,
Modernization complete, the config shines bright! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'chore(clerk-js,ui): upgrade to Rspack 2' accurately and specifically summarizes the main change—upgrading Rspack to version 2 for the clerk-js and ui packages.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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.

@coderabbitaicoderabbitaiBot left a comment

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.

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

Comment thread.changeset/rspack-2-upgrade.md Outdated
Comment threadpnpm-workspace.yaml Outdated
@github-actions

github-actionsBot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Break Check: no API changes detected across the tracked packages.

Last ran on 94cc5fb. Pushes that change no tracked declarations (no API surface change vs. base) are skipped and don't update this comment.

Drop the NoInfer import from @tanstack/query-core (removed in 5.100.14;
TS provides NoInfer as a built-in) and guard the script.nonce assignment
for stricter typecheck, matching #8177. Bump clerk.browser.js and
base-account-sdk bundlewatch budgets for rspack 2's slightly larger gzip output.

@coderabbitaicoderabbitaiBot left a comment

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.

🧹 Nitpick comments (1)
packages/shared/src/react/query/useQuery.ts (1)

36-41: ⚡ Quick win

Add JSDoc documentation for the public API function.

The useClerkQuery function is exported and part of the public API, but currently has an empty JSDoc comment. As per coding guidelines, public APIs should be documented with @param, @returns, and @example tags.

📝 Suggested JSDoc documentation
 /**
- *+ * Hook to execute a Clerk-specific query using TanStack Query patterns.+ *+ * `@param` options - Query configuration options including queryKey, queryFn, and other TanStack Query options+ * `@returns` Query result with data, error, loading, and fetching states+ *+ * `@example`+ * ```tsx+ * const { data, error, isLoading } = useClerkQuery({+ * queryKey: ['user', userId],+ * queryFn: () => fetchUserData(userId),+ * enabled: !!userId,+ * });+ * ```
*/
export function useClerkQuery(options: UseQueryOptions) {
return useBaseQuery(options, QueryObserver);
}

As per coding guidelines: "All public APIs must be documented with JSDoc".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/shared/src/react/query/useQuery.ts` around lines 36 - 41, Add a
proper JSDoc block above the exported function useClerkQuery describing its
purpose, a `@param` for the options parameter (type UseQueryOptions), a `@returns`
describing the query result shape, and an `@example` showing typical usage (e.g.,
queryKey, queryFn, enabled). Reference the implementation details by mentioning
useBaseQuery and QueryObserver so the docs note that useClerkQuery delegates to
useBaseQuery(options, QueryObserver). Keep the comment concise and follow
existing project JSDoc style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/shared/src/react/query/useQuery.ts`:
- Around line 36-41: Add a proper JSDoc block above the exported function
useClerkQuery describing its purpose, a `@param` for the options parameter (type
UseQueryOptions), a `@returns` describing the query result shape, and an `@example`
showing typical usage (e.g., queryKey, queryFn, enabled). Reference the
implementation details by mentioning useBaseQuery and QueryObserver so the docs
note that useClerkQuery delegates to useBaseQuery(options, QueryObserver). Keep
the comment concise and follow existing project JSDoc style.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: eed67afe-f65b-45d3-b58c-ec5a0a59ad5e

📥 Commits

Reviewing files that changed from the base of the PR and between 8fd4764 and 71991d7.

📒 Files selected for processing (3)
  • packages/clerk-js/bundlewatch.config.json
  • packages/shared/src/loadScript.ts
  • packages/shared/src/react/query/useQuery.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

Bump @rspack/core and @rspack/cli to 2.0.6, @rspack/dev-server to 2.0.3,
and @rspack/plugin-react-refresh to 2.0.1 (each package's latest in the
2.0.x line). All four are now >48h old, so drop the temporary @rspack/*
entry from minimumReleaseAgeExclude, restoring the release-age quarantine.
# Conflicts:
#	packages/clerk-js/bundlewatch.config.json
#	pnpm-lock.yaml

@coderabbitaicoderabbitaiBot left a comment

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.

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/package.json (1)

120-122: ⚠️ Potential issue | 🟠 Major

Fix engines.node to match Rspack 2’s required minimum.

packages/clerk-js/package.json sets engines.node to >=20.9.0, but Rspack 2 requires Node minimum 20.19.0 (or 22.12.0). Update the engines.node range to match (either >=20.19.0 or your chosen >=22.12.0 standard).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/clerk-js/package.json` around lines 120 - 122, Update the
package.json engines.node field to meet Rspack 2’s minimum: change the
"engines.node" value from ">=20.9.0" to either ">=20.19.0" (or your chosen
stricter baseline like ">=22.12.0") so the project declares a compatible Node.js
range; locate and edit the "engines.node" entry in the package.json manifest
(key: engines.node) and commit the updated range.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/clerk-js/package.json`:
- Around line 120-122: Update the package.json engines.node field to meet Rspack
2’s minimum: change the "engines.node" value from ">=20.9.0" to either
">=20.19.0" (or your chosen stricter baseline like ">=22.12.0") so the project
declares a compatible Node.js range; locate and edit the "engines.node" entry in
the package.json manifest (key: engines.node) and commit the updated range.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: dd59d800-11e7-4b80-9ac8-656f48f8b059

📥 Commits

Reviewing files that changed from the base of the PR and between e1714aa and 61d422e.

📒 Files selected for processing (2)
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/package.json
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

@github-actions

github-actionsBot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-06-12T12:06:36.032Z

Summary

MetricCount
Packages analyzed19
Packages with changes0
🔴 Breaking changes0
🟡 Non-breaking changes0
🟢 Additions0

Note
Break Check could not snapshot 1 subpath; the diff below excludes them.

  • @clerk/astro ./env: Internal Error: Unable to determine module for: /home/runner/_work/javascript/javascript/packages/astro/env.d.ts You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on c31eb18.

@dstaleydstaley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm :shipit:

Comment thread.changeset/rspack-2-upgrade.md Outdated
Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jacekradko@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' chore(clerk-js,ui): upgrade to Rspack 2 by jacekradko · Pull Request #8382 · clerk/javascript · GitHub
Skip to content

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

Merged
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2
Jun 12, 2026
Merged

chore(clerk-js,ui): upgrade to Rspack 2#8382
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2

Conversation

@jacekradko

@jacekradkojacekradko commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Upgrades @clerk/clerk-js and @clerk/ui bundling from Rspack 1.7.x to Rspack 2 (2.0.6). Every variant builds (7 for clerk-js, 3 for ui), and the unit + integration matrix and bundlewatch are all green. Node minimum moves to 22.12.0, a Rspack 2 requirement.

The part worth real scrutiny is the config migration in packages/clerk-js/rspack.config.mjs and packages/ui/rspack.config.js: the config moves to ESM (Rspack 2 core is pure ESM), output.libraryTarget: 'x' is rewritten to output.library: { type: 'x' } across both configs, and experiments.cache graduates to a top-level cache. Since clerk-js/ui load into apps pinned on older SDK versions, the thing to confirm is that the per-variant bundle shape (library type, chunking) is unchanged.

Two small riders come along: bundlewatch budgets nudged up for Rspack 2's marginally larger gzip (clerk.browser.js 70→72KB, base-account-sdk 203→205KB, otherwise within ~0.1KB), and two @clerk/shared typecheck fixes, dropping the now-built-in NoInfer import from @tanstack/query-core and guarding script.nonce in loadScript.ts (matching #8177).

Holding the merge while the TS 6.0 work (#8177) settles, since the two overlap in the bundlewatch config and @clerk/ui's build.

Summary by CodeRabbit

  • Chores
    • Upgraded build infrastructure to Rspack 2 with optimized bundle handling
    • Updated minimum Node.js version requirement to 22.12.0
    • Adjusted bundle size to 72KB

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

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentJun 12, 2026 12:05pm
swingsetReadyReadyPreview, CommentJun 12, 2026 12:05pm

Request Review

@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c31eb18

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

This PR includes changesets to release 5 packages
NameType
@clerk/clerk-jsPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/swingsetPatch

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

pkg-pr-newBot commented Apr 22, 2026

Copy link
Copy Markdown

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/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: c31eb18

@coderabbitai

coderabbitaiBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR upgrades Rspack to version 2 across the workspace and migrates the clerk-js build configuration from CommonJS to ESM. The core change replaces deprecated libraryTarget API with the modern library.type format, consolidates cache configuration, and updates all related npm scripts and workspace dependencies.

Changes

Rspack 2.0 Upgrade and Configuration Updates

Layer / File(s)Summary
ESM imports, module interop, and config export
packages/clerk-js/rspack.config.mjs
Replace CommonJS requires with ESM imports, add createRequire and __dirname compatibility shims from import.meta.url, import package.json as JSON module, and switch config export from module.exports to export default.
Output library API migration
packages/clerk-js/rspack.config.mjs
Replace deprecated output.libraryTarget with output.library: { type: ... } across all bundle variants (UMD production, ESM/CJS variants, and dev builds).
Development cache consolidation
packages/clerk-js/rspack.config.mjs
Simplify dev caching by removing cache: true plus experiments.cache.type and replacing with cache: { type: 'memory' }.
Package scripts and devDependencies
packages/clerk-js/package.json
Update clerk-js npm scripts to reference rspack.config.mjs, remove --analyze CLI flag from build:analyze, upgrade @rsdoctor/rspack-plugin to ^1.5.9, and add @rspack/dev-server.
Workspace catalogs, bundle threshold, and type imports
pnpm-workspace.yaml, packages/clerk-js/bundlewatch.config.json, packages/shared/src/react/query/useQuery.ts
Update pnpm rspack catalog versions to 2.0.x range, extend trustPolicyExclude with tinyclip, increase clerk-js bundlewatch maxSize threshold, and remove NoInfer from @tanstack/query-core import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • dstaley
  • wobsoriano

Poem

🐰 With Rspack 2.0 and files in ESM flow,
The bundle output now gleams in runtime glow,
Libraries restructured from target to type so clean,
Cache consolidated—the smoothest build scene!
TypeScript imports refined, thresholds adjusted right,
Modernization complete, the config shines bright! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'chore(clerk-js,ui): upgrade to Rspack 2' accurately and specifically summarizes the main change—upgrading Rspack to version 2 for the clerk-js and ui packages.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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.

@coderabbitaicoderabbitaiBot left a comment

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.

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

Comment thread.changeset/rspack-2-upgrade.md Outdated
Comment threadpnpm-workspace.yaml Outdated
@github-actions

github-actionsBot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Break Check: no API changes detected across the tracked packages.

Last ran on 94cc5fb. Pushes that change no tracked declarations (no API surface change vs. base) are skipped and don't update this comment.

Drop the NoInfer import from @tanstack/query-core (removed in 5.100.14;
TS provides NoInfer as a built-in) and guard the script.nonce assignment
for stricter typecheck, matching #8177. Bump clerk.browser.js and
base-account-sdk bundlewatch budgets for rspack 2's slightly larger gzip output.

@coderabbitaicoderabbitaiBot left a comment

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.

🧹 Nitpick comments (1)
packages/shared/src/react/query/useQuery.ts (1)

36-41: ⚡ Quick win

Add JSDoc documentation for the public API function.

The useClerkQuery function is exported and part of the public API, but currently has an empty JSDoc comment. As per coding guidelines, public APIs should be documented with @param, @returns, and @example tags.

📝 Suggested JSDoc documentation
 /**
- *+ * Hook to execute a Clerk-specific query using TanStack Query patterns.+ *+ * `@param` options - Query configuration options including queryKey, queryFn, and other TanStack Query options+ * `@returns` Query result with data, error, loading, and fetching states+ *+ * `@example`+ * ```tsx+ * const { data, error, isLoading } = useClerkQuery({+ * queryKey: ['user', userId],+ * queryFn: () => fetchUserData(userId),+ * enabled: !!userId,+ * });+ * ```
*/
export function useClerkQuery(options: UseQueryOptions) {
return useBaseQuery(options, QueryObserver);
}

As per coding guidelines: "All public APIs must be documented with JSDoc".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/shared/src/react/query/useQuery.ts` around lines 36 - 41, Add a
proper JSDoc block above the exported function useClerkQuery describing its
purpose, a `@param` for the options parameter (type UseQueryOptions), a `@returns`
describing the query result shape, and an `@example` showing typical usage (e.g.,
queryKey, queryFn, enabled). Reference the implementation details by mentioning
useBaseQuery and QueryObserver so the docs note that useClerkQuery delegates to
useBaseQuery(options, QueryObserver). Keep the comment concise and follow
existing project JSDoc style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/shared/src/react/query/useQuery.ts`:
- Around line 36-41: Add a proper JSDoc block above the exported function
useClerkQuery describing its purpose, a `@param` for the options parameter (type
UseQueryOptions), a `@returns` describing the query result shape, and an `@example`
showing typical usage (e.g., queryKey, queryFn, enabled). Reference the
implementation details by mentioning useBaseQuery and QueryObserver so the docs
note that useClerkQuery delegates to useBaseQuery(options, QueryObserver). Keep
the comment concise and follow existing project JSDoc style.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: eed67afe-f65b-45d3-b58c-ec5a0a59ad5e

📥 Commits

Reviewing files that changed from the base of the PR and between 8fd4764 and 71991d7.

📒 Files selected for processing (3)
  • packages/clerk-js/bundlewatch.config.json
  • packages/shared/src/loadScript.ts
  • packages/shared/src/react/query/useQuery.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

Bump @rspack/core and @rspack/cli to 2.0.6, @rspack/dev-server to 2.0.3,
and @rspack/plugin-react-refresh to 2.0.1 (each package's latest in the
2.0.x line). All four are now >48h old, so drop the temporary @rspack/*
entry from minimumReleaseAgeExclude, restoring the release-age quarantine.
# Conflicts:
#	packages/clerk-js/bundlewatch.config.json
#	pnpm-lock.yaml

@coderabbitaicoderabbitaiBot left a comment

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.

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/package.json (1)

120-122: ⚠️ Potential issue | 🟠 Major

Fix engines.node to match Rspack 2’s required minimum.

packages/clerk-js/package.json sets engines.node to >=20.9.0, but Rspack 2 requires Node minimum 20.19.0 (or 22.12.0). Update the engines.node range to match (either >=20.19.0 or your chosen >=22.12.0 standard).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/clerk-js/package.json` around lines 120 - 122, Update the
package.json engines.node field to meet Rspack 2’s minimum: change the
"engines.node" value from ">=20.9.0" to either ">=20.19.0" (or your chosen
stricter baseline like ">=22.12.0") so the project declares a compatible Node.js
range; locate and edit the "engines.node" entry in the package.json manifest
(key: engines.node) and commit the updated range.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/clerk-js/package.json`:
- Around line 120-122: Update the package.json engines.node field to meet Rspack
2’s minimum: change the "engines.node" value from ">=20.9.0" to either
">=20.19.0" (or your chosen stricter baseline like ">=22.12.0") so the project
declares a compatible Node.js range; locate and edit the "engines.node" entry in
the package.json manifest (key: engines.node) and commit the updated range.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: dd59d800-11e7-4b80-9ac8-656f48f8b059

📥 Commits

Reviewing files that changed from the base of the PR and between e1714aa and 61d422e.

📒 Files selected for processing (2)
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/package.json
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

@github-actions

github-actionsBot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-06-12T12:06:36.032Z

Summary

MetricCount
Packages analyzed19
Packages with changes0
🔴 Breaking changes0
🟡 Non-breaking changes0
🟢 Additions0

Note
Break Check could not snapshot 1 subpath; the diff below excludes them.

  • @clerk/astro ./env: Internal Error: Unable to determine module for: /home/runner/_work/javascript/javascript/packages/astro/env.d.ts You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on c31eb18.

@dstaleydstaley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm :shipit:

Comment thread.changeset/rspack-2-upgrade.md Outdated
Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jacekradko@dstaley@wobsoriano
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); chore(clerk-js,ui): upgrade to Rspack 2 by jacekradko · Pull Request #8382 · clerk/javascript · GitHub
Skip to content

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

Merged
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2
Jun 12, 2026
Merged

chore(clerk-js,ui): upgrade to Rspack 2#8382
jacekradko merged 12 commits into
mainfrom
jacek/rspack-2

Conversation

@jacekradko

@jacekradkojacekradko commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Upgrades @clerk/clerk-js and @clerk/ui bundling from Rspack 1.7.x to Rspack 2 (2.0.6). Every variant builds (7 for clerk-js, 3 for ui), and the unit + integration matrix and bundlewatch are all green. Node minimum moves to 22.12.0, a Rspack 2 requirement.

The part worth real scrutiny is the config migration in packages/clerk-js/rspack.config.mjs and packages/ui/rspack.config.js: the config moves to ESM (Rspack 2 core is pure ESM), output.libraryTarget: 'x' is rewritten to output.library: { type: 'x' } across both configs, and experiments.cache graduates to a top-level cache. Since clerk-js/ui load into apps pinned on older SDK versions, the thing to confirm is that the per-variant bundle shape (library type, chunking) is unchanged.

Two small riders come along: bundlewatch budgets nudged up for Rspack 2's marginally larger gzip (clerk.browser.js 70→72KB, base-account-sdk 203→205KB, otherwise within ~0.1KB), and two @clerk/shared typecheck fixes, dropping the now-built-in NoInfer import from @tanstack/query-core and guarding script.nonce in loadScript.ts (matching #8177).

Holding the merge while the TS 6.0 work (#8177) settles, since the two overlap in the bundlewatch config and @clerk/ui's build.

Summary by CodeRabbit

  • Chores
    • Upgraded build infrastructure to Rspack 2 with optimized bundle handling
    • Updated minimum Node.js version requirement to 22.12.0
    • Adjusted bundle size to 72KB

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

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
clerk-js-sandboxReadyReadyPreview, CommentJun 12, 2026 12:05pm
swingsetReadyReadyPreview, CommentJun 12, 2026 12:05pm

Request Review

@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c31eb18

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

This PR includes changesets to release 5 packages
NameType
@clerk/clerk-jsPatch
@clerk/uiPatch
@clerk/chrome-extensionPatch
@clerk/expoPatch
@clerk/swingsetPatch

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

pkg-pr-newBot commented Apr 22, 2026

Copy link
Copy Markdown

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/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: c31eb18

@coderabbitai

coderabbitaiBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR upgrades Rspack to version 2 across the workspace and migrates the clerk-js build configuration from CommonJS to ESM. The core change replaces deprecated libraryTarget API with the modern library.type format, consolidates cache configuration, and updates all related npm scripts and workspace dependencies.

Changes

Rspack 2.0 Upgrade and Configuration Updates

Layer / File(s)Summary
ESM imports, module interop, and config export
packages/clerk-js/rspack.config.mjs
Replace CommonJS requires with ESM imports, add createRequire and __dirname compatibility shims from import.meta.url, import package.json as JSON module, and switch config export from module.exports to export default.
Output library API migration
packages/clerk-js/rspack.config.mjs
Replace deprecated output.libraryTarget with output.library: { type: ... } across all bundle variants (UMD production, ESM/CJS variants, and dev builds).
Development cache consolidation
packages/clerk-js/rspack.config.mjs
Simplify dev caching by removing cache: true plus experiments.cache.type and replacing with cache: { type: 'memory' }.
Package scripts and devDependencies
packages/clerk-js/package.json
Update clerk-js npm scripts to reference rspack.config.mjs, remove --analyze CLI flag from build:analyze, upgrade @rsdoctor/rspack-plugin to ^1.5.9, and add @rspack/dev-server.
Workspace catalogs, bundle threshold, and type imports
pnpm-workspace.yaml, packages/clerk-js/bundlewatch.config.json, packages/shared/src/react/query/useQuery.ts
Update pnpm rspack catalog versions to 2.0.x range, extend trustPolicyExclude with tinyclip, increase clerk-js bundlewatch maxSize threshold, and remove NoInfer from @tanstack/query-core import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • dstaley
  • wobsoriano

Poem

🐰 With Rspack 2.0 and files in ESM flow,
The bundle output now gleams in runtime glow,
Libraries restructured from target to type so clean,
Cache consolidated—the smoothest build scene!
TypeScript imports refined, thresholds adjusted right,
Modernization complete, the config shines bright! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'chore(clerk-js,ui): upgrade to Rspack 2' accurately and specifically summarizes the main change—upgrading Rspack to version 2 for the clerk-js and ui packages.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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.

@coderabbitaicoderabbitaiBot left a comment

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.

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

Comment thread.changeset/rspack-2-upgrade.md Outdated
Comment threadpnpm-workspace.yaml Outdated
@github-actions

github-actionsBot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Break Check: no API changes detected across the tracked packages.

Last ran on 94cc5fb. Pushes that change no tracked declarations (no API surface change vs. base) are skipped and don't update this comment.

Drop the NoInfer import from @tanstack/query-core (removed in 5.100.14;
TS provides NoInfer as a built-in) and guard the script.nonce assignment
for stricter typecheck, matching #8177. Bump clerk.browser.js and
base-account-sdk bundlewatch budgets for rspack 2's slightly larger gzip output.

@coderabbitaicoderabbitaiBot left a comment

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.

🧹 Nitpick comments (1)
packages/shared/src/react/query/useQuery.ts (1)

36-41: ⚡ Quick win

Add JSDoc documentation for the public API function.

The useClerkQuery function is exported and part of the public API, but currently has an empty JSDoc comment. As per coding guidelines, public APIs should be documented with @param, @returns, and @example tags.

📝 Suggested JSDoc documentation
 /**
- *+ * Hook to execute a Clerk-specific query using TanStack Query patterns.+ *+ * `@param` options - Query configuration options including queryKey, queryFn, and other TanStack Query options+ * `@returns` Query result with data, error, loading, and fetching states+ *+ * `@example`+ * ```tsx+ * const { data, error, isLoading } = useClerkQuery({+ * queryKey: ['user', userId],+ * queryFn: () => fetchUserData(userId),+ * enabled: !!userId,+ * });+ * ```
*/
export function useClerkQuery(options: UseQueryOptions) {
return useBaseQuery(options, QueryObserver);
}

As per coding guidelines: "All public APIs must be documented with JSDoc".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/shared/src/react/query/useQuery.ts` around lines 36 - 41, Add a
proper JSDoc block above the exported function useClerkQuery describing its
purpose, a `@param` for the options parameter (type UseQueryOptions), a `@returns`
describing the query result shape, and an `@example` showing typical usage (e.g.,
queryKey, queryFn, enabled). Reference the implementation details by mentioning
useBaseQuery and QueryObserver so the docs note that useClerkQuery delegates to
useBaseQuery(options, QueryObserver). Keep the comment concise and follow
existing project JSDoc style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/shared/src/react/query/useQuery.ts`:
- Around line 36-41: Add a proper JSDoc block above the exported function
useClerkQuery describing its purpose, a `@param` for the options parameter (type
UseQueryOptions), a `@returns` describing the query result shape, and an `@example`
showing typical usage (e.g., queryKey, queryFn, enabled). Reference the
implementation details by mentioning useBaseQuery and QueryObserver so the docs
note that useClerkQuery delegates to useBaseQuery(options, QueryObserver). Keep
the comment concise and follow existing project JSDoc style.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: eed67afe-f65b-45d3-b58c-ec5a0a59ad5e

📥 Commits

Reviewing files that changed from the base of the PR and between 8fd4764 and 71991d7.

📒 Files selected for processing (3)
  • packages/clerk-js/bundlewatch.config.json
  • packages/shared/src/loadScript.ts
  • packages/shared/src/react/query/useQuery.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

Bump @rspack/core and @rspack/cli to 2.0.6, @rspack/dev-server to 2.0.3,
and @rspack/plugin-react-refresh to 2.0.1 (each package's latest in the
2.0.x line). All four are now >48h old, so drop the temporary @rspack/*
entry from minimumReleaseAgeExclude, restoring the release-age quarantine.
# Conflicts:
#	packages/clerk-js/bundlewatch.config.json
#	pnpm-lock.yaml

@coderabbitaicoderabbitaiBot left a comment

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.

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/package.json (1)

120-122: ⚠️ Potential issue | 🟠 Major

Fix engines.node to match Rspack 2’s required minimum.

packages/clerk-js/package.json sets engines.node to >=20.9.0, but Rspack 2 requires Node minimum 20.19.0 (or 22.12.0). Update the engines.node range to match (either >=20.19.0 or your chosen >=22.12.0 standard).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/clerk-js/package.json` around lines 120 - 122, Update the
package.json engines.node field to meet Rspack 2’s minimum: change the
"engines.node" value from ">=20.9.0" to either ">=20.19.0" (or your chosen
stricter baseline like ">=22.12.0") so the project declares a compatible Node.js
range; locate and edit the "engines.node" entry in the package.json manifest
(key: engines.node) and commit the updated range.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/clerk-js/package.json`:
- Around line 120-122: Update the package.json engines.node field to meet Rspack
2’s minimum: change the "engines.node" value from ">=20.9.0" to either
">=20.19.0" (or your chosen stricter baseline like ">=22.12.0") so the project
declares a compatible Node.js range; locate and edit the "engines.node" entry in
the package.json manifest (key: engines.node) and commit the updated range.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: dd59d800-11e7-4b80-9ac8-656f48f8b059

📥 Commits

Reviewing files that changed from the base of the PR and between e1714aa and 61d422e.

📒 Files selected for processing (2)
  • packages/clerk-js/bundlewatch.config.json
  • packages/clerk-js/package.json
✅ Files skipped from review due to trivial changes (1)
  • packages/clerk-js/bundlewatch.config.json

@github-actions

github-actionsBot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-06-12T12:06:36.032Z

Summary

MetricCount
Packages analyzed19
Packages with changes0
🔴 Breaking changes0
🟡 Non-breaking changes0
🟢 Additions0

Note
Break Check could not snapshot 1 subpath; the diff below excludes them.

  • @clerk/astro ./env: Internal Error: Unable to determine module for: /home/runner/_work/javascript/javascript/packages/astro/env.d.ts You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on c31eb18.

@dstaleydstaley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm :shipit:

Comment thread.changeset/rspack-2-upgrade.md Outdated
Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jacekradko@dstaley@wobsoriano