Skip to content

Commit 0a96e64

Browse files
committed
fix(clerk-js): Fix chunk loading
1 parent 4129a1a commit 0a96e64

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

packages/clerk-js/bundle-check.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from 'node:path';
55
import { pipeline } from 'node:stream';
66
import zlib from 'node:zlib';
77

8-
import { chromium } from 'playwright';
8+
import { chromium } from '@playwright/test';
99

1010
/**
1111
* This script generates a CLI report detailing the gzipped size of JavaScript resources loaded by `clerk-js` for a
@@ -212,7 +212,7 @@ function report(url, responses) {
212212

213213
/**
214214
* Loads the given `url` in `browser`, capturing all HTTP requests that occur.
215-
* @param {import('playwright').Browser} browser
215+
* @param {import('@playwright/test').Browser} browser
216216
* @param {string} url
217217
*/
218218
async function getResponseSizes(browser, url) {

packages/clerk-js/bundlewatch.config.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"files": [
33
{ "path": "./dist/clerk.js", "maxSize": "918KB" },
4-
{ "path": "./dist/clerk.browser.js", "maxSize": "81KB" },
5-
{ "path": "./dist/clerk.channel.browser.js", "maxSize": "81KB" },
6-
{ "path": "./dist/clerk.legacy.browser.js", "maxSize": "123KB" },
4+
{ "path": "./dist/clerk.browser.js", "maxSize": "84KB" },
5+
{ "path": "./dist/clerk.channel.browser.js", "maxSize": "85KB" },
6+
{ "path": "./dist/clerk.legacy.browser.js", "maxSize": "125KB" },
77
{ "path": "./dist/clerk.headless*.js", "maxSize": "65KB" },
88
{ "path": "./dist/ui-common*.js", "maxSize": "119KB" },
99
{ "path": "./dist/ui-common*.legacy.*.js", "maxSize": "122KB" },
10-
{ "path": "./dist/vendors*.js", "maxSize": "47KB" },
10+
{ "path": "./dist/vendors*.js", "maxSize": "50KB" },
1111
{ "path": "./dist/coinbase*.js", "maxSize": "38KB" },
1212
{ "path": "./dist/stripe-vendors*.js", "maxSize": "1KB" },
1313
{ "path": "./dist/createorganization*.js", "maxSize": "5KB" },

packages/clerk-js/rspack.config.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,22 @@ const common = ({ mode, variant, disableRHC = false }) => {
150150
},
151151
defaultVendors: {
152152
minChunks: 1,
153-
test: /[\\/]node_modules[\\/]/,
153+
test: module => {
154+
if (!(module instanceof rspack.NormalModule) || !module.resource) {
155+
return false;
156+
}
157+
// Exclude Solana packages and their known transitive dependencies
158+
if (
159+
/[\\/]node_modules[\\/](@solana|@solana-mobile|@wallet-standard|bn\.js|borsh|buffer|superstruct|bs58|jayson|rpc-websockets|qrcode)[\\/]/.test(
160+
module.resource,
161+
)
162+
) {
163+
return false;
164+
}
165+
return /[\\/]node_modules[\\/]/.test(module.resource);
166+
},
154167
name: 'vendors',
155168
priority: -10,
156-
/**
157-
* Only apply to initial chunks. Dependencies used exclusively by async chunks
158-
* (like Solana packages and their transitive deps) will be bundled with those
159-
* async chunks instead of being forced into the shared vendors bundle.
160-
*
161-
* This ensures that lazy-loaded features (like Web3 wallet support) don't
162-
* bloat the initial bundle, and their dependencies are automatically
163-
* code-split without needing explicit configuration.
164-
*/
165-
chunks: 'initial',
166169
},
167170
react: {
168171
chunks: 'all',

packages/clerk-js/src/ui/components/SignIn/SignInFactorOneSolanaWalletsCard.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { Header } from '@/ui/elements/Header';
1010
import { web3CallbackErrorHandler } from '@/ui/utils/web3CallbackErrorHandler';
1111

1212
const Web3WalletButtons = lazy(() =>
13-
import('@/ui/elements/Web3WalletButtons').then(m => ({ default: m.Web3WalletButtons })),
13+
import(/* webpackChunkName: "web3-wallet-buttons" */ '@/ui/elements/Web3WalletButtons').then(m => ({
14+
default: m.Web3WalletButtons,
15+
})),
1416
);
1517

1618
import { useSignInContext } from '../../contexts';

packages/clerk-js/src/ui/components/SignUp/SignUpStartSolanaWalletsCard.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { Header } from '@/ui/elements/Header';
1010
import { web3CallbackErrorHandler } from '@/ui/utils/web3CallbackErrorHandler';
1111

1212
const Web3WalletButtons = lazy(() =>
13-
import('@/ui/elements/Web3WalletButtons').then(m => ({ default: m.Web3WalletButtons })),
13+
import(/* webpackChunkName: "web3-wallet-buttons" */ '@/ui/elements/Web3WalletButtons').then(m => ({
14+
default: m.Web3WalletButtons,
15+
})),
1416
);
1517

1618
import { useSignUpContext } from '../../contexts';

0 commit comments

Comments
 (0)