Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update rsbuild to v0.3.11 #5314

Merged
merged 3 commits into from
Jan 31, 2024
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
2 changes: 1 addition & 1 deletion packages/builder/builder-webpack-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"@modern-js/types": "workspace:*",
"@modern-js/utils": "workspace:*",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
"@rsbuild/babel-preset": "0.3.7",
"@rsbuild/babel-preset": "0.3.11",
"@swc/helpers": "0.5.3",
"babel-plugin-import": "1.13.5",
"babel-plugin-styled-components": "1.13.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/builder/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"dependencies": {
"@modern-js/builder-shared": "workspace:*",
"@modern-js/utils": "workspace:*",
"@rsbuild/monorepo-utils": "0.3.7",
"@rsbuild/monorepo-utils": "0.3.11",
"@svgr/webpack": "8.1.0",
"@swc/helpers": "0.5.3",
"deepmerge": "^4.3.1",
Expand Down
36 changes: 18 additions & 18 deletions packages/builder/uni-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@
"@modern-js/server": "workspace:*",
"@modern-js/prod-server": "workspace:*",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
"@rsbuild/babel-preset": "0.3.7",
"@rsbuild/core": "0.3.7",
"@rsbuild/plugin-assets-retry": "0.3.7",
"@rsbuild/plugin-babel": "0.3.7",
"@rsbuild/plugin-check-syntax": "0.3.7",
"@rsbuild/plugin-css-minimizer": "0.3.7",
"@rsbuild/plugin-pug": "0.3.7",
"@rsbuild/plugin-react": "0.3.7",
"@rsbuild/plugin-rem": "0.3.7",
"@rsbuild/plugin-source-build": "0.3.7",
"@rsbuild/plugin-styled-components": "0.3.7",
"@rsbuild/plugin-svgr": "0.3.7",
"@rsbuild/plugin-type-check": "0.3.7",
"@rsbuild/plugin-toml": "0.3.7",
"@rsbuild/plugin-yaml": "0.3.7",
"@rsbuild/shared": "0.3.7",
"@rsbuild/webpack": "0.3.7",
"@rsbuild/babel-preset": "0.3.11",
"@rsbuild/core": "0.3.11",
"@rsbuild/plugin-assets-retry": "0.3.11",
"@rsbuild/plugin-babel": "0.3.11",
"@rsbuild/plugin-check-syntax": "0.3.11",
"@rsbuild/plugin-css-minimizer": "0.3.11",
"@rsbuild/plugin-pug": "0.3.11",
"@rsbuild/plugin-react": "0.3.11",
"@rsbuild/plugin-rem": "0.3.11",
"@rsbuild/plugin-source-build": "0.3.11",
"@rsbuild/plugin-styled-components": "0.3.11",
"@rsbuild/plugin-svgr": "0.3.11",
"@rsbuild/plugin-type-check": "0.3.11",
"@rsbuild/plugin-toml": "0.3.11",
"@rsbuild/plugin-yaml": "0.3.11",
"@rsbuild/shared": "0.3.11",
"@rsbuild/webpack": "0.3.11",
"@swc/helpers": "0.5.3",
"babel-loader": "9.1.3",
"babel-plugin-import": "1.13.5",
Expand All @@ -76,7 +76,7 @@
},
"devDependencies": {
"@modern-js/builder-plugin-node-polyfill": "workspace:*",
"@rsbuild/plugin-swc": "0.3.7",
"@rsbuild/plugin-swc": "0.3.11",
"@scripts/build": "workspace:*",
"@scripts/vitest-config": "workspace:*",
"@types/lodash": "^4.14.202",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const pluginBabelPost = (): RsbuildPlugin => ({

setup(api) {
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
const config = api.getNormalizedConfig();
if (chain.module.rules.get(CHAIN_ID.RULE.JS)) {
const babelLoaderOptions = chain.module
.rule(CHAIN_ID.RULE.JS)
Expand All @@ -20,7 +21,10 @@ export const pluginBabelPost = (): RsbuildPlugin => ({

if (
babelLoaderOptions &&
lodash.isEqual(getDefaultBabelOptions(), babelLoaderOptions)
lodash.isEqual(
getDefaultBabelOptions(config.source.decorators),
babelLoaderOptions,
)
) {
chain.module.rule(CHAIN_ID.RULE.JS).uses.delete(CHAIN_ID.USE.BABEL);
}
Expand Down
9 changes: 8 additions & 1 deletion packages/builder/uni-builder/src/shared/parseCommonConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export async function parseCommonConfig(
plugins: [...plugins] = [],
performance: { ...performanceConfig } = {},
output: {
enableLatestDecorators,
cssModuleLocalIdentName,
enableInlineScripts,
disableCssExtract,
Expand Down Expand Up @@ -149,7 +150,13 @@ export async function parseCommonConfig(
security: securityConfig,
};

const { dev = {}, html = {}, output = {} } = rsbuildConfig;
const { dev = {}, html = {}, output = {}, source = {} } = rsbuildConfig;

if (enableLatestDecorators) {
source.decorators = {
version: '2022-03',
};
}

if (cssModuleLocalIdentName) {
output.cssModules ||= {};
Expand Down
4 changes: 4 additions & 0 deletions packages/builder/uni-builder/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export type UniBuilderExtraConfig = {
resolveExtensionPrefix?: string | Partial<Record<RsbuildTarget, string>>;
};
output?: {
/**
* @deprecated use `source.decorators` instead
*/
enableLatestDecorators?: boolean;
/**
* @deprecated use `output.cssModules.localIdentName` instead
*/
Expand Down
6 changes: 1 addition & 5 deletions packages/builder/uni-builder/src/webpack/plugins/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ export const pluginBabel = (options?: PluginBabelOptions): RsbuildPlugin => ({
},
};

const decoratorConfig = {
version: config.output.enableLatestDecorators
? '2018-09'
: 'legacy',
} as const;
const decoratorConfig = config.source.decorators;

const baseBabelConfig =
isServer || isServiceWorker
Expand Down
32 changes: 19 additions & 13 deletions packages/builder/uni-builder/tests/__snapshots__/babel.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

exports[`plugin-babel (rspack mode) > should not set babel-loader when babel config not modified 1`] = `
[
{
"resolve": {
"fullySpecified": false,
},
"test": /\\\\\\.m\\?js/,
},
{
"include": [
{
Expand Down Expand Up @@ -48,7 +42,7 @@ exports[`plugin-babel (rspack mode) > should not set babel-loader when babel con
"decoratorMetadata": true,
"legacyDecorator": true,
"react": {
"development": true,
"development": false,
"refresh": true,
"runtime": "automatic",
},
Expand Down Expand Up @@ -85,17 +79,17 @@ exports[`plugin-babel (rspack mode) > should not set babel-loader when babel con
},
],
},
]
`;

exports[`plugin-babel (rspack mode) > should set babel-loader when babel config modified 1`] = `
[
{
"resolve": {
"fullySpecified": false,
},
"test": /\\\\\\.m\\?js/,
},
]
`;

exports[`plugin-babel (rspack mode) > should set babel-loader when babel config modified 1`] = `
[
{
"include": [
{
Expand Down Expand Up @@ -136,7 +130,7 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when babel config
"decoratorMetadata": true,
"legacyDecorator": true,
"react": {
"development": true,
"development": false,
"refresh": true,
"runtime": "automatic",
},
Expand Down Expand Up @@ -178,6 +172,12 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when babel config
"compact": false,
"configFile": false,
"plugins": [
[
"<WORKSPACE>/node_modules/<PNPM_INNER>/@babel/plugin-proposal-decorators/lib/index.js",
{
"version": "legacy",
},
],
[
"babel-plugin-import",
{
Expand All @@ -203,6 +203,12 @@ exports[`plugin-babel (rspack mode) > should set babel-loader when babel config
},
],
},
{
"resolve": {
"fullySpecified": false,
},
"test": /\\\\\\.m\\?js/,
},
]
`;

Expand Down
Loading
Loading