Skip to content

Conversation

@bratsos
Copy link
Member

@bratsos bratsos commented Jan 23, 2026

Add runtime version check in ClerkUi constructor to detect incompatible @clerk/clerk-js versions. In development instances, logs a warning; in production, throws ClerkRuntimeError with actionable upgrade guidance.

Also moves shared version utilities to @clerk/shared/utils.

Description

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

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

brkalow and others added 20 commits January 15, 2026 22:54
Introduces a "shared" variant of @clerk/ui that externalizes React
dependencies, allowing the host application's React to be reused
instead of bundling a separate copy.

Changes:
- Add @clerk/ui/register module to register React on globalThis
- Add ui.shared.browser.js build variant with externalized React
- Add React version compatibility checking in @clerk/react
- Add clerkUiVariant option to load the appropriate variant
- Make dev server React externalization conditional via --env shared

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Extract version checking logic into testable utility (versionCheck.ts)
- Add comprehensive unit tests for version parsing and bounds checking
- Move version compatibility check to module level for better performance
- Add dev warning when pnpm-workspace.yaml fallback is used
- Add warning for React version mismatch in register modules
- Remove redundant clerkUiVariant assignment in isomorphicClerk.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The new exports field in clerk-js/package.json blocked deep imports that
expo and chrome-extension packages depended on. This adds:
- ./internal/fapi export for FapiRequestInit/FapiResponse types (expo)
- ./no-rhc export for the no-RHC variant (chrome-extension)

Also updates expo to use the new clean import path.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rename register/index.js to register/index.cjs to fix module syntax
  mismatch (package uses "type": "module" but file was CommonJS)
- Add register/index.d.cts for CJS type declarations to fix
  "Masquerading as ESM" attw error
- Update exports to point to correct file extensions
- Run pnpm dedupe to clean up lockfile

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The new exports field introduces ESM entry points (.mjs) with CJS type
declarations (.d.ts), which triggers attw's "Masquerading as CJS" warning.
This is expected behavior for this package's build setup, so we ignore
the false-cjs rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add required curly braces after if conditions in versionCheck.ts and
fix import sorting in index.ts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Externalize react-dom/client in the shared variant and register it
on globalThis.__clerkSharedModules so host apps can share it with
@clerk/ui.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…pendencies

- Remove hardcoded fallback version range in tsup.config.ts
- Start from package.json peerDependencies.react to determine version range
- If it's a catalog reference (catalog:XXX), resolve it from pnpm-workspace.yaml
- If it's already a version range, parse it directly
- Extract parseRangeToBounds to build-utils/ for testability
- Add comprehensive tests for version range parsing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The ClerkScripts component was not passing clerkUiVariant to clerkUiScriptUrl(),
causing ui.browser.js to load instead of ui.shared.browser.js in Next.js apps.

- Export IS_REACT_SHARED_VARIANT_COMPATIBLE from @clerk/react/internal
- Use React version compatibility to determine default UI variant in Next.js
- Pass clerkUiVariant to opts, allowing user override via provider props

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add `noExternal: ['@clerk/ui/register']` to tsup config to inline
  the registration code at build time instead of requiring it as a
  runtime dependency
- Rename `clerkUiVariant` to `clerkUIVariant` for consistency

This eliminates the runtime dependency on @clerk/ui for consumers
of @clerk/react while still enabling the shared React variant.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

⚠️ No Changeset found

Latest commit: 682ea78

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Jan 23, 2026

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

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jan 23, 2026 8:45pm

Request Review

@github-actions github-actions bot added the react label Jan 23, 2026
brkalow and others added 4 commits January 23, 2026 13:42
…rray

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move parseVersion, checkVersionAgainstBounds, isVersionCompatible, and
VersionBounds type from @clerk/react to @clerk/shared/versionCheck for
reuse across packages. The React package now imports from shared and
re-exports for backwards compatibility, keeping only the React-specific
computeReactVersionCompatibility and IS_REACT_SHARED_VARIANT_COMPATIBLE.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add runtime version check in ClerkUi constructor to detect incompatible
@clerk/clerk-js versions. In development instances, logs a warning; in
production, throws ClerkRuntimeError with actionable upgrade guidance.

Also adds isVersionAtLeast utility to @clerk/shared/versionCheck.
@bratsos bratsos force-pushed the alexbratsos/user-4102-implement-minimum-clerkjs-sdk-version-in-clerkui branch from f6578d0 to 682ea78 Compare January 23, 2026 20:44
Base automatically changed from brkalow/sacramento to main January 23, 2026 21:05
Sign up for free to 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