fix(nextjs): declare dist/esm as ESM via type:module sidecar#8397
fix(nextjs): declare dist/esm as ESM via type:module sidecar#8397jacekradko wants to merge 2 commits intomainfrom
Conversation
Add `"type": "module"` to `package.esm.json` so `dist/esm/package.json` declares the bundle as ESM. Node 22+ and tsx consumers under `"type": "module"` can now import named exports from `@clerk/nextjs/server` without hitting SyntaxError at instantiate time. Swap `lint:attw --ignore-rules unexpected-module-syntax` (no longer needed) for `--ignore-rules false-cjs`, which fires because types are still emitted as `.d.ts`. The `.d.mts` split is tracked separately. Closes #8396
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
🦋 Changeset detectedLatest commit: 05425f5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR adds a Changesets release note and updates package metadata to mark the ESM build as an ES module by adding Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
Webpack's next-flight-loader rejects 'export *' in client boundaries once a package declares itself as ESM. With the type:module sidecar now in place, the existing re-export chain through '@clerk/nextjs/experimental' broke Next.js 15 app builds that imported from it in client components. Spell out the named exports to satisfy the client-boundary rule while keeping the public API intact.
Summary
"type": "module"topackages/nextjs/package.esm.jsonsodist/esm/package.jsondeclares the bundled ESM output as ESM. Node 22+ andtsxconsumers under"type": "module"can now import named exports from@clerk/nextjs/serverwithout theSyntaxError: does not provide an export named 'clerkClient'reported in dist/esm lacks 'type: module' metadata — breaks @clerk/nextjs on Node 22+ under type:module consumers #8396.lint:attw --ignore-rules unexpected-module-syntaxfor--ignore-rules false-cjs. Withtype: moduleset,unexpected-module-syntaxstops firing, but attw now flagsfalse-cjson every subpath because type declarations are still emitted as.d.ts. Splitting types to.d.mtsis tracked as a separate follow-up.Closes #8396
Test plan
pnpm --filter @clerk/nextjs buildsucceeds anddist/esm/package.jsoncontains"type": "module"pnpm --filter @clerk/nextjs lint:attwpasses with the swapped ignore rulepnpm --filter @clerk/nextjs lint:publintpasses (pre-existing warnings unchanged)pnpm --filter @clerk/nextjs test— no new regressionsimport { clerkClient } from '@clerk/nextjs/server'under"type": "module") now printsclerkClient typeof: function; fails on main with the reported error