Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/poor-balloons-pretend.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion packages/backend/src/tokens/jwt/cryptoKeys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isomorphicAtob } from '@clerk/shared';
import { isomorphicAtob } from '@clerk/shared/isomorphicAtob';

import runtime from '../../runtime';

Expand Down
14 changes: 4 additions & 10 deletions packages/backend/src/util/shared.ts
Original file line number Diff line number Diff line change
@@ -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();
3 changes: 2 additions & 1 deletion packages/nextjs/src/server/utils.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/contexts/ClerkProvider.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/isomorphicClerk.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/utils/isDevOrStageUrl.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createDevOrStagingUrlCache } from '@clerk/shared';
import { createDevOrStagingUrlCache } from '@clerk/shared/keys';
const { isDevOrStagingUrl } = createDevOrStagingUrlCache();
export { isDevOrStagingUrl };
7 changes: 5 additions & 2 deletions packages/react/src/utils/loadClerkJsScript.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -12,7 +15,7 @@ type LoadClerkJsScriptOptions = Omit<IsomorphicClerkOptions, 'proxyUrl' | 'domai
domain: string;
};

export const loadClerkJsScript = async (opts: LoadClerkJsScriptOptions) => {
export const loadClerkJsScript = (opts: LoadClerkJsScriptOptions) => {
const { frontendApi, publishableKey } = opts;

if (!publishableKey && !frontendApi) {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
8 changes: 8 additions & 0 deletions packages/shared/src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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_');
}
3 changes: 1 addition & 2 deletions packages/shared/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -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';
8 changes: 0 additions & 8 deletions packages/shared/src/utils/instance.ts
Original file line number Diff line number Diff line change
@@ -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') ||
Expand Down