diff --git a/.changeset/free-knives-boil.md b/.changeset/free-knives-boil.md new file mode 100644 index 00000000000..445d628480a --- /dev/null +++ b/.changeset/free-knives-boil.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Remove Stripe from non-RHC build diff --git a/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx b/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx index a727d392159..e27764ea33e 100644 --- a/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx +++ b/packages/clerk-js/src/ui/components/PaymentSources/AddPaymentSource.tsx @@ -10,6 +10,7 @@ import type { Appearance as StripeAppearance, Stripe } from '@stripe/stripe-js'; import { loadStripe } from '@stripe/stripe-js'; import { useEffect, useRef, useState } from 'react'; +import { clerkUnsupportedEnvironmentWarning } from '../../../core/errors'; import { useEnvironment, usePaymentSourcesContext } from '../../contexts'; import { descriptors, Flex, localizationKeys, Spinner, useAppearance } from '../../customizables'; import { Alert, Form, FormButtons, FormContainer, withCardStateProvider } from '../../elements'; @@ -74,12 +75,16 @@ export const AddPaymentSource = (props: AddPaymentSourceProps) => { useEffect(() => { if (!stripePromiseRef.current && externalGatewayId && __experimental_commerceSettings.stripePublishableKey) { - stripePromiseRef.current = loadStripe(__experimental_commerceSettings.stripePublishableKey, { - stripeAccount: externalGatewayId, - }); - void stripePromiseRef.current.then(stripeInstance => { - setStripe(stripeInstance); - }); + if (!__BUILD_DISABLE_RHC__) { + stripePromiseRef.current = loadStripe(__experimental_commerceSettings.stripePublishableKey, { + stripeAccount: externalGatewayId, + }); + void stripePromiseRef.current.then(stripeInstance => { + setStripe(stripeInstance); + }); + } else { + clerkUnsupportedEnvironmentWarning('Stripe'); + } } }, [externalGatewayId, __experimental_commerceSettings]); diff --git a/scripts/search-for-rhc.mjs b/scripts/search-for-rhc.mjs index 8721f02c75d..68222fa423e 100644 --- a/scripts/search-for-rhc.mjs +++ b/scripts/search-for-rhc.mjs @@ -27,6 +27,7 @@ await Promise.allSettled([ asyncSearchRHC('Turnstile', 'cloudflare.com/turnstile/v0/api.js'), asyncSearchRHC('clerk-js Hotloading', '/npm/@clerk/clerk-js'), asyncSearchRHC('Google One Tap', 'accounts.google.com/gsi/client'), + asyncSearchRHC('Stripe', 'loadStripe('), ]).then(results => { const errors = results.filter(result => result.status === 'rejected').map(result => result.reason.message);