fix(expo): prevent crash when importing @clerk/expo in web environments#8066
fix(expo): prevent crash when importing @clerk/expo in web environments#8066chriscanin wants to merge 3 commits intomainfrom
Conversation
Add .web.ts variants for NativeClerkModule spec and polyfills so the bundler skips TurboModuleRegistry and react-native-url-polyfill on web.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: a4f23d2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA patch is being introduced to address web crashes in the Clerk Expo package. The changes include adding a new changelog entry documenting the fix, creating a new web-specific polyfills file that indicates no polyfills are required in web environments, and modifying the NativeClerkModule to use optional chaining and nullish coalescing when accessing the TurboModuleRegistry, allowing it to return null when the registry is unavailable rather than throwing an error. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
Replace .web.ts approach with optional chaining in the original spec file. This avoids TypeScript build issues from moduleSuffixes while still preventing the crash when TurboModuleRegistry is undefined on web.
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |


Summary
@clerk/expocrashing withCannot read properties of undefined (reading 'get')when used in Expo web environmentsTurboModuleRegistryfromreact-nativeisundefinedon web (react-native-web), andNativeClerkModule.tscallsTurboModuleRegistry.get('ClerkExpo')at module evaluation time — before any runtime guards can protect against it.web.tsvariants forNativeClerkModule(exportsnull) and polyfills (empty — browsers have native URL and base64), following the existing pattern used bysingleton.web.tsError:
Uncaught Error: Cannot read properties of undefined (reading 'get')atNativeClerkModule.jsTest plan
@clerk/expono longer crashes when bundled for web (Expo web / react-native-web)TurboModuleRegistry.get()still runs on native via the original.tsfileuseSignIn,useSSO,useAuth) work correctly on webSummary by CodeRabbit