Skip to content

Commit 97ceeb2

Browse files
authored
chore: upgrade rspack version (#36)
* chore: upgrade rspack version * fix: remove ssr template string
1 parent a4d8439 commit 97ceeb2

5 files changed

+337
-889
lines changed

package.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"*.less"
3535
],
3636
"dependencies": {
37-
"@arco-design/theme-line": "^0.0.3",
3837
"@arco-design/web-react": "^2.53.2",
3938
"@monaco-editor/react": "^4.6.0",
4039
"axios": "^1.5.1",
@@ -49,12 +48,13 @@
4948
"rehype-katex": "^6.0.3",
5049
"remark-math": "^6.0.0",
5150
"styled-components": "^6.1.0",
51+
"ts-deepmerge": "^7.0.0",
5252
"type-assertions": "^1.1.0"
5353
},
5454
"devDependencies": {
55-
"@arco-plugins/unplugin-react": "^1.0.0-alpha.1",
56-
"@rspack/cli": "^0.3.5",
57-
"@rspack/plugin-html": "^0.3.11",
55+
"@rspack/cli": "^0.6.5",
56+
"@rspack/core": "^0.6.5",
57+
"@rspack/plugin-html": "^0.5.8",
5858
"@svgr/webpack": "^8.1.0",
5959
"@types/event-emitter": "^0.3.4",
6060
"@types/lodash.debounce": "^4.0.7",
@@ -68,7 +68,6 @@
6868
"@typescript-eslint/parser": "^6.7.3",
6969
"browserslist": "^4.22.1",
7070
"commitlint": "^17.7.1",
71-
"css-loader": "^6.8.1",
7271
"eslint": "^8.50.0",
7372
"eslint-config-prettier": "^9.0.0",
7473
"eslint-import-resolver-alias": "^1.1.2",
@@ -85,7 +84,6 @@
8584
"monaco-editor": "^0.44.0",
8685
"prettier": "^3.0.3",
8786
"prompts": "^2.4.2",
88-
"style-loader": "^3.3.3",
8987
"ts-node": "^10.9.1",
9088
"typescript": "^5.2.2"
9189
},

tools/rspack.base.config.ts

+47-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import path from 'path';
22
import type { Configuration } from '@rspack/cli';
3+
import type { SwcLoaderOptions } from '@rspack/core';
34

45
export default function createBaseRspackConfig(): Configuration {
6+
const mode = process.env.NODE_ENV as Configuration['mode'];
57
return {
6-
context: path.resolve(__dirname, '..'),
8+
mode,
79
output: {
810
path: './dist',
911
filename: '[name].[contenthash:8].bundle.js',
@@ -12,19 +14,20 @@ export default function createBaseRspackConfig(): Configuration {
1214
},
1315
resolve: {
1416
alias: {
15-
'@config': './config',
16-
'@problems': './problems',
17-
'@src': './src',
17+
'@config': path.resolve(__dirname, '../config'),
18+
'@problems': path.resolve(__dirname, '../problems'),
19+
'@src': path.resolve(__dirname, '../src'),
1820
},
21+
extensions: ['...', 'js', '.ts', 'jsx', '.tsx'],
1922
},
20-
builtins: {
21-
css: {
22-
modules: {
23-
localIdentName: '[path][name]__[local]--[hash:6]',
24-
},
25-
},
23+
experiments: {
24+
css: true,
2625
},
2726
module: {
27+
parser: {
28+
css: { namedExports: false },
29+
'css/module': { namedExports: false },
30+
},
2831
rules: [
2932
{
3033
resourceQuery: /url$/,
@@ -34,6 +37,11 @@ export default function createBaseRspackConfig(): Configuration {
3437
resourceQuery: /raw$/,
3538
type: 'asset/source',
3639
},
40+
{
41+
test: /\.svg$/,
42+
issuer: /\.[jt]sx?$/,
43+
use: ['@svgr/webpack'],
44+
},
3745
{
3846
test: /\.less$/i,
3947
use: [
@@ -63,9 +71,35 @@ export default function createBaseRspackConfig(): Configuration {
6371
type: 'css/module',
6472
},
6573
{
66-
test: /\.svg$/,
67-
issuer: /\.[jt]sx?$/,
68-
use: ['@svgr/webpack'],
74+
test: /\.(jsx?|tsx?)$/,
75+
exclude: [/problems\//],
76+
use: [
77+
{
78+
loader: 'builtin:swc-loader',
79+
options: {
80+
jsc: {
81+
parser: {
82+
syntax: 'typescript',
83+
tsx: true,
84+
},
85+
transform: {
86+
react: {
87+
runtime: 'automatic',
88+
},
89+
},
90+
},
91+
rspackExperiments: {
92+
import: [
93+
{
94+
libraryName: '@arco-design/web-react',
95+
customName: '@arco-design/web-react/es/{{ member }}',
96+
style: true,
97+
},
98+
],
99+
},
100+
} as SwcLoaderOptions,
101+
},
102+
],
69103
},
70104
],
71105
},

tools/rspack.config.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import type { Configuration } from '@rspack/cli';
22
import HtmlRspackPlugin from '@rspack/plugin-html';
33
import { CopyRspackPlugin, DefinePlugin } from '@rspack/core';
4-
import { ArcoDesignPlugin } from '@arco-plugins/unplugin-react';
4+
import { merge as deepmerge } from 'ts-deepmerge';
55
import RspackSSRPlugin from './RspackSSRPlugin';
66
import createBaseRspackConfig from './rspack.base.config';
77

88
export default function createRspackConfig(): Configuration {
99
const baseConfig = createBaseRspackConfig();
1010
const mode = process.env.NODE_ENV as Configuration['mode'];
1111
const template = './html/index.html';
12-
return {
13-
...baseConfig,
14-
mode,
12+
return deepmerge<[Configuration, Configuration]>(baseConfig, {
1513
stats: mode === 'production',
1614
entry: {
1715
main: './src/main.tsx',
@@ -45,10 +43,6 @@ export default function createRspackConfig(): Configuration {
4543
new DefinePlugin({
4644
WEBPACK_IS_SSR: false,
4745
}),
48-
new ArcoDesignPlugin({
49-
style: 'css',
50-
theme: '@arco-design/theme-line',
51-
}),
5246
],
5347
optimization: {
5448
splitChunks: {
@@ -79,5 +73,5 @@ export default function createRspackConfig(): Configuration {
7973
},
8074
},
8175
},
82-
};
76+
});
8377
}

tools/rspack.ssr.config.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import type { Configuration } from '@rspack/cli';
22
import { HtmlRspackPlugin, DefinePlugin } from '@rspack/core';
3+
import { merge as deepmerge } from 'ts-deepmerge';
34
import createBaseRspackConfig from './rspack.base.config';
45

56
export default function createSSRRspackConfig(): Configuration {
67
const baseConfig = createBaseRspackConfig();
7-
const mode = process.env.NODE_ENV as Configuration['mode'];
8-
return {
9-
...baseConfig,
10-
mode,
8+
return deepmerge<[Configuration, Configuration]>(baseConfig, {
119
target: 'node',
1210
entry: {
1311
ssr: './src/ssr.tsx',
@@ -28,5 +26,5 @@ export default function createSSRRspackConfig(): Configuration {
2826
WEBPACK_IS_SSR: true,
2927
}),
3028
],
31-
};
29+
});
3230
}

0 commit comments

Comments
 (0)