Uh oh!
There was an error while loading. Please reload this page.
fix(shared): Preserve import.meta without requiring ES2020 target - #5203
fix(shared): Preserve import.meta without requiring ES2020 target#5203wobsoriano wants to merge 8 commits into
import.meta without requiring ES2020 target#5203Conversation
🦋 Changeset detectedLatest commit: 322f1b6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 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 ↗︎
|
wobsoriano
commented
Feb 20, 2025
!snapshot |
clerk-cookie
commented
Feb 20, 2025
Hey @wobsoriano - 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/agent-toolkit@0.0.4-snapshot.v20250220050105 --save-exact
npm i @clerk/astro@2.3.0-snapshot.v20250220050105 --save-exact
npm i @clerk/backend@1.24.3-snapshot.v20250220050105 --save-exact
npm i @clerk/chrome-extension@2.2.11-snapshot.v20250220050105 --save-exact
npm i @clerk/clerk-js@5.54.0-snapshot.v20250220050105 --save-exact
npm i @clerk/elements@0.23.0-snapshot.v20250220050105 --save-exact
npm i @clerk/clerk-expo@2.8.0-snapshot.v20250220050105 --save-exact
npm i @clerk/expo-passkeys@0.1.22-snapshot.v20250220050105 --save-exact
npm i @clerk/express@1.3.50-snapshot.v20250220050105 --save-exact
npm i @clerk/fastify@2.1.23-snapshot.v20250220050105 --save-exact
npm i @clerk/localizations@3.10.8-snapshot.v20250220050105 --save-exact
npm i @clerk/nextjs@6.12.1-snapshot.v20250220050105 --save-exact
npm i @clerk/nuxt@1.2.1-snapshot.v20250220050105 --save-exact
npm i @clerk/clerk-react@5.24.0-snapshot.v20250220050105 --save-exact
npm i @clerk/react-router@1.1.1-snapshot.v20250220050105 --save-exact
npm i @clerk/remix@4.5.1-snapshot.v20250220050105 --save-exact
npm i @clerk/shared@2.23.0-snapshot.v20250220050105 --save-exact
npm i @clerk/tanstack-start@0.10.1-snapshot.v20250220050105 --save-exact
npm i @clerk/testing@1.4.24-snapshot.v20250220050105 --save-exact
npm i @clerk/themes@2.2.20-snapshot.v20250220050105 --save-exact
npm i @clerk/types@4.47.0-snapshot.v20250220050105 --save-exact
npm i @clerk/ui@0.3.25-snapshot.v20250220050105 --save-exact
npm i @clerk/vue@1.3.0-snapshot.v20250220050105 --save-exact |
| const text = new TextDecoder().decode(contents); | ||
| // Remove esbuild's var import_meta = {} transformation and restore original import.meta references | ||
| const modified = text.replace(/var\s+import_meta\s*=\s*{};/g, '').replace(/import_meta/g, 'import.meta'); |
There was a problem hiding this comment.
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@clerk/shared": minor | |||
There was a problem hiding this comment.
Since we're removing the target...
wobsoriano
commented
Feb 20, 2025
Closing this as we want to keep the state of the shared package and fix the issue in clerk-js side instead |

Description
In #4985, we introduced a shared function that checks if environment variables exist across different platforms (Node.js, Vite, Cloudflare, etc). To support Vite's
import.meta.env, we set the build target toES2020, but this broke support for older browsers due to ES2020 features like optional chaining.This PR removes the added ES2020 target, but preserves the
import.metafunctionality via a plugin. The plugin removes esbuild'svar import_meta = {}transformation and restores the originalimport.metareferences in ESM builds only, while maintaining compatibility with older browsers.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change