Skip to content

Commit 9ca560a

Browse files
authored
feat: rsbuild config (#7821)
1 parent e4234cc commit 9ca560a

File tree

70 files changed

+587
-1570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+587
-1570
lines changed

.changeset/five-ghosts-care.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modern-js/utils': patch
3+
'@modern-js/builder': patch
4+
---
5+
6+
feat: align rsbuild config
7+
feat: 对齐 rsbuild 配置

packages/cli/builder/src/plugins/extensionPrefix.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

packages/cli/builder/src/plugins/mainFields.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/cli/builder/src/shared/parseCommonConfig.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,7 @@ export async function parseCommonConfig(
6868
...outputConfig
6969
} = {},
7070
html: { outputStructure, appIcon, ...htmlConfig } = {},
71-
source: {
72-
alias,
73-
globalVars,
74-
resolveMainFields,
75-
resolveExtensionPrefix,
76-
transformImport,
77-
...sourceConfig
78-
} = {},
71+
source: { alias, globalVars, transformImport, ...sourceConfig } = {},
7972
dev = {},
8073
security: { checkSyntax, sri, ...securityConfig } = {},
8174
tools: {
@@ -166,10 +159,7 @@ export async function parseCommonConfig(
166159

167160
html.title ??= '';
168161

169-
html.appIcon =
170-
typeof appIcon === 'string'
171-
? { icons: [{ src: appIcon, size: 180 }] }
172-
: appIcon;
162+
html.appIcon = appIcon;
173163

174164
extraConfig.tools ??= {};
175165

@@ -237,18 +227,6 @@ export async function parseCommonConfig(
237227
);
238228
}
239229

240-
if (resolveMainFields) {
241-
const { pluginMainFields } = await import('../plugins/mainFields');
242-
rsbuildPlugins.push(pluginMainFields(resolveMainFields));
243-
}
244-
245-
if (resolveExtensionPrefix) {
246-
const { pluginExtensionPrefix } = await import(
247-
'../plugins/extensionPrefix'
248-
);
249-
rsbuildPlugins.push(pluginExtensionPrefix(resolveExtensionPrefix));
250-
}
251-
252230
if (convertToRem) {
253231
const { pluginRem } = await import('@rsbuild/plugin-rem');
254232
rsbuildPlugins.push(

packages/cli/builder/src/shared/utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,16 @@ export const isHtmlDisabled = (
4949
);
5050
};
5151

52-
const DEFAULT_WEB_BROWSERSLIST = ['> 0.01%', 'not dead', 'not op_mini all'];
52+
const DEFAULT_WEB_BROWSERSLIST = [
53+
'chrome >= 87',
54+
'edge >= 88',
55+
'firefox >= 78',
56+
'safari >= 14',
57+
];
5358

5459
const DEFAULT_BROWSERSLIST: Record<RsbuildTarget, string[]> = {
5560
web: DEFAULT_WEB_BROWSERSLIST,
56-
node: ['node >= 14'],
61+
node: ['node >= 16'],
5762
'web-worker': DEFAULT_WEB_BROWSERSLIST,
5863
};
5964

packages/cli/builder/src/types.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,6 @@ export type BuilderExtraConfig = {
151151
* Define global variables. It can replace expressions like `process.env.FOO` in your code after compile.
152152
*/
153153
globalVars?: ChainedGlobalVars;
154-
/**
155-
* This configuration will determine which field of `package.json` you use to import the `npm` module.
156-
* Same as the [resolve.mainFields](https://webpack.js.org/configuration/resolve/#resolvemainfields) config of webpack.
157-
*/
158-
resolveMainFields?: MainFields | Partial<Record<RsbuildTarget, MainFields>>;
159-
/**
160-
* Add a prefix to [resolve.extensions](https://webpack.js.org/configuration/resolve/#resolveextensions).
161-
*/
162-
resolveExtensionPrefix?: string | Partial<Record<RsbuildTarget, string>>;
163154
};
164155
output?: {
165156
/**
@@ -200,7 +191,7 @@ export type BuilderExtraConfig = {
200191
disableSvgr?: boolean;
201192
};
202193
html?: {
203-
appIcon?: string | HtmlConfig['appIcon'];
194+
appIcon?: HtmlConfig['appIcon'];
204195
// TODO: need support rsbuild favicon type in server/utils
205196
favicon?: string;
206197
};

packages/cli/builder/tests/__snapshots__/babel.test.ts.snap

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ exports[`plugin-babel (rspack mode) > should merge environment and shared babel
3636
"coreJs": "3.46",
3737
"mode": "entry",
3838
"targets": [
39-
"> 0.01%",
40-
"not dead",
41-
"not op_mini all",
39+
"chrome >= 87",
40+
"edge >= 88",
41+
"firefox >= 78",
42+
"safari >= 14",
4243
],
4344
},
4445
"isModule": "unknown",
@@ -166,9 +167,10 @@ exports[`plugin-babel (rspack mode) > should merge environment and shared babel
166167
"coreJs": "3.46",
167168
"mode": "entry",
168169
"targets": [
169-
"> 0.01%",
170-
"not dead",
171-
"not op_mini all",
170+
"chrome >= 87",
171+
"edge >= 88",
172+
"firefox >= 78",
173+
"safari >= 14",
172174
],
173175
},
174176
"isModule": "unknown",
@@ -288,9 +290,10 @@ exports[`plugin-babel (rspack mode) > should not set babel-loader when babel con
288290
"coreJs": "3.46",
289291
"mode": "entry",
290292
"targets": [
291-
"> 0.01%",
292-
"not dead",
293-
"not op_mini all",
293+
"chrome >= 87",
294+
"edge >= 88",
295+
"firefox >= 78",
296+
"safari >= 14",
294297
],
295298
},
296299
"isModule": "unknown",
@@ -373,9 +376,10 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when babel config
373376
"coreJs": "3.46",
374377
"mode": "entry",
375378
"targets": [
376-
"> 0.01%",
377-
"not dead",
378-
"not op_mini all",
379+
"chrome >= 87",
380+
"edge >= 88",
381+
"firefox >= 78",
382+
"safari >= 14",
379383
],
380384
},
381385
"isModule": "unknown",
@@ -495,9 +499,10 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when environment b
495499
"coreJs": "3.46",
496500
"mode": "entry",
497501
"targets": [
498-
"> 0.01%",
499-
"not dead",
500-
"not op_mini all",
502+
"chrome >= 87",
503+
"edge >= 88",
504+
"firefox >= 78",
505+
"safari >= 14",
501506
],
502507
},
503508
"isModule": "unknown",
@@ -617,9 +622,10 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when environment b
617622
"coreJs": "3.46",
618623
"mode": "entry",
619624
"targets": [
620-
"> 0.01%",
621-
"not dead",
622-
"not op_mini all",
625+
"chrome >= 87",
626+
"edge >= 88",
627+
"firefox >= 78",
628+
"safari >= 14",
623629
],
624630
},
625631
"isModule": "unknown",

0 commit comments

Comments
 (0)