Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shared): load clerk-js@v4 in interstitial #2180

Merged
merged 6 commits into from
Nov 22, 2023
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
5 changes: 5 additions & 0 deletions .changeset/good-llamas-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/shared": patch
---

Ensure that the interstitial page loads clerk-js@v4.
5 changes: 5 additions & 0 deletions .changeset/rich-crabs-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/shared': patch
---

Ensure the interstitial loads a clerk-js version that matches the current major version.
1 change: 1 addition & 0 deletions packages/shared/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export {};

declare global {
const CLERK_JS_PACKAGE_VERSION: string;
const PACKAGE_VERSION: string;
const __DEV__: boolean;
}
4 changes: 4 additions & 0 deletions packages/shared/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const config = {
displayName: 'shared',
injectGlobals: true,

globals: {
CLERK_JS_PACKAGE_VERSION: '4.0.0-test',
},

testEnvironment: 'jsdom',
roots: ['<rootDir>/src'],
setupFiles: ['./jest.setup.ts'],
Expand Down
10 changes: 2 additions & 8 deletions packages/shared/src/__tests__/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,13 @@ describe('getScriptUrl', () => {
);
});

it('returns URL using the latest version if clerkJSVersion & pkgVersion is not provided + frontendApi is not staging', () => {
expect(getScriptUrl(frontendApi, {})).toBe('https://foobar.dev/npm/@clerk/clerk-js@latest/dist/clerk.browser.js');
it('returns URL using the major version if clerkJSVersion & pkgVersion is not provided + frontendApi is not staging', () => {
expect(getScriptUrl(frontendApi, {})).toBe('https://foobar.dev/npm/@clerk/clerk-js@4/dist/clerk.browser.js');
});

it('returns URL using the major version if only pkgVersion is provided', () => {
expect(getScriptUrl(frontendApi, { pkgVersion: '1.2.3' })).toBe(
'https://foobar.dev/npm/@clerk/clerk-js@1/dist/clerk.browser.js',
);
});

it('returns URL using the canary tag if frontendApi is staging', () => {
expect(getScriptUrl('https://foobar.lclstage.dev', {})).toBe(
'https://foobar.lclstage.dev/npm/@clerk/clerk-js@canary/dist/clerk.browser.js',
);
});
});
2 changes: 1 addition & 1 deletion packages/shared/src/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const getClerkJsMajorVersionOrTag = (frontendApi: string, pkgVersion?: st
*/
export const getScriptUrl = (
frontendApi: string,
{ pkgVersion, clerkJSVersion }: { pkgVersion?: string; clerkJSVersion?: string },
{ pkgVersion = CLERK_JS_PACKAGE_VERSION, clerkJSVersion }: { pkgVersion?: string; clerkJSVersion?: string },
) => {
const noSchemeFrontendApi = frontendApi.replace(/http(s)?:\/\//, '');
const major = getClerkJsMajorVersionOrTag(frontendApi, pkgVersion);
Expand Down
4 changes: 3 additions & 1 deletion packages/shared/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { transform } from 'esbuild';
import { readFile } from 'fs/promises';
import { defineConfig } from 'tsup';

import { version as clerkJsVersion } from '../clerk-js/package.json';
import { name, version } from './package.json';

export default defineConfig(overrideOptions => {
Expand All @@ -17,8 +18,9 @@ export default defineConfig(overrideOptions => {
sourcemap: true,
dts: true,
external: ['react', 'react-dom'],
esbuildPlugins: [WebWorkerMinifyPlugin as any],
esbuildPlugins: [WebWorkerMinifyPlugin],
define: {
CLERK_JS_PACKAGE_VERSION: `"${clerkJsVersion}"`,
PACKAGE_NAME: `"${name}"`,
PACKAGE_VERSION: `"${version}"`,
__DEV__: `${isWatch}`,
Expand Down
Loading