-
Notifications
You must be signed in to change notification settings - Fork 330
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
feat(clerk-js): Introduce legacy browser variant #5495
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 1b53f83 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.
], | ||
optimization: { | ||
splitChunks: false, | ||
const clerkEsm = merge( |
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.
none of this was actually changed, it's just a formatting thing
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.
Where does the formatting change come from then? Your personal prettier settings? If I open the file in my editor ESLint doesn't want to format the file.
Ideally such unintended formatting changes don't make it into the PR as it's quite possible that another PR will undo them later again.
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.
Previously Prettier kept everything on one line since it was below our max line length threshold. Since the line is longer (due to the inclusion of the { targets: packageJSON.browserslist }
argument), it splits the arguments to merge
into separate lines. This confuses the GitHub diff formatter into thinking the lines have changed due to how the final argument to merge
is now indented. So this is Prettier working as expected! I just wanted to make sure folks weren't struggling to find the difference between the two :)
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
], | ||
optimization: { | ||
splitChunks: false, | ||
const clerkEsm = merge( |
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.
Where does the formatting change come from then? Your personal prettier settings? If I open the file in my editor ESLint doesn't want to format the file.
Ideally such unintended formatting changes don't make it into the PR as it's quite possible that another PR will undo them later again.
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. |
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, although they're not differentiated by filename.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