Skip to content

fix(chrome-extension): Bundle @clerk/shared to properly tree-shake - #4899

Merged
LekoArts merged 1 commit into
mainfrom
lekoarts/eco-300-chrome-web-store-rejection-mv3-remote-code-loading-issue
Jan 15, 2025
Merged

fix(chrome-extension): Bundle @clerk/shared to properly tree-shake#4899
LekoArts merged 1 commit into
mainfrom
lekoarts/eco-300-chrome-web-store-rejection-mv3-remote-code-loading-issue

Conversation

@LekoArts

@LekoArts LekoArts commented Jan 15, 2025

Copy link
Copy Markdown
Contributor

Description

If you look at https://unpkg.com/browse/@clerk/[email protected]/dist/esm/index.js you'll see that we end up with:

import { setErrorThrowerOptions } from './chunk-BGR6KYCZ.js';
export { ... } from './chunk-BGR6KYCZ.js';
import './chunk-V7OWHRAI.js';
import '@clerk/shared/loadClerkJsScript';

setErrorThrowerOptions({ packageName: "@clerk/chrome-extension" });

The unused import '@clerk/shared/loadClerkJsScript'; is problematic because inside is "remotely hosted code" that the Chrome extension store is flagging. In #4551 build flags were added and they work. But the unused imports are not removed during bundling.

So the fix is to also mark @clerk/shared not external and bundle it. Then tsup seems to be able to remove those unused imports.

Fixes #4886

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:

@changeset-bot

changeset-bot Bot commented Jan 15, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8c6f91f

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

This PR includes changesets to release 1 package
Name Type
@clerk/chrome-extension 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 Jan 15, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 0:03am

@LekoArts

Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @LekoArts - the snapshot version command generated the following package versions:

Package Version
@clerk/astro 2.1.8-snapshot.v20250115120857
@clerk/backend 1.22.1-snapshot.v20250115120857
@clerk/chrome-extension 2.1.12-snapshot.v20250115120857
@clerk/clerk-js 5.44.1-snapshot.v20250115120857
@clerk/clerk-expo 2.6.11-snapshot.v20250115120857
@clerk/express 1.3.35-snapshot.v20250115120857
@clerk/fastify 2.1.8-snapshot.v20250115120857
@clerk/nextjs 6.9.11-snapshot.v20250115120857
@clerk/nuxt 1.0.4-snapshot.v20250115120857
@clerk/react-router 0.1.9-snapshot.v20250115120857
@clerk/remix 4.4.10-snapshot.v20250115120857
@clerk/tanstack-start 0.8.9-snapshot.v20250115120857
@clerk/testing 1.4.8-snapshot.v20250115120857
@clerk/vue 1.0.3-snapshot.v20250115120857

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/vue

npm i @clerk/[email protected] --save-exact

@LekoArts
LekoArts marked this pull request as ready for review January 15, 2025 12:17
@LekoArts

Copy link
Copy Markdown
Contributor Author

@anagstef anagstef left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chrome Web Store Rejection - MV3 Remote Code Loading Issue

4 participants