Skip to content

fix(shared): Declare package as side-effect-free for tree-shaking - #9503

Open
addielaruee wants to merge 1 commit into
clerk:mainfrom
addielaruee:fix/shared-side-effects-free
Open

fix(shared): Declare package as side-effect-free for tree-shaking#9503
addielaruee wants to merge 1 commit into
clerk:mainfrom
addielaruee:fix/shared-side-effects-free

Conversation

@addielaruee

Copy link
Copy Markdown

Description

@clerk/nextjs declares "sideEffects": false, but @clerk/shared, which it stands on, omits the field. Bundlers therefore have to assume every module in @clerk/shared may have side effects and cannot drop unused exports reached through it. This is the @clerk/shared part of #9475.

This adds "sideEffects": false to @clerk/shared. Its published source has no import-time side effects: there are 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. The declaration matches @clerk/nextjs and the other framework packages that already set it.

Scope note: this covers the @clerk/shared half of #9475 only. @clerk/react is intentionally left out, because its entry (src/index.ts) has genuine import-time side effects: the window.global shim in polyfills.ts, and top-level setErrorThrowerOptions / setClerkJSLoadingErrorPackageName calls. It would need the array form rather than a blanket false, and which built chunks that array has to cover depends on the merged tsdown output described in the issue. Happy to follow up on @clerk/react separately.

Part of #9475

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:

@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-bot

changeset-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c31d2eb

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

This PR includes changesets to release 23 packages
Name Type
@clerk/shared Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/chrome-extension Patch
@clerk/clerk-js Patch
@clerk/electron Patch
@clerk/expo-passkeys Patch
@clerk/expo Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/headless Patch
@clerk/hono Patch
@clerk/localizations Patch
@clerk/msw Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/react Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/ui Patch
@clerk/vue Patch
@clerk/swingset Patch

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

@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

@addielaruee is attempting to deploy a commit to the Clerk Production Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 31058174-8fbf-4607-a2c3-b1f982a7960c

📥 Commits

Reviewing files that changed from the base of the PR and between a52d486 and c31d2eb.

📒 Files selected for processing (2)
  • .changeset/shared-sideeffects-false.md
  • packages/shared/package.json
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change declares @clerk/shared as side-effect-free in its package metadata. It also adds a patch changeset that documents the declaration and bundling behavior.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to c31d2

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: clerk-cookie, jacekradko

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the addition of sideEffects false to @clerk/shared and its scope.
Title check ✅ Passed The title clearly and concisely describes declaring @clerk/shared as side-effect-free for tree-shaking.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant