From 11947c657524c441f106ccca2b7c10f38afb97aa Mon Sep 17 00:00:00 2001 From: ChrisCanin Date: Thu, 6 Nov 2025 10:12:31 -0800 Subject: [PATCH 1/4] fix(expo): Resolve module loading issue for optional Sign in with Apple --- .changeset/fix-expo-apple-auth-optional.md | 5 +++++ packages/expo/package.json | 2 +- packages/expo/src/hooks/useSignInWithApple.ios.ts | 15 +++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .changeset/fix-expo-apple-auth-optional.md diff --git a/.changeset/fix-expo-apple-auth-optional.md b/.changeset/fix-expo-apple-auth-optional.md new file mode 100644 index 00000000000..cd56e8e3c87 --- /dev/null +++ b/.changeset/fix-expo-apple-auth-optional.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-expo': patch +--- + +Fix module resolution error for users not using Sign in with Apple. Remove static imports of expo-apple-authentication and expo-crypto, replacing them with dynamic imports that only load when the useSignInWithApple hook is actually called. diff --git a/packages/expo/package.json b/packages/expo/package.json index 04655da30a0..8b4535348a9 100644 --- a/packages/expo/package.json +++ b/packages/expo/package.json @@ -1,6 +1,6 @@ { "name": "@clerk/clerk-expo", - "version": "2.18.2", + "version": "2.18.3", "description": "Clerk React Native/Expo library", "keywords": [ "react", diff --git a/packages/expo/src/hooks/useSignInWithApple.ios.ts b/packages/expo/src/hooks/useSignInWithApple.ios.ts index 36be6034000..ccb5683bdd4 100644 --- a/packages/expo/src/hooks/useSignInWithApple.ios.ts +++ b/packages/expo/src/hooks/useSignInWithApple.ios.ts @@ -1,7 +1,5 @@ import { useSignIn, useSignUp } from '@clerk/clerk-react'; import type { SetActive, SignInResource, SignUpResource } from '@clerk/types'; -import * as AppleAuthentication from 'expo-apple-authentication'; -import * as Crypto from 'expo-crypto'; import { errorThrower } from '../utils/errors'; @@ -69,6 +67,19 @@ export function useSignInWithApple() { }; } + // Dynamically import expo-apple-authentication only when needed + let AppleAuthentication; + let Crypto; + + try { + [AppleAuthentication, Crypto] = await Promise.all([import('expo-apple-authentication'), import('expo-crypto')]); + } catch (error) { + return errorThrower.throw( + 'expo-apple-authentication is required to use Sign in with Apple. ' + + 'Please install it by running: npx expo install expo-apple-authentication expo-crypto', + ); + } + // Check if Apple Authentication is available on the device const isAvailable = await AppleAuthentication.isAvailableAsync(); if (!isAvailable) { From 063089f90ef1ee99e135f8f8798e88dff3156284 Mon Sep 17 00:00:00 2001 From: ChrisCanin Date: Thu, 6 Nov 2025 10:40:43 -0800 Subject: [PATCH 2/4] Revert version number bump. System will take care of this automatically. --- packages/expo/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/expo/package.json b/packages/expo/package.json index 8b4535348a9..04655da30a0 100644 --- a/packages/expo/package.json +++ b/packages/expo/package.json @@ -1,6 +1,6 @@ { "name": "@clerk/clerk-expo", - "version": "2.18.3", + "version": "2.18.2", "description": "Clerk React Native/Expo library", "keywords": [ "react", From 7cc7ef6534d73584612a4d2df1f474e5718ed131 Mon Sep 17 00:00:00 2001 From: Christopher Canin Date: Thu, 6 Nov 2025 10:43:11 -0800 Subject: [PATCH 3/4] Update .changeset/fix-expo-apple-auth-optional.md Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com> --- .changeset/fix-expo-apple-auth-optional.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/fix-expo-apple-auth-optional.md b/.changeset/fix-expo-apple-auth-optional.md index cd56e8e3c87..82cc52983c5 100644 --- a/.changeset/fix-expo-apple-auth-optional.md +++ b/.changeset/fix-expo-apple-auth-optional.md @@ -2,4 +2,4 @@ '@clerk/clerk-expo': patch --- -Fix module resolution error for users not using Sign in with Apple. Remove static imports of expo-apple-authentication and expo-crypto, replacing them with dynamic imports that only load when the useSignInWithApple hook is actually called. +Fix module resolution error for users not using Sign in with Apple by removing static imports of `expo-apple-authentication` and `expo-crypto`, replacing them with dynamic imports that only load when the `useSignInWithApple()` hook is actually called. From d2a23140b3dc6f3e36a4a7bce248f468956b560a Mon Sep 17 00:00:00 2001 From: ChrisCanin Date: Thu, 6 Nov 2025 10:51:23 -0800 Subject: [PATCH 4/4] fix(useSignInWithApple): Improve error handling for module imports --- packages/expo/src/hooks/useSignInWithApple.ios.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/expo/src/hooks/useSignInWithApple.ios.ts b/packages/expo/src/hooks/useSignInWithApple.ios.ts index ccb5683bdd4..2c0d59a1ef9 100644 --- a/packages/expo/src/hooks/useSignInWithApple.ios.ts +++ b/packages/expo/src/hooks/useSignInWithApple.ios.ts @@ -73,7 +73,7 @@ export function useSignInWithApple() { try { [AppleAuthentication, Crypto] = await Promise.all([import('expo-apple-authentication'), import('expo-crypto')]); - } catch (error) { + } catch { return errorThrower.throw( 'expo-apple-authentication is required to use Sign in with Apple. ' + 'Please install it by running: npx expo install expo-apple-authentication expo-crypto',