Skip to content

Commit d88197e

Browse files
committed
feat(clerk-js): Remove BroadcastChannel build variant
1 parent 36e43cc commit d88197e

File tree

8 files changed

+9
-41
lines changed

8 files changed

+9
-41
lines changed

integration/presets/envs.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,6 @@ const withEmailCodes = base
4242
.setEnvVariable('public', 'CLERK_PUBLISHABLE_KEY', instanceKeys.get('with-email-codes').pk)
4343
.setEnvVariable('private', 'CLERK_ENCRYPTION_KEY', constants.E2E_CLERK_ENCRYPTION_KEY || 'a-key');
4444

45-
const withBroadcastChannel = withEmailCodes
46-
.clone()
47-
.setId('withBroadcastChannel')
48-
.setEnvVariable(
49-
'public',
50-
'CLERK_JS_URL',
51-
constants.E2E_APP_CLERK_JS || 'http://localhost:18211/clerk.channel.browser.js',
52-
);
53-
5445
const sessionsProd1 = base
5546
.clone()
5647
.setId('sessionsProd1')
@@ -201,7 +192,6 @@ export const envs = {
201192
withAPCore2ClerkV4,
202193
withBilling,
203194
withBillingJwtV2,
204-
withBroadcastChannel,
205195
withCustomRoles,
206196
withDynamicKeys,
207197
withEmailCodes,

integration/tests/session-token-cache/single-session.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { createTestUtils, testAgainstRunningApps } from '../../testUtils';
1111
* token fetches in one tab are automatically broadcast and cached in other tabs,
1212
* eliminating redundant network requests.
1313
*/
14-
testAgainstRunningApps({ withEnv: [appConfigs.envs.withBroadcastChannel] })(
14+
testAgainstRunningApps({ withEnv: [appConfigs.envs.withEmailCodes] })(
1515
'MemoryTokenCache Multi-Tab Integration @generic',
1616
({ app }) => {
1717
test.describe.configure({ mode: 'serial' });

packages/clerk-js/bundlewatch.config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"files": [
33
{ "path": "./dist/clerk.js", "maxSize": "840KB" },
44
{ "path": "./dist/clerk.browser.js", "maxSize": "81KB" },
5-
{ "path": "./dist/clerk.channel.browser.js", "maxSize": "81KB" },
65
{ "path": "./dist/clerk.legacy.browser.js", "maxSize": "123KB" },
76
{ "path": "./dist/clerk.headless*.js", "maxSize": "65KB" },
87
{ "path": "./dist/ui-common*.js", "maxSize": "117.1KB" },

packages/clerk-js/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"bundlewatch:fix": "node bundlewatch-fix.mjs",
4343
"clean": "rimraf ./dist",
4444
"dev": "rspack serve --config rspack.config.js",
45-
"dev:channel": "rspack serve --config rspack.config.js --env variant=\"clerk.channel.browser\"",
4645
"dev:chips": "rspack serve --config rspack.config.js --env variant=\"clerk.chips.browser\"",
4746
"dev:headless": "rspack serve --config rspack.config.js --env variant=\"clerk.headless.browser\"",
4847
"dev:origin": "rspack serve --config rspack.config.js --env devOrigin=http://localhost:${PORT:-4000}",

packages/clerk-js/rspack.config.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const variants = {
1717
clerkHeadlessBrowser: 'clerk.headless.browser',
1818
clerkLegacyBrowser: 'clerk.legacy.browser',
1919
clerkCHIPS: 'clerk.chips.browser',
20-
clerkChannelBrowser: 'clerk.channel.browser',
2120
};
2221

2322
const variantToSourceFile = {
@@ -28,7 +27,6 @@ const variantToSourceFile = {
2827
[variants.clerkHeadlessBrowser]: './src/index.headless.browser.ts',
2928
[variants.clerkLegacyBrowser]: './src/index.legacy.browser.ts',
3029
[variants.clerkCHIPS]: './src/index.browser.ts',
31-
[variants.clerkChannelBrowser]: './src/index.browser.ts',
3230
};
3331

3432
/**
@@ -60,7 +58,6 @@ const common = ({ mode, variant, disableRHC = false }) => {
6058
*/
6159
__BUILD_FLAG_KEYLESS_UI__: isDevelopment(mode),
6260
__BUILD_DISABLE_RHC__: JSON.stringify(disableRHC),
63-
__BUILD_VARIANT_CHANNEL__: variant === variants.clerkChannelBrowser,
6461
__BUILD_VARIANT_CHIPS__: variant === variants.clerkCHIPS,
6562
}),
6663
new rspack.EnvironmentPlugin({
@@ -433,13 +430,6 @@ const prodConfig = ({ mode, env, analysis }) => {
433430
commonForProdChunked(),
434431
);
435432

436-
const clerkChannelBrowser = merge(
437-
entryForVariant(variants.clerkChannelBrowser),
438-
common({ mode, variant: variants.clerkChannelBrowser }),
439-
commonForProd(),
440-
commonForProdChunked(),
441-
);
442-
443433
const clerkEsm = merge(
444434
entryForVariant(variants.clerk),
445435
common({ mode, variant: variants.clerk }),
@@ -554,7 +544,6 @@ const prodConfig = ({ mode, env, analysis }) => {
554544
clerkHeadless,
555545
clerkHeadlessBrowser,
556546
clerkCHIPS,
557-
clerkChannelBrowser,
558547
clerkEsm,
559548
clerkEsmNoRHC,
560549
clerkCjs,
@@ -662,11 +651,6 @@ const devConfig = ({ mode, env }) => {
662651
common({ mode, variant: variants.clerkCHIPS }),
663652
commonForDev(),
664653
),
665-
[variants.clerkChannelBrowser]: merge(
666-
entryForVariant(variants.clerkChannelBrowser),
667-
common({ mode, variant: variants.clerkChannelBrowser }),
668-
commonForDev(),
669-
),
670654
};
671655

672656
if (!entryToConfigMap[variant]) {

packages/clerk-js/src/core/tokenCache.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const generateTabId = (): string => {
138138
/**
139139
* Creates an in-memory token cache with optional BroadcastChannel synchronization across tabs.
140140
* Automatically manages token expiration and cleanup via scheduled timeouts.
141-
* BroadcastChannel support is enabled only in the channel build variant.
141+
* BroadcastChannel support is enabled whenever the environment provides it.
142142
*/
143143
const MemoryTokenCache = (prefix = KEY_PREFIX): TokenCache => {
144144
const cache = new Map<string, TokenCacheValue>();
@@ -147,21 +147,19 @@ const MemoryTokenCache = (prefix = KEY_PREFIX): TokenCache => {
147147
let broadcastChannel: BroadcastChannel | null = null;
148148

149149
const ensureBroadcastChannel = (): BroadcastChannel | null => {
150-
if (!__BUILD_VARIANT_CHANNEL__) {
151-
return null;
152-
}
153-
154150
if (broadcastChannel) {
155151
return broadcastChannel;
156152
}
157153

158-
if (typeof BroadcastChannel !== 'undefined') {
159-
broadcastChannel = new BroadcastChannel('clerk:session_token');
160-
broadcastChannel.addEventListener('message', (e: MessageEvent<SessionTokenEvent>) => {
161-
void handleBroadcastMessage(e);
162-
});
154+
if (typeof BroadcastChannel === 'undefined') {
155+
return null;
163156
}
164157

158+
broadcastChannel = new BroadcastChannel('clerk:session_token');
159+
broadcastChannel.addEventListener('message', (e: MessageEvent<SessionTokenEvent>) => {
160+
void handleBroadcastMessage(e);
161+
});
162+
165163
return broadcastChannel;
166164
};
167165

packages/clerk-js/src/global.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ declare const __DEV__: boolean;
1111
* Build time feature flags.
1212
*/
1313
declare const __BUILD_DISABLE_RHC__: string;
14-
declare const __BUILD_VARIANT_CHANNEL__: boolean;
1514
declare const __BUILD_VARIANT_CHIPS__: boolean;
1615

1716
interface Window {

packages/clerk-js/vitest.config.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export default defineConfig({
2626
plugins: [react({ jsxRuntime: 'automatic', jsxImportSource: '@emotion/react' }), viteSvgMockPlugin()],
2727
define: {
2828
__BUILD_DISABLE_RHC__: JSON.stringify(false),
29-
__BUILD_VARIANT_CHANNEL__: JSON.stringify(true),
3029
__BUILD_VARIANT_CHIPS__: JSON.stringify(false),
3130
__PKG_NAME__: JSON.stringify('@clerk/clerk-js'),
3231
__PKG_VERSION__: JSON.stringify('test'),

0 commit comments

Comments
 (0)