Skip to content

Commit

Permalink
feat: update rsbuild version (#5274)
Browse files Browse the repository at this point in the history
  • Loading branch information
caohuilin authored Jan 24, 2024
1 parent 2d3971d commit cb85327
Show file tree
Hide file tree
Showing 17 changed files with 374 additions and 235 deletions.
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.4",
"@rsbuild/babel-preset": "0.3.7",
"@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.4",
"@rsbuild/monorepo-utils": "0.3.7",
"@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.4",
"@rsbuild/core": "0.3.4",
"@rsbuild/plugin-assets-retry": "0.3.4",
"@rsbuild/plugin-babel": "0.3.4",
"@rsbuild/plugin-check-syntax": "0.3.4",
"@rsbuild/plugin-css-minimizer": "0.3.4",
"@rsbuild/plugin-pug": "0.3.4",
"@rsbuild/plugin-react": "0.3.4",
"@rsbuild/plugin-rem": "0.3.4",
"@rsbuild/plugin-source-build": "0.3.4",
"@rsbuild/plugin-styled-components": "0.3.4",
"@rsbuild/plugin-svgr": "0.3.4",
"@rsbuild/plugin-type-check": "0.3.4",
"@rsbuild/plugin-toml": "0.3.4",
"@rsbuild/plugin-yaml": "0.3.4",
"@rsbuild/shared": "0.3.4",
"@rsbuild/webpack": "0.3.4",
"@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",
"@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.4",
"@rsbuild/plugin-swc": "0.3.7",
"@scripts/build": "workspace:*",
"@scripts/vitest-config": "workspace:*",
"@types/lodash": "^4.14.202",
Expand Down
2 changes: 2 additions & 0 deletions packages/builder/uni-builder/src/shared/compatLegacyPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export function compatLegacyPlugin(
'modifyBuilderConfig',
'modifyRsbuildConfig',
);
// @ts-expect-error
// rsbuild is not completely consistent with modern.js builder config type
return fn(config, { mergeBuilderConfig: mergeRsbuildConfig });
});
},
Expand Down
15 changes: 4 additions & 11 deletions packages/builder/uni-builder/src/shared/plugins/fallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
JSON_REGEX,
getDistPath,
getFilename,
setConfig,
type Rspack,
} from '@rsbuild/shared';
import type { RsbuildPlugin } from '@rsbuild/core';
Expand Down Expand Up @@ -96,21 +95,15 @@ export const pluginFallback = (): RsbuildPlugin => ({
const distDir = getDistPath(rsbuildConfig, 'media');
const filename = getFilename(rsbuildConfig, 'media', isProd);

setConfig(
config,
'output.assetModuleFilename',
join(distDir, filename),
);
config.output ||= {};
config.output.assetModuleFilename = join(distDir, filename);

if (!config.module) {
return;
}

setConfig(
config,
'module.rules',
resourceRuleFallback(config.module?.rules),
);
config.module ||= {};
config.module.rules = resourceRuleFallback(config.module?.rules);
});
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exports[`uni-builder rspack > should generator rspack config correctly 1`] = `
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tiff\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
},
{
"oneOf": [
Expand All @@ -91,7 +91,7 @@ exports[`uni-builder rspack > should generator rspack config correctly 1`] = `
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:mp4\\|webm\\|ogg\\|mp3\\|wav\\|flac\\|aac\\|mov\\)\\$/i,
"test": /\\\\\\.\\(\\?:mp4\\|webm\\|ogg\\|mov\\|mp3\\|wav\\|flac\\|aac\\|m4a\\|opus\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -1069,7 +1069,7 @@ exports[`uni-builder rspack > should generator rspack config correctly when prod
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tiff\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
},
{
"oneOf": [
Expand All @@ -1096,7 +1096,7 @@ exports[`uni-builder rspack > should generator rspack config correctly when prod
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:mp4\\|webm\\|ogg\\|mp3\\|wav\\|flac\\|aac\\|mov\\)\\$/i,
"test": /\\\\\\.\\(\\?:mp4\\|webm\\|ogg\\|mov\\|mp3\\|wav\\|flac\\|aac\\|m4a\\|opus\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -2087,7 +2087,7 @@ exports[`uni-builder webpack > should generator webpack config correctly 1`] = `
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tiff\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
},
{
"oneOf": [
Expand All @@ -2114,7 +2114,7 @@ exports[`uni-builder webpack > should generator webpack config correctly 1`] = `
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:mp4\\|webm\\|ogg\\|mp3\\|wav\\|flac\\|aac\\|mov\\)\\$/i,
"test": /\\\\\\.\\(\\?:mp4\\|webm\\|ogg\\|mov\\|mp3\\|wav\\|flac\\|aac\\|m4a\\|opus\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -3109,7 +3109,7 @@ exports[`uni-builder webpack > should generator webpack config correctly when pr
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tiff\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
},
{
"oneOf": [
Expand All @@ -3136,7 +3136,7 @@ exports[`uni-builder webpack > should generator webpack config correctly when pr
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:mp4\\|webm\\|ogg\\|mp3\\|wav\\|flac\\|aac\\|mov\\)\\$/i,
"test": /\\\\\\.\\(\\?:mp4\\|webm\\|ogg\\|mov\\|mp3\\|wav\\|flac\\|aac\\|m4a\\|opus\\)\\$/i,
},
{
"oneOf": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exports[`plugin-postcssLegacy > should register postcss plugin by browserslist 1
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tiff\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
},
{
"oneOf": [
Expand All @@ -66,7 +66,7 @@ exports[`plugin-postcssLegacy > should register postcss plugin by browserslist 1
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:mp4\\|webm\\|ogg\\|mp3\\|wav\\|flac\\|aac\\|mov\\)\\$/i,
"test": /\\\\\\.\\(\\?:mp4\\|webm\\|ogg\\|mov\\|mp3\\|wav\\|flac\\|aac\\|m4a\\|opus\\)\\$/i,
},
{
"oneOf": [
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/plugin-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"test": "jest"
},
"dependencies": {
"@rsbuild/plugin-swc": "0.3.4",
"@rsbuild/plugin-swc": "0.3.7",
"@modern-js/utils": "workspace:*",
"@swc/helpers": "0.5.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/themes": "^2.0.0",
"@rsbuild/core": "0.3.4",
"@rsbuild/core": "0.3.7",
"@types/jest": "^29",
"@types/lodash": "^4.14.202",
"@types/node": "~16.11.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/review/eslint-config-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@babel/core": "^7.23.2",
"@babel/eslint-parser": "^7.22.15",
"@babel/eslint-plugin": "^7.22.10",
"@rsbuild/babel-preset": "0.3.4",
"@rsbuild/babel-preset": "0.3.7",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"eslint": "^8.28.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/plugin-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"@modern-js/plugin": "workspace:*",
"@modern-js/prod-server": "workspace:*",
"@modern-js/types": "workspace:*",
"@rsbuild/babel-preset": "0.3.4",
"@rsbuild/babel-preset": "0.3.7",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^13.4.0",
"@types/testing-library__jest-dom": "^5.14.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"axios": "^1.6.0"
},
"devDependencies": {
"@rsbuild/shared": "0.3.4",
"@rsbuild/shared": "0.3.7",
"@modern-js/server-core": "workspace:*",
"@scripts/build": "workspace:*",
"@scripts/jest-config": "workspace:*",
Expand Down
13 changes: 12 additions & 1 deletion packages/server/server/src/server/devServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,18 @@ export class ModernDevServer extends ModernServer {

await this.applyDefaultMiddlewares();

this.addMiddlewareHandler(rsbuildMiddlewares);
rsbuildMiddlewares.forEach(middleware => {
if (Array.isArray(middleware)) {
this.addHandler((ctx, next) => {
if (ctx.path === middleware[0]) {
return middleware[1](ctx.req, ctx.res, next);
}
return next();
});
} else {
this.addMiddlewareHandler([middleware]);
}
});

this.closeCb.push(close);

Expand Down
2 changes: 1 addition & 1 deletion packages/server/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@modern-js/babel-compiler": "workspace:*",
"@modern-js/utils": "workspace:*",
"@modern-js/babel-plugin-module-resolver": "workspace:*",
"@rsbuild/babel-preset": "0.3.4",
"@rsbuild/babel-preset": "0.3.7",
"@swc/helpers": "0.5.3",
"babel-plugin-transform-typescript-metadata": "^0.3.2"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/solutions/app-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@
"@modern-js/types": "workspace:*",
"@modern-js/upgrade": "workspace:*",
"@modern-js/utils": "workspace:*",
"@rsbuild/plugin-esbuild": "0.3.4",
"@rsbuild/plugin-node-polyfill": "0.3.4",
"@rsbuild/shared": "0.3.4",
"@rsbuild/plugin-esbuild": "0.3.7",
"@rsbuild/plugin-node-polyfill": "0.3.7",
"@rsbuild/shared": "0.3.7",
"es-module-lexer": "^1.1.0",
"esbuild": "0.17.19",
"@swc/helpers": "0.5.3",
"@modern-js/server-core": "workspace:*"
},
"devDependencies": {
"@rsbuild/plugin-swc": "0.3.4",
"@rsbuild/plugin-swc": "0.3.7",
"@scripts/build": "workspace:*",
"@scripts/jest-config": "workspace:*",
"@types/babel__traverse": "7.18.5",
Expand Down
Loading

0 comments on commit cb85327

Please sign in to comment.