diff --git a/.changeset/poor-balloons-pretend.md b/.changeset/poor-balloons-pretend.md new file mode 100644 index 0000000000..51964faade --- /dev/null +++ b/.changeset/poor-balloons-pretend.md @@ -0,0 +1,8 @@ +--- +'@clerk/backend': patch +'@clerk/nextjs': patch +'@clerk/shared': patch +'@clerk/clerk-react': patch +--- + +Update imports of `@clerk/shared` to granular entrypoints. This addresses warnings during a Next.js build that are the result of unsupported APIs being included in the module graph of builds for the edge runtime. diff --git a/packages/backend/src/tokens/jwt/cryptoKeys.ts b/packages/backend/src/tokens/jwt/cryptoKeys.ts index 1223c7eb58..ae4e3caa1b 100644 --- a/packages/backend/src/tokens/jwt/cryptoKeys.ts +++ b/packages/backend/src/tokens/jwt/cryptoKeys.ts @@ -1,4 +1,4 @@ -import { isomorphicAtob } from '@clerk/shared'; +import { isomorphicAtob } from '@clerk/shared/isomorphicAtob'; import runtime from '../../runtime'; diff --git a/packages/backend/src/util/shared.ts b/packages/backend/src/util/shared.ts index 1b4d09e38a..becfd5f28e 100644 --- a/packages/backend/src/util/shared.ts +++ b/packages/backend/src/util/shared.ts @@ -1,17 +1,11 @@ -export { - addClerkPrefix, - callWithRetry, - getClerkJsMajorVersionOrTag, - getScriptUrl, - isDevelopmentFromApiKey, - isProductionFromApiKey, - parsePublishableKey, -} from '@clerk/shared'; +export { addClerkPrefix, getScriptUrl, getClerkJsMajorVersionOrTag } from '@clerk/shared/url'; +export { callWithRetry } from '@clerk/shared/callWithRetry'; +export { isDevelopmentFromApiKey, isProductionFromApiKey, parsePublishableKey } from '@clerk/shared/keys'; export { deprecated, deprecatedProperty } from '@clerk/shared/deprecated'; import { buildErrorThrower } from '@clerk/shared/error'; // TODO: replace packageName with `${PACKAGE_NAME}@${PACKAGE_VERSION}` from tsup.config.ts export const errorThrower = buildErrorThrower({ packageName: '@clerk/backend' }); -import { createDevOrStagingUrlCache } from '@clerk/shared'; +import { createDevOrStagingUrlCache } from '@clerk/shared/keys'; export const { isDevOrStagingUrl } = createDevOrStagingUrlCache(); diff --git a/packages/nextjs/src/server/utils.ts b/packages/nextjs/src/server/utils.ts index 14df666c6b..37080d720e 100644 --- a/packages/nextjs/src/server/utils.ts +++ b/packages/nextjs/src/server/utils.ts @@ -1,6 +1,7 @@ import type { RequestState } from '@clerk/backend'; import { buildRequestUrl, constants } from '@clerk/backend'; -import { handleValueOrFn, isHttpOrHttps } from '@clerk/shared'; +import { handleValueOrFn } from '@clerk/shared/handleValueOrFn'; +import { isHttpOrHttps } from '@clerk/shared/proxy'; import type { NextRequest } from 'next/server'; import { NextResponse } from 'next/server'; diff --git a/packages/react/src/contexts/ClerkProvider.tsx b/packages/react/src/contexts/ClerkProvider.tsx index d8f2a4bceb..8495ed4c77 100644 --- a/packages/react/src/contexts/ClerkProvider.tsx +++ b/packages/react/src/contexts/ClerkProvider.tsx @@ -1,4 +1,4 @@ -import { isLegacyFrontendApiKey, isPublishableKey } from '@clerk/shared'; +import { isLegacyFrontendApiKey, isPublishableKey } from '@clerk/shared/keys'; import type { InitialState } from '@clerk/types'; import React from 'react'; diff --git a/packages/react/src/isomorphicClerk.ts b/packages/react/src/isomorphicClerk.ts index 6e157a937f..9a30c028fe 100644 --- a/packages/react/src/isomorphicClerk.ts +++ b/packages/react/src/isomorphicClerk.ts @@ -1,4 +1,6 @@ -import { deprecated, handleValueOrFn, inBrowser } from '@clerk/shared'; +import { inBrowser } from '@clerk/shared/browser'; +import { deprecated } from '@clerk/shared/deprecated'; +import { handleValueOrFn } from '@clerk/shared/handleValueOrFn'; import type { ActiveSessionResource, AuthenticateWithMetamaskParams, diff --git a/packages/react/src/utils/isDevOrStageUrl.tsx b/packages/react/src/utils/isDevOrStageUrl.tsx index d30d9d5266..835eceeb71 100644 --- a/packages/react/src/utils/isDevOrStageUrl.tsx +++ b/packages/react/src/utils/isDevOrStageUrl.tsx @@ -1,3 +1,3 @@ -import { createDevOrStagingUrlCache } from '@clerk/shared'; +import { createDevOrStagingUrlCache } from '@clerk/shared/keys'; const { isDevOrStagingUrl } = createDevOrStagingUrlCache(); export { isDevOrStagingUrl }; diff --git a/packages/react/src/utils/loadClerkJsScript.ts b/packages/react/src/utils/loadClerkJsScript.ts index 1ce63f52eb..ff75bd09d8 100644 --- a/packages/react/src/utils/loadClerkJsScript.ts +++ b/packages/react/src/utils/loadClerkJsScript.ts @@ -1,4 +1,7 @@ -import { addClerkPrefix, isValidProxyUrl, loadScript, parsePublishableKey, proxyUrlToAbsoluteURL } from '@clerk/shared'; +import { parsePublishableKey } from '@clerk/shared/keys'; +import { loadScript } from '@clerk/shared/loadScript'; +import { isValidProxyUrl, proxyUrlToAbsoluteURL } from '@clerk/shared/proxy'; +import { addClerkPrefix } from '@clerk/shared/url'; import type { IsomorphicClerkOptions } from '../types'; import { errorThrower } from './errorThrower'; @@ -12,7 +15,7 @@ type LoadClerkJsScriptOptions = Omit { +export const loadClerkJsScript = (opts: LoadClerkJsScriptOptions) => { const { frontendApi, publishableKey } = opts; if (!publishableKey && !frontendApi) { diff --git a/packages/shared/src/utils/callWithRetry.ts b/packages/shared/src/callWithRetry.ts similarity index 100% rename from packages/shared/src/utils/callWithRetry.ts rename to packages/shared/src/callWithRetry.ts diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index f572339a09..b5d8d07b76 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -12,6 +12,7 @@ export * from './utils'; export { createWorkerTimers } from './workerTimers'; export * from './browser'; +export { callWithRetry } from './callWithRetry'; export * from './color'; export * from './date'; export * from './deprecated'; diff --git a/packages/shared/src/keys.ts b/packages/shared/src/keys.ts index 73611cc6a9..d2f4848f12 100644 --- a/packages/shared/src/keys.ts +++ b/packages/shared/src/keys.ts @@ -86,3 +86,11 @@ export function createDevOrStagingUrlCache() { }, }; } + +export function isDevelopmentFromApiKey(apiKey: string): boolean { + return apiKey.startsWith('test_') || apiKey.startsWith('sk_test_'); +} + +export function isProductionFromApiKey(apiKey: string): boolean { + return apiKey.startsWith('live_') || apiKey.startsWith('sk_live_'); +} diff --git a/packages/shared/src/utils/index.ts b/packages/shared/src/utils/index.ts index 8d2ae051ce..7e6dcec81b 100644 --- a/packages/shared/src/utils/index.ts +++ b/packages/shared/src/utils/index.ts @@ -1,6 +1,5 @@ -export { callWithRetry } from './callWithRetry'; export * from './createDeferredPromise'; -export { isDevelopmentFromApiKey, isProductionFromApiKey, isStaging } from './instance'; +export { isStaging } from './instance'; export { noop } from './noop'; export * from './runtimeEnvironment'; export * from './runWithExponentialBackOff'; diff --git a/packages/shared/src/utils/instance.ts b/packages/shared/src/utils/instance.ts index 16e36e8710..5441634f48 100644 --- a/packages/shared/src/utils/instance.ts +++ b/packages/shared/src/utils/instance.ts @@ -1,11 +1,3 @@ -export function isDevelopmentFromApiKey(apiKey: string): boolean { - return apiKey.startsWith('test_') || apiKey.startsWith('sk_test_'); -} - -export function isProductionFromApiKey(apiKey: string): boolean { - return apiKey.startsWith('live_') || apiKey.startsWith('sk_live_'); -} - export function isStaging(frontendApi: string): boolean { return ( frontendApi.endsWith('.lclstage.dev') ||