-
Notifications
You must be signed in to change notification settings - Fork 385
feat(clerk-react): Test ESM-only clerk-react #6821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 84c3897 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughShifts the React package to ESM-only: sets "type": "module", simplifies exports to "types"/"default", updates tsup to emit only ESM, and adjusts TypeScript module/moduleResolution. Adds a changeset marking a minor release for @clerk/clerk-react. No source code or runtime logic changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Comment |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.changeset/red-horses-type.md (1)
1-6
: Complete the changeset description.The changeset correctly marks this as a minor release but needs a proper description explaining the breaking change nature of moving to ESM-only.
Apply this diff to provide a complete changeset description:
--- '@clerk/clerk-react': minor --- -wip +Convert @clerk/clerk-react to ESM-only package. This removes CommonJS support and requires Node.js environments that support ES modules.
🧹 Nitpick comments (1)
packages/react/package.json (1)
45-45
: Consider removing the main field for ESM-only packages.The
main
field is primarily for CommonJS compatibility. Since this is now an ESM-only package, themain
field might be redundant as modern tools should use theexports
field.Consider applying this diff to remove the redundant main field:
- "main": "./dist/index.js",
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
.changeset/red-horses-type.md
(1 hunks)packages/react/package.json
(1 hunks)packages/react/tsconfig.json
(1 hunks)packages/react/tsup.config.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
.changeset/**
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/red-horses-type.md
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/react/tsup.config.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/react/tsup.config.ts
packages/react/tsconfig.json
packages/react/package.json
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/react/tsup.config.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/react/tsup.config.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/react/tsup.config.ts
packages/*/tsup.config.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
TypeScript compilation and bundling must use tsup.
Files:
packages/react/tsup.config.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/react/tsup.config.ts
packages/*/tsconfig.json
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Type checking must be performed with TypeScript and publint.
Files:
packages/react/tsconfig.json
packages/*/package.json
📄 CodeRabbit inference engine (.cursor/rules/global.mdc)
All publishable packages should be placed under the packages/ directory
packages/*/package.json
: All publishable packages must be located in the 'packages/' directory.
All packages must be published under the @clerk namespace on npm.
Semantic versioning must be used across all packages.
Files:
packages/react/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Build Packages
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
packages/react/tsconfig.json (1)
9-10
: LGTM! TypeScript configuration aligns with ESM-only build.The changes to
moduleResolution: "bundler"
andmodule: "preserve"
are appropriate for the ESM-only transformation. These settings work well with modern bundlers and preserve the original module format during TypeScript compilation, letting tsup handle the final ESM output.packages/react/package.json (3)
25-25
: LGTM! Enables ES module support.Adding
"type": "module"
correctly marks this package as an ES module, which is essential for the ESM-only transformation.
26-44
: Export paths verified — no action required.tsup (packages/react/tsup.config.ts) defines entries index/internal/errors/experimental with dts: true and the matching source files exist (packages/react/src/{index,internal,errors,experimental}.ts), so the package.json exports align with the build outputs.
82-84
: Confirm Node.js 18.17.0 supports the ESM features usedFile: packages/react/package.json
Lines: 82-84"engines": { "node": ">=18.17.0" },
18.17.0 is LTS and supports standard ESM (import/export, dynamic import, top-level await). Verify the repo does not rely on experimental ESM features (JSON import assertions, import.meta.resolve, WASM imports) or synchronous CJS→ESM require; if it does, raise the engines range or add compatibility shims.
packages/react/tsup.config.ts (1)
19-19
: Verify impact of removing CommonJS support across the ecosystem — repo scan results
- Scan of the repo (script output) found NO in-repo CommonJS usage of @clerk/clerk-react (no require('@clerk/clerk-react') or module.exports referencing that package).
- Repo occurrences: ES import in playground/cra-js/src/App.js (import { ClerkProvider, SignIn } from '@clerk/clerk-react'); packages/upgrade/src/guide-generators/core-2/react/index.js contains the package name string; several jest.config.* files use module.exports (config files only).
- Recommendation: still a breaking change for external CommonJS consumers — either restore CJS output or publish as ESM-only with a major-version bump, ensure package.json 'exports'/'main' and 'type' are correct, and add migration notes.
Description
This PR is just a testing ground for a potential ESM-only version of
@clerk/clerk-react
.Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
Chores
Impact