-
Notifications
You must be signed in to change notification settings - Fork 364
feat(clerk-js): Introduce legacy browser variant #5495
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
Conversation
🦋 Changeset detectedLatest commit: a01916b The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 Git ↗︎
|
!snapshot |
Hey @dstaley - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact |
@@ -158,7 +160,13 @@ const typescriptLoaderProd = () => { | |||
loader: 'builtin:swc-loader', | |||
options: { | |||
env: { | |||
targets: packageJSON.browserslist, | |||
targets, | |||
...(useCoreJs |
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.
Because core-js
will inject polyfills even in our more modern targets, we only enable it when we know we're targeting legacy browsers.
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.
I'd argue that with this change we should also change our existing browserslist
entry and remove the legacy information (Safari > 12, iOS > 12
), write down the exact browsers we support in our docs, and set the browserslist
according to that
I absolutely agree with this, but it might break other customers who were relying on the transformations that SWC was applying to fit those targets. We're going to be discussing this more during the SDK Infra meeting this week to determine if we're okay accepting that. The current plan is to opt instances into the legacy bundle via CF worker, so we might be hesitant to suddenly break previously working browsers during a minor update. |
@@ -65,7 +68,7 @@ const common = ({ mode, disableRHC = false }) => { | |||
}), | |||
].filter(Boolean), | |||
output: { | |||
chunkFilename: `[name]_[fullhash:6]_${packageJSON.version}.js`, | |||
chunkFilename: `[name]_${variant}_[fullhash:6]_${packageJSON.version}.js`, |
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.
This is so that we can distinguish which variant a chunk belongs to, mainly so we could (in the future) target specific variant chunks with specific bundlewatch rules.
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.
Copilot reviewed 4 out of 7 changed files in this pull request and generated 1 comment.
Files not reviewed (3)
- packages/clerk-js/bundlewatch.config.json: Language not supported
- packages/clerk-js/package.json: Language not supported
- pnpm-lock.yaml: Language not supported
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.
Generally speaking LGTM, left one minor comment.
Did you test a current snapshot of the normal browser and legacy bundle to see that old and new behavior is OK?
It would also be good to start a docs PR (if not already done) to update our https://clerk.com/docs/upgrade-guides/long-term-support#library-compatibility page
Co-authored-by: Jacek Radko <[email protected]>
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.
Let's give it a whirl!
Description
This PR introduces a new
legacy
variant ofclerk.browser
, intended to be used for instances that require compatibility with browsers released in mid-2019 or newer. This is achieved through the use ofcore-js
, which polyfills modern JavaScript APIs, in addition to the language-level transformations provided by SWC.We now emit two primary
clerk.browser
bundles:clerk.browser.js
: This is our "modern"/default bundle that adheres to our browser support policy as specified bybrowserslist
inpackage.json
. This bundle includes language-level transformations for supported browsers, but does not includecore-js
polyfills. This is becausecore-js
will polyfill divergent behaviors between browsers, inflating our bundle size.clerk.legacy.browser.js
: This is our legacy bundle that adheres to the browser support policy specified bybrowserslistLegacy
inpackage.json
, which supports browsers released in mid-2019 and later. It includes language-level transformations from SWC in addition tocore-js
polyfills. It is an additional 35KB gzipped compared to the defaultclerk.browser.js
bundle.In addition to the bundles, we also emit separate chunks for the
legacy
variant.clerk.legacy.browser.js
will load legacy-compatible chunks, whereasclerk.browser.js
will load modern-compatible chunks.As of writing, it's not intended for customers to be able to manually switch to the
legacy
bundle since it's outside our official browser support matrix. We will be enabling this at the Cloudflare proxy level only for specific customers who have an agreement with us and a demonstrated need for legacy browser compatibility.Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change