Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/five-ghosts-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-js/utils': patch
'@modern-js/builder': patch
---

feat: align rsbuild config
feat: 对齐 rsbuild 配置
26 changes: 0 additions & 26 deletions packages/cli/builder/src/plugins/extensionPrefix.ts

This file was deleted.

31 changes: 0 additions & 31 deletions packages/cli/builder/src/plugins/mainFields.ts

This file was deleted.

26 changes: 2 additions & 24 deletions packages/cli/builder/src/shared/parseCommonConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ export async function parseCommonConfig(
...outputConfig
} = {},
html: { outputStructure, appIcon, ...htmlConfig } = {},
source: {
alias,
globalVars,
resolveMainFields,
resolveExtensionPrefix,
transformImport,
...sourceConfig
} = {},
source: { alias, globalVars, transformImport, ...sourceConfig } = {},
dev = {},
security: { checkSyntax, sri, ...securityConfig } = {},
tools: {
Expand Down Expand Up @@ -166,10 +159,7 @@ export async function parseCommonConfig(

html.title ??= '';

html.appIcon =
typeof appIcon === 'string'
? { icons: [{ src: appIcon, size: 180 }] }
: appIcon;
html.appIcon = appIcon;

extraConfig.tools ??= {};

Expand Down Expand Up @@ -237,18 +227,6 @@ export async function parseCommonConfig(
);
}

if (resolveMainFields) {
const { pluginMainFields } = await import('../plugins/mainFields');
rsbuildPlugins.push(pluginMainFields(resolveMainFields));
}

if (resolveExtensionPrefix) {
const { pluginExtensionPrefix } = await import(
'../plugins/extensionPrefix'
);
rsbuildPlugins.push(pluginExtensionPrefix(resolveExtensionPrefix));
}

if (convertToRem) {
const { pluginRem } = await import('@rsbuild/plugin-rem');
rsbuildPlugins.push(
Expand Down
9 changes: 7 additions & 2 deletions packages/cli/builder/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ export const isHtmlDisabled = (
);
};

const DEFAULT_WEB_BROWSERSLIST = ['> 0.01%', 'not dead', 'not op_mini all'];
const DEFAULT_WEB_BROWSERSLIST = [
'chrome >= 87',
'edge >= 88',
'firefox >= 78',
'safari >= 14',
];

const DEFAULT_BROWSERSLIST: Record<RsbuildTarget, string[]> = {
web: DEFAULT_WEB_BROWSERSLIST,
node: ['node >= 14'],
node: ['node >= 16'],
'web-worker': DEFAULT_WEB_BROWSERSLIST,
};

Expand Down
11 changes: 1 addition & 10 deletions packages/cli/builder/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,6 @@ export type BuilderExtraConfig = {
* Define global variables. It can replace expressions like `process.env.FOO` in your code after compile.
*/
globalVars?: ChainedGlobalVars;
/**
* This configuration will determine which field of `package.json` you use to import the `npm` module.
* Same as the [resolve.mainFields](https://webpack.js.org/configuration/resolve/#resolvemainfields) config of webpack.
*/
resolveMainFields?: MainFields | Partial<Record<RsbuildTarget, MainFields>>;
/**
* Add a prefix to [resolve.extensions](https://webpack.js.org/configuration/resolve/#resolveextensions).
*/
resolveExtensionPrefix?: string | Partial<Record<RsbuildTarget, string>>;
};
output?: {
/**
Expand Down Expand Up @@ -200,7 +191,7 @@ export type BuilderExtraConfig = {
disableSvgr?: boolean;
};
html?: {
appIcon?: string | HtmlConfig['appIcon'];
appIcon?: HtmlConfig['appIcon'];
// TODO: need support rsbuild favicon type in server/utils
favicon?: string;
};
Expand Down
42 changes: 24 additions & 18 deletions packages/cli/builder/tests/__snapshots__/babel.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ exports[`plugin-babel (rspack mode) > should merge environment and shared babel
"coreJs": "3.46",
"mode": "entry",
"targets": [
"> 0.01%",
"not dead",
"not op_mini all",
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14",
],
},
"isModule": "unknown",
Expand Down Expand Up @@ -166,9 +167,10 @@ exports[`plugin-babel (rspack mode) > should merge environment and shared babel
"coreJs": "3.46",
"mode": "entry",
"targets": [
"> 0.01%",
"not dead",
"not op_mini all",
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14",
],
},
"isModule": "unknown",
Expand Down Expand Up @@ -288,9 +290,10 @@ exports[`plugin-babel (rspack mode) > should not set babel-loader when babel con
"coreJs": "3.46",
"mode": "entry",
"targets": [
"> 0.01%",
"not dead",
"not op_mini all",
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14",
],
},
"isModule": "unknown",
Expand Down Expand Up @@ -373,9 +376,10 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when babel config
"coreJs": "3.46",
"mode": "entry",
"targets": [
"> 0.01%",
"not dead",
"not op_mini all",
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14",
],
},
"isModule": "unknown",
Expand Down Expand Up @@ -495,9 +499,10 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when environment b
"coreJs": "3.46",
"mode": "entry",
"targets": [
"> 0.01%",
"not dead",
"not op_mini all",
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14",
],
},
"isModule": "unknown",
Expand Down Expand Up @@ -617,9 +622,10 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when environment b
"coreJs": "3.46",
"mode": "entry",
"targets": [
"> 0.01%",
"not dead",
"not op_mini all",
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14",
],
},
"isModule": "unknown",
Expand Down
Loading