fix(shared): Declare package as side-effect-free for tree-shaking - #9503
fix(shared): Declare package as side-effect-free for tree-shaking#9503addielaruee wants to merge 1 commit into
Conversation
@clerk/shared omitted the "sideEffects" field, so bundlers had to assume every module in the package might have side effects and could not drop unused exports reached through @clerk/nextjs. Its published source has no import-time side effects: no CSS or bare side-effect imports, and the only globalThis write (in createClerkDevCache) runs lazily when the function is called rather than on import. Declaring "sideEffects": false lets bundlers tree-shake unused @clerk/shared exports, matching @clerk/nextjs and the other framework packages that already set it. Refs clerk#9475
🦋 Changeset detectedLatest commit: c31d2eb The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 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 |
|
@addielaruee is attempting to deploy a commit to the Clerk Production Team on Vercel. A member of the Team first needs to authorize it. |
|
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 Plus Run ID: 📒 Files selected for processing (2)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change declares Estimated code review effort: 1 (Trivial) | ~3 minutes Merge Risk: ⚪ Minimal · up to The package metadata change is narrowly scoped to enable tree-shaking, and no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
@clerk/nextjsdeclares"sideEffects": false, but@clerk/shared, which it stands on, omits the field. Bundlers therefore have to assume every module in@clerk/sharedmay have side effects and cannot drop unused exports reached through it. This is the@clerk/sharedpart of #9475.This adds
"sideEffects": falseto@clerk/shared. Its published source has no import-time side effects: there are no CSS or bare side-effect imports, and the onlyglobalThiswrite (increateClerkDevCache) runs lazily when the function is called rather than on import. The declaration matches@clerk/nextjsand the other framework packages that already set it.Scope note: this covers the
@clerk/sharedhalf of #9475 only.@clerk/reactis intentionally left out, because its entry (src/index.ts) has genuine import-time side effects: thewindow.globalshim inpolyfills.ts, and top-levelsetErrorThrowerOptions/setClerkJSLoadingErrorPackageNamecalls. It would need the array form rather than a blanketfalse, and which built chunks that array has to cover depends on the mergedtsdownoutput described in the issue. Happy to follow up on@clerk/reactseparately.Part of #9475
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change