Skip to content

Commit e75d2de

Browse files
authored
chore(astro): Remove dependency @clerk/clerk-js (clerk#3965)
1 parent 201be9b commit e75d2de

6 files changed

Lines changed: 23 additions & 7 deletions

File tree

.changeset/nine-shoes-hug.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@clerk/astro": patch
3+
---
4+
5+
Remove dependency `@clerk/clerk-js`.
6+
7+
Since clerk-js is being hotloaded it is unnecessary to keep the npm package as a dependency.

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/astro/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
},
8181
"dependencies": {
8282
"@clerk/backend": "1.6.3",
83-
"@clerk/clerk-js": "5.14.1",
8483
"@clerk/shared": "2.5.1",
8584
"@clerk/types": "4.13.1",
8685
"nanoid": "5.0.7",

packages/astro/src/internal/create-clerk-instance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function updateClerkOptions(options: AstroClerkUpdateOptions) {
7272
if (!clerk) {
7373
throw new Error('Missing clerk instance');
7474
}
75-
// TODO: Update Clerk type from @clerk/types to include this method
75+
// `__unstable__updateProps` is not exposed as public API from `@clerk/types`
7676
void (clerk as any).__unstable__updateProps({
7777
options: { ...initOptions, ...options },
7878
appearance: { ...initOptions?.appearance, ...options.appearance },

packages/astro/src/internal/run-once.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { Clerk } from '@clerk/clerk-js';
2-
31
import { invokeClerkAstroJSFunctions } from './invoke-clerk-astro-js-functions';
42
import { mountAllClerkAstroJSComponents } from './mount-clerk-astro-js-components';
53
import type { CreateClerkInstanceInternalFn } from './types';
@@ -12,7 +10,7 @@ const runOnce = (onFirst: CreateClerkInstanceInternalFn) => {
1210
let hasRun = false;
1311
return (params: Parameters<CreateClerkInstanceInternalFn>[0]) => {
1412
if (hasRun) {
15-
const clerkJSInstance = window.Clerk as Clerk;
13+
const clerkJSInstance = window.Clerk;
1614
return new Promise(res => {
1715
if (!clerkJSInstance) {
1816
return res(false);

packages/astro/src/types.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ClerkOptions, MultiDomainAndOrProxyPrimitives, Without } from '@clerk/types';
1+
import type { Clerk, ClerkOptions, ClientResource, MultiDomainAndOrProxyPrimitives, Without } from '@clerk/types';
22

33
type AstroClerkUpdateOptions = Pick<ClerkOptions, 'appearance' | 'localization'>;
44

@@ -18,10 +18,23 @@ type AstroClerkIntegrationParams = Without<
1818

1919
type AstroClerkCreateInstanceParams = AstroClerkIntegrationParams & { publishableKey: string };
2020

21+
// Copied from `@clerk/clerk-react`
22+
export interface HeadlessBrowserClerk extends Clerk {
23+
load: (opts?: Without<ClerkOptions, 'isSatellite'>) => Promise<void>;
24+
updateClient: (client: ClientResource) => void;
25+
}
26+
27+
// Copied from `@clerk/clerk-react`
28+
export interface BrowserClerk extends HeadlessBrowserClerk {
29+
onComponentsReady: Promise<void>;
30+
components: any;
31+
}
32+
2133
declare global {
2234
interface Window {
2335
__astro_clerk_component_props: Map<string, Map<string, Record<string, unknown>>>;
2436
__astro_clerk_function_props: Map<string, Map<string, Record<string, unknown>>>;
37+
Clerk: BrowserClerk;
2538
}
2639
}
2740

0 commit comments

Comments
 (0)