Skip to content

Commit 8a7d4d2

Browse files
authored
fix(builder): update Rspack and fix upgrade error (#3709)
fix(builder): update Rspack and fix upgrade error
1 parent a4b8ff7 commit 8a7d4d2

File tree

8 files changed

+103
-71
lines changed

8 files changed

+103
-71
lines changed

.changeset/little-lions-exercise.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modern-js/builder-rspack-provider': patch
3+
---
4+
5+
hotfix(rspack-provider): update Rspack and fix upgrade error
6+
7+
hotfix(rspack-provider): 升级 Rspack 并处理升级问题

packages/builder/builder-rspack-provider/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@
5656
"@modern-js/types": "workspace:*",
5757
"@modern-js/utils": "workspace:*",
5858
"@babel/preset-typescript": "^7.17.12",
59-
"@rspack/core": "0.1.11",
60-
"@rspack/dev-client": "0.1.11",
61-
"@rspack/dev-middleware": "0.1.11",
62-
"@rspack/plugin-html": "0.1.11",
63-
"@rspack/postcss-loader": "0.1.11",
59+
"@rspack/core": "0.0.0-canary-22b006c-20230517164249",
60+
"@rspack/dev-client": "0.0.0-canary-22b006c-20230517164249",
61+
"@rspack/dev-middleware": "0.0.0-canary-22b006c-20230517164249",
62+
"@rspack/plugin-html": "0.0.0-canary-22b006c-20230517164249",
63+
"@rspack/postcss-loader": "0.0.0-canary-22b006c-20230517164249",
6464
"caniuse-lite": "^1.0.30001451",
6565
"core-js": "~3.30.0",
6666
"rspack-plugin-virtual-module": "0.1.0"

packages/builder/builder-rspack-provider/src/core/formatConfig.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ export const formatSplitChunks = (
145145
throw new Error(`name not support function`);
146146
}
147147

148+
const fallbackCacheGroup = (
149+
data: NonNullable<typeof splitChunks.fallbackCacheGroup>,
150+
) => ({
151+
maxSize: formatSplitSize(data.maxSize, 'maxSize'),
152+
maxAsyncSize: formatSplitSize(data.maxSize, 'maxAsyncSize'),
153+
maxInitialSize: formatSplitSize(data.maxSize, 'maxInitialSize'),
154+
minSize: formatSplitSize(data.minSize, 'minSize'),
155+
});
156+
148157
return {
149158
...rest,
150159

@@ -154,14 +163,18 @@ export const formatSplitChunks = (
154163
splitChunks.minRemainingSize,
155164
'minRemainingSize',
156165
),
157-
// todo: not support in rspack
158-
// maxSize: formatSplitSize(splitChunks.maxSize, 'maxSize'),
166+
maxSize: formatSplitSize(splitChunks.maxSize, 'maxSize'),
167+
maxAsyncSize: formatSplitSize(splitChunks.maxSize, 'maxAsyncSize'),
168+
maxInitialSize: formatSplitSize(splitChunks.maxSize, 'maxInitialSize'),
159169
minSize: formatSplitSize(splitChunks.minSize, 'minSize'),
160170
enforceSizeThreshold: formatSplitSize(
161171
splitChunks.enforceSizeThreshold,
162172
'enforceSizeThreshold',
163173
),
164174
chunks: splitChunks.chunks,
165175
cacheGroups: formatCacheGroups(splitChunks.cacheGroups),
176+
fallbackCacheGroup: splitChunks.fallbackCacheGroup
177+
? fallbackCacheGroup(splitChunks.fallbackCacheGroup)
178+
: undefined,
166179
};
167180
};

packages/builder/builder-rspack-provider/tests/plugins/__snapshots__/default.test.ts.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
630630
},
631631
"chunks": "all",
632632
"enforceSizeThreshold": 50000,
633+
"fallbackCacheGroup": undefined,
634+
"maxAsyncSize": undefined,
635+
"maxInitialSize": undefined,
636+
"maxSize": undefined,
633637
"minRemainingSize": undefined,
634638
"minSize": undefined,
635639
"name": undefined,
@@ -1302,6 +1306,10 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
13021306
},
13031307
"chunks": "all",
13041308
"enforceSizeThreshold": 50000,
1309+
"fallbackCacheGroup": undefined,
1310+
"maxAsyncSize": undefined,
1311+
"maxInitialSize": undefined,
1312+
"maxSize": undefined,
13051313
"minRemainingSize": undefined,
13061314
"minSize": undefined,
13071315
"name": undefined,
@@ -2392,6 +2400,10 @@ exports[`tools.rspack > should match snapshot 1`] = `
23922400
},
23932401
"chunks": "all",
23942402
"enforceSizeThreshold": 50000,
2403+
"fallbackCacheGroup": undefined,
2404+
"maxAsyncSize": undefined,
2405+
"maxInitialSize": undefined,
2406+
"maxSize": undefined,
23952407
"minRemainingSize": undefined,
23962408
"minSize": undefined,
23972409
"name": undefined,

pnpm-lock.yaml

Lines changed: 60 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/e2e/builder/cases/css/css-modules/cssModules.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test('should compile CSS modules correctly', async () => {
1919

2020
if (builder.providerType === 'rspack') {
2121
expect(content).toEqual(
22-
'.the-a-class{color:red}.l00wA{color:blue}.WV9bl{color:yellow}.the-d-class{color:green}',
22+
'.the-a-class{color:red}.LtKZ0{color:blue}._8nrJ{color:yellow}.the-d-class{color:green}',
2323
);
2424
} else {
2525
expect(content).toEqual(
@@ -46,7 +46,7 @@ test('should treat normal CSS as CSS modules when disableCssModuleExtension is t
4646

4747
if (builder.providerType === 'rspack') {
4848
expect(content).toEqual(
49-
'.hX0jA{color:red}.l00wA{color:blue}.WV9bl{color:yellow}.the-d-class{color:green}',
49+
'.T6GiI{color:red}.LtKZ0{color:blue}._8nrJ{color:yellow}.the-d-class{color:green}',
5050
);
5151
} else {
5252
expect(content).toEqual(

tests/e2e/builder/cases/stylus-rem/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ allProviderTest('should compile stylus and rem correctly', async () => {
2525

2626
if (builder.providerType === 'rspack') {
2727
expect(content).toEqual(
28-
'body{color:#f00;font:.28rem Arial,sans-serif}.KPtXW{font-size:.28rem}',
28+
'body{color:#f00;font:.28rem Arial,sans-serif}.KsRAA{font-size:.28rem}',
2929
);
3030
} else {
3131
expect(content).toEqual(

tests/e2e/builder/cases/stylus/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ allProviderTest('should compile stylus correctly', async () => {
1818

1919
if (builder.providerType === 'rspack') {
2020
expect(content).toEqual(
21-
'body{color:#f00;font:14px Arial,sans-serif}.KPtXW{font-size:14px}',
21+
'body{color:#f00;font:14px Arial,sans-serif}.KsRAA{font-size:14px}',
2222
);
2323
} else {
2424
expect(content).toEqual(

0 commit comments

Comments
 (0)