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
7 changes: 7 additions & 0 deletions .changeset/nine-shoes-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@clerk/astro": patch
---

Remove dependency `@clerk/clerk-js`.

Since clerk-js is being hotloaded it is unnecessary to keep the npm package as a dependency.
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
},
"dependencies": {
"@clerk/backend": "1.6.3",
"@clerk/clerk-js": "5.14.1",
"@clerk/shared": "2.5.1",
"@clerk/types": "4.13.1",
"nanoid": "5.0.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/internal/create-clerk-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function updateClerkOptions(options: AstroClerkUpdateOptions) {
if (!clerk) {
throw new Error('Missing clerk instance');
}
// TODO: Update Clerk type from @clerk/types to include this method
// `__unstable__updateProps` is not exposed as public API from `@clerk/types`
void (clerk as any).__unstable__updateProps({
options: { ...initOptions, ...options },
appearance: { ...initOptions?.appearance, ...options.appearance },
Expand Down
4 changes: 1 addition & 3 deletions packages/astro/src/internal/run-once.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { Clerk } from '@clerk/clerk-js';

import { invokeClerkAstroJSFunctions } from './invoke-clerk-astro-js-functions';
import { mountAllClerkAstroJSComponents } from './mount-clerk-astro-js-components';
import type { CreateClerkInstanceInternalFn } from './types';
Expand All @@ -12,7 +10,7 @@ const runOnce = (onFirst: CreateClerkInstanceInternalFn) => {
let hasRun = false;
return (params: Parameters<CreateClerkInstanceInternalFn>[0]) => {
if (hasRun) {
const clerkJSInstance = window.Clerk as Clerk;
const clerkJSInstance = window.Clerk;
return new Promise(res => {
if (!clerkJSInstance) {
return res(false);
Expand Down
15 changes: 14 additions & 1 deletion packages/astro/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ClerkOptions, MultiDomainAndOrProxyPrimitives, Without } from '@clerk/types';
import type { Clerk, ClerkOptions, ClientResource, MultiDomainAndOrProxyPrimitives, Without } from '@clerk/types';

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

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

type AstroClerkCreateInstanceParams = AstroClerkIntegrationParams & { publishableKey: string };

// Copied from `@clerk/clerk-react`
export interface HeadlessBrowserClerk extends Clerk {
load: (opts?: Without<ClerkOptions, 'isSatellite'>) => Promise<void>;
updateClient: (client: ClientResource) => void;
}

// Copied from `@clerk/clerk-react`
export interface BrowserClerk extends HeadlessBrowserClerk {
onComponentsReady: Promise<void>;
components: any;
}

declare global {
interface Window {
__astro_clerk_component_props: Map<string, Map<string, Record<string, unknown>>>;
__astro_clerk_function_props: Map<string, Map<string, Record<string, unknown>>>;
Clerk: BrowserClerk;
}
}

Expand Down