Skip to content

Commit fa23ad8

Browse files
jacekradkowobsorianodstaley
authored
chore(clerk-js,ui): upgrade to Rspack 2 (#8382)
Co-authored-by: wobsoriano <sorianorobertc@gmail.com> Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
1 parent 0f7794a commit fa23ad8

10 files changed

Lines changed: 3018 additions & 3472 deletions

File tree

.changeset/rspack-2-upgrade.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/ui': patch
4+
---
5+
6+
Upgrade build tooling to Rspack 2 (No user-facing API changes).

packages/clerk-js/bundlewatch.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"files": [
33
{ "path": "./dist/clerk.js", "maxSize": "549KB" },
4-
{ "path": "./dist/clerk.browser.js", "maxSize": "71.24KB" },
4+
{ "path": "./dist/clerk.browser.js", "maxSize": "72KB" },
55
{ "path": "./dist/clerk.legacy.browser.js", "maxSize": "114KB" },
66
{ "path": "./dist/clerk.no-rhc.js", "maxSize": "316KB" },
77
{ "path": "./dist/clerk.native.js", "maxSize": "72KB" },

packages/clerk-js/package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@
5757
],
5858
"scripts": {
5959
"build": "pnpm build:bundle && pnpm build:declarations",
60-
"build:analyze": "rspack build --config rspack.config.js --env production --env variant=\"clerk.browser\" --env analysis --analyze",
61-
"build:bundle": "pnpm clean && rspack build --config rspack.config.js --env production",
60+
"build:analyze": "rspack build --config rspack.config.mjs --env production --env variant=\"clerk.browser\" --env analysis",
61+
"build:bundle": "pnpm clean && rspack build --config rspack.config.mjs --env production",
6262
"build:declarations": "tsc -p tsconfig.declarations.json",
63-
"build:sandbox": "pnpm --filter @clerk/ui build:umd && rspack build --config rspack.config.js --env production --env sandbox",
64-
"build:stats": "rspack build --config rspack.config.js --env production --json=stats.json --env variant=\"clerk.browser\"",
63+
"build:sandbox": "pnpm --filter @clerk/ui build:umd && rspack build --config rspack.config.mjs --env production --env sandbox",
64+
"build:stats": "rspack build --config rspack.config.mjs --env production --json=stats.json --env variant=\"clerk.browser\"",
6565
"bundlewatch": "FORCE_COLOR=1 bundlewatch --config bundlewatch.config.json",
6666
"bundlewatch:fix": "node bundlewatch-fix.mjs",
6767
"clean": "rimraf ./dist",
68-
"dev": "rspack serve --config rspack.config.js",
69-
"dev:origin": "rspack serve --config rspack.config.js --env devOrigin=http://localhost:${PORT:-4000}",
68+
"dev": "rspack serve --config rspack.config.mjs",
69+
"dev:origin": "rspack serve --config rspack.config.mjs --env devOrigin=http://localhost:${PORT:-4000}",
7070
"dev:sandbox": "pnpm -w dev:sandbox",
71-
"dev:sandbox:serve": "rspack serve --config rspack.config.js --env devOrigin=http://localhost:${PORT:-4000} --env sandbox=1",
71+
"dev:sandbox:serve": "rspack serve --config rspack.config.mjs --env devOrigin=http://localhost:${PORT:-4000} --env sandbox=1",
7272
"format": "node ../../scripts/format-package.mjs",
7373
"format:check": "node ../../scripts/format-package.mjs --check",
7474
"lint": "eslint src",
@@ -79,7 +79,7 @@
7979
"test:sandbox:integration": "playwright test",
8080
"test:sandbox:integration:ui": "playwright test --ui",
8181
"test:sandbox:integration:update-snapshots": "playwright test --update-snapshots",
82-
"watch": "rspack build --config rspack.config.js --env production --watch"
82+
"watch": "rspack build --config rspack.config.mjs --env production --watch"
8383
},
8484
"browserslist": "last 2 years",
8585
"dependencies": {
@@ -105,9 +105,10 @@
105105
"@clerk/msw": "workspace:^",
106106
"@clerk/testing": "workspace:^",
107107
"@emotion/react": "11.14.0",
108-
"@rsdoctor/rspack-plugin": "^0.4.13",
108+
"@rsdoctor/rspack-plugin": "^1.5.9",
109109
"@rspack/cli": "catalog:rspack",
110110
"@rspack/core": "catalog:rspack",
111+
"@rspack/dev-server": "catalog:rspack",
111112
"@rspack/plugin-react-refresh": "catalog:rspack",
112113
"@types/cloudflare-turnstile": "^0.2.2",
113114
"@types/webpack-env": "^1.18.8",
Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
// @ts-check
2-
const rspack = require('@rspack/core');
3-
const packageJSON = require('./package.json');
4-
const path = require('path');
5-
const { merge } = require('webpack-merge');
6-
const ReactRefreshPlugin = require('@rspack/plugin-react-refresh');
7-
const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
8-
const { svgLoader, typescriptLoaderProd, typescriptLoaderDev } = require('../../scripts/rspack-common');
2+
import rspack from '@rspack/core';
3+
import path from 'path';
4+
import { fileURLToPath } from 'url';
5+
import { createRequire } from 'module';
6+
import { merge } from 'webpack-merge';
7+
import ReactRefreshPlugin from '@rspack/plugin-react-refresh';
8+
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
9+
import { svgLoader, typescriptLoaderProd, typescriptLoaderDev } from '../../scripts/rspack-common.js';
10+
import packageJSON from './package.json' with { type: 'json' };
11+
12+
const require = createRequire(import.meta.url);
13+
const __filename = fileURLToPath(import.meta.url);
14+
const __dirname = path.dirname(__filename);
915

1016
const isProduction = mode => mode === 'production';
1117
const isDevelopment = mode => !isProduction(mode);
@@ -185,7 +191,7 @@ const commonForProd = () => {
185191
output: {
186192
path: path.resolve(__dirname, 'dist'),
187193
filename: '[name].js',
188-
libraryTarget: 'umd',
194+
library: { type: 'umd' },
189195
globalObject: 'globalThis',
190196
},
191197
optimization: {
@@ -305,7 +311,7 @@ const prodConfig = ({ mode, env, analysis }) => {
305311
},
306312
output: {
307313
filename: '[name].mjs',
308-
libraryTarget: 'module',
314+
library: { type: 'module' },
309315
},
310316
plugins: [
311317
// Include the lazy chunks in the bundle as well
@@ -329,7 +335,7 @@ const prodConfig = ({ mode, env, analysis }) => {
329335
{
330336
output: {
331337
filename: '[name].js',
332-
libraryTarget: 'commonjs',
338+
library: { type: 'commonjs' },
333339
},
334340
plugins: [
335341
// Include the lazy chunks in the bundle as well
@@ -378,7 +384,7 @@ const prodConfig = ({ mode, env, analysis }) => {
378384
},
379385
output: {
380386
filename: '[name].mjs',
381-
libraryTarget: 'module',
387+
library: { type: 'module' },
382388
},
383389
},
384390
);
@@ -392,7 +398,7 @@ const prodConfig = ({ mode, env, analysis }) => {
392398
{
393399
output: {
394400
filename: '[name].js',
395-
libraryTarget: 'commonjs',
401+
library: { type: 'commonjs' },
396402
},
397403
},
398404
);
@@ -443,7 +449,7 @@ const devConfig = ({ mode, env }) => {
443449
publicPath: isSandbox ? `` : `${devUrl.origin}/npm`,
444450
crossOriginLoading: 'anonymous',
445451
filename: `[name].js`,
446-
libraryTarget: 'umd',
452+
library: { type: 'umd' },
447453
},
448454
optimization: {
449455
minimize: false,
@@ -463,11 +469,8 @@ const devConfig = ({ mode, env }) => {
463469
}
464470
: {}),
465471
},
466-
cache: true,
467-
experiments: {
468-
cache: {
469-
type: 'memory',
470-
},
472+
cache: {
473+
type: 'memory',
471474
},
472475
lazyCompilation: false,
473476
};
@@ -507,7 +510,7 @@ const devConfig = ({ mode, env }) => {
507510
return entryToConfigMap[variant];
508511
};
509512

510-
module.exports = env => {
513+
export default env => {
511514
const mode = env.production ? 'production' : 'development';
512515
const analysis = !!env.analysis;
513516

packages/clerk-js/turbo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"src/**",
88
"tsconfig.json",
99
"tsconfig.declarations.json",
10-
"rspack.config.js",
10+
"rspack.config.mjs",
1111

1212
"!**/*.test.*",
1313
"!**/test/**",

packages/shared/src/react/query/useQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DefaultError, NoInfer, QueryKey } from '@tanstack/query-core';
1+
import type { DefaultError, QueryKey } from '@tanstack/query-core';
22
import { QueryObserver } from '@tanstack/query-core';
33

44
import type { DefinedInitialDataOptions, UndefinedInitialDataOptions } from './queryOptions';

packages/ui/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
],
7171
"scripts": {
7272
"build": "pnpm build:umd && pnpm build:esm && pnpm check:no-rhc && pnpm type-check",
73-
"build:analyze": "rspack build --config rspack.config.js --env production --env analyze --analyze",
73+
"build:analyze": "rspack build --config rspack.config.js --env production --env analyze",
7474
"build:esm": "tsdown",
7575
"build:rsdoctor": "RSDOCTOR=true rspack build --config rspack.config.js --env production",
7676
"build:umd": "rspack build --config rspack.config.js --env production",
@@ -114,9 +114,10 @@
114114
"devDependencies": {
115115
"@clerk/headless": "workspace:^",
116116
"@floating-ui/react-dom": "^2.1.8",
117-
"@rsdoctor/rspack-plugin": "^0.4.13",
117+
"@rsdoctor/rspack-plugin": "^1.5.9",
118118
"@rspack/cli": "catalog:rspack",
119119
"@rspack/core": "catalog:rspack",
120+
"@rspack/dev-server": "catalog:rspack",
120121
"@rspack/plugin-react-refresh": "catalog:rspack",
121122
"@svgr/rollup": "^8.1.0",
122123
"@svgr/webpack": "^6.5.1",

packages/ui/rspack.config.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const commonForProdBrowser = ({ targets = 'last 2 years', useCoreJs = false } =
166166
output: {
167167
path: path.resolve(__dirname, 'dist'),
168168
filename: '[name].js',
169-
libraryTarget: 'umd',
169+
library: { type: 'umd' },
170170
globalObject: 'globalThis',
171171
},
172172
module: {
@@ -265,7 +265,7 @@ const devConfig = (mode, env) => {
265265
publicPath: `${devUrl.origin}/npm/`,
266266
crossOriginLoading: 'anonymous',
267267
filename: `[name].js`,
268-
libraryTarget: 'umd',
268+
library: { type: 'umd' },
269269
},
270270
optimization: {
271271
minimize: false,
@@ -281,11 +281,8 @@ const devConfig = (mode, env) => {
281281
liveReload: false,
282282
client: { webSocketURL: `auto://${devUrl.host}/ws` },
283283
},
284-
cache: false,
285-
experiments: {
286-
cache: {
287-
type: 'memory',
288-
},
284+
cache: {
285+
type: 'memory',
289286
},
290287
lazyCompilation: false,
291288
// Only externalize React when using the shared variant (e.g., with @clerk/react).

0 commit comments

Comments
 (0)