Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"**",
"!**/*.vue",
"!**/.rslib/**/*",
"!tests/e2e/react-component/public/umd/**/*"
"!tests/e2e/react-component/public/umd/**/*",
"!tests/integration/preserve-jsx/default/src/Component2.tsx"
],
"indentStyle": "space"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/module-federation/mf-host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"@module-federation/rsbuild-plugin": "^0.19.1",
"@rsbuild/core": "~1.5.11",
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@types/react": "^19.1.13",
"@types/react-dom": "^19.1.9",
"typescript": "^5.9.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/module-federation/mf-react-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@module-federation/enhanced": "^0.19.1",
"@module-federation/rsbuild-plugin": "^0.19.1",
"@module-federation/storybook-addon": "^4.0.30",
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@types/react": "^19.1.13",
"http-server": "^14.1.1",
Expand Down
2 changes: 1 addition & 1 deletion examples/module-federation/mf-remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"devDependencies": {
"@module-federation/rsbuild-plugin": "^0.19.1",
"@rsbuild/core": "~1.5.11",
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@types/react": "^19.1.13",
"@types/react-dom": "^19.1.9",
"typescript": "^5.9.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/react-component-bundle-false/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "rslib build"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rsbuild/plugin-sass": "^1.4.0",
"@rslib/core": "workspace:*",
"@types/react": "^19.1.13",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-component-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "rslib build"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rsbuild/plugin-sass": "^1.4.0",
"@rslib/core": "workspace:*",
"@types/react": "^19.1.13",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-component-umd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "rslib build"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rsbuild/plugin-sass": "^1.4.0",
"@rslib/core": "workspace:*",
"@types/react": "^19.1.13",
Expand Down
38 changes: 38 additions & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ export function composeMinifyConfig(config: LibConfig): EnvironmentConfig {
js: true,
css: false,
jsOptions: {
// Tweaked based on https://github.com/web-infra-dev/rspack/blob/e350b76163c976ee48da54c29bbb9d72153738d7/crates/rspack_plugin_swc_js_minimizer/src/lib.rs#L40.
test: /\.[cm]?jsx?(\?.*)?$/,
minimizerOptions: {
mangle: false,
// MF assets are loaded over the network, which means they will not be compressed by the project. Therefore, minifying them is necessary.
Expand Down Expand Up @@ -838,6 +840,40 @@ const fixJsModuleTypePlugin = (): RsbuildPlugin => ({
},
});

const BundlePlugin = (): RsbuildPlugin => ({
name: 'rslib:bundle',
setup(api) {
api.onBeforeBuild({
order: 'post',
handler: ({ bundlerConfigs }) => {
if (bundlerConfigs) {
for (const config of bundlerConfigs) {
if (config?.module?.parser?.javascript?.jsx === true) {
throw new Error(
'Bundle mode does not support preserving JSX syntax. Set `bundle` to `false` or change the JSX runtime to `automatic` or `classic`.',
);
}
}
}
},
});
},
});

const composeBundleConfig = (
bundle: LibConfig['bundle'],
): { rsbuildConfig: EnvironmentConfig } => {
if (bundle) {
return {
rsbuildConfig: {
plugins: [BundlePlugin()],
},
};
}

return { rsbuildConfig: {} };
};

const composeShimsConfig = (
format: Format,
shims?: Shims,
Expand Down Expand Up @@ -1676,6 +1712,7 @@ async function composeLibRsbuildConfig(
redirect = {},
umdName,
} = config;
const { rsbuildConfig: bundleConfig } = composeBundleConfig(bundle);
const { rsbuildConfig: shimsConfig, enabledShims } = composeShimsConfig(
format,
shims,
Expand Down Expand Up @@ -1761,6 +1798,7 @@ async function composeLibRsbuildConfig(
const printFileSizeConfig = composePrintFileSizeConfig(bundle, target);

return mergeRsbuildConfig(
bundleConfig,
formatConfig,
// outputConfig,
shimsConfig,
Expand Down
40 changes: 35 additions & 5 deletions packages/core/tests/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,8 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
toplevel: true
}
},
extractComments: true
extractComments: true,
test: /\\.[cm]?jsx?(\\?.*)?$/
}
)
],
Expand Down Expand Up @@ -1627,7 +1628,8 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
toplevel: true
}
},
extractComments: true
extractComments: true,
test: /\\.[cm]?jsx?(\\?.*)?$/
}
)
],
Expand Down Expand Up @@ -2230,7 +2232,8 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
toplevel: true
}
},
extractComments: true
extractComments: true,
test: /\\.[cm]?jsx?(\\?.*)?$/
}
)
],
Expand Down Expand Up @@ -2831,7 +2834,8 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
toplevel: true
}
},
extractComments: true
extractComments: true,
test: /\\.[cm]?jsx?(\\?.*)?$/
}
)
],
Expand Down Expand Up @@ -3401,7 +3405,8 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
toplevel: false
}
},
extractComments: true
extractComments: true,
test: /\\.[cm]?jsx?(\\?.*)?$/
}
)
],
Expand Down Expand Up @@ -3559,6 +3564,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
"mangle": false,
"minify": false,
},
"test": /\\\\\\.\\[cm\\]\\?jsx\\?\\(\\\\\\?\\.\\*\\)\\?\\$/,
},
},
"overrideBrowserslist": [
Expand All @@ -3572,6 +3578,10 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
},
},
"plugins": [
{
"name": "rslib:bundle",
"setup": [Function],
},
{
"name": "rsbuild:disable-url-parse",
"setup": [Function],
Expand Down Expand Up @@ -3835,6 +3845,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
"mangle": false,
"minify": false,
},
"test": /\\\\\\.\\[cm\\]\\?jsx\\?\\(\\\\\\?\\.\\*\\)\\?\\$/,
},
},
"overrideBrowserslist": [
Expand All @@ -3848,6 +3859,10 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
},
},
"plugins": [
{
"name": "rslib:bundle",
"setup": [Function],
},
{
"name": "rsbuild:cjs-import-meta-url-shim",
"setup": [Function],
Expand Down Expand Up @@ -4099,6 +4114,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
"mangle": false,
"minify": false,
},
"test": /\\\\\\.\\[cm\\]\\?jsx\\?\\(\\\\\\?\\.\\*\\)\\?\\$/,
},
},
"overrideBrowserslist": [
Expand All @@ -4112,6 +4128,10 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
},
},
"plugins": [
{
"name": "rslib:bundle",
"setup": [Function],
},
{
"name": "rsbuild:fix-js-module-type",
"setup": [Function],
Expand Down Expand Up @@ -4338,6 +4358,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
"minify": false,
"module": true,
},
"test": /\\\\\\.\\[cm\\]\\?jsx\\?\\(\\\\\\?\\.\\*\\)\\?\\$/,
},
},
"overrideBrowserslist": [
Expand All @@ -4351,6 +4372,10 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
},
},
"plugins": [
{
"name": "rslib:bundle",
"setup": [Function],
},
{
"name": "rsbuild:fix-js-module-type",
"setup": [Function],
Expand Down Expand Up @@ -4522,6 +4547,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
"mangle": false,
"minify": true,
},
"test": /\\\\\\.\\[cm\\]\\?jsx\\?\\(\\\\\\?\\.\\*\\)\\?\\$/,
},
},
"overrideBrowserslist": [
Expand All @@ -4540,6 +4566,10 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
},
},
"plugins": [
{
"name": "rslib:bundle",
"setup": [Function],
},
{
"name": "rsbuild:fix-js-module-type",
"setup": [Function],
Expand Down
1 change: 1 addition & 0 deletions packages/core/tests/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ describe('minify', () => {
"mangle": false,
"minify": false,
},
"test": /\\\\\\.\\[cm\\]\\?jsx\\?\\(\\\\\\?\\.\\*\\)\\?\\$/,
},
}
`);
Expand Down
2 changes: 1 addition & 1 deletion packages/create-rslib/fragments/base/react-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dev": "rslib build --watch"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"react": "^19.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/create-rslib/fragments/base/react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dev": "rslib build --watch"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@types/react": "^19.1.13",
"react": "^19.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-rslib/template-[react]-[]-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dev": "rslib build --watch"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"react": "^19.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/create-rslib/template-[react]-[]-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dev": "rslib build --watch"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@types/react": "^19.1.13",
"react": "^19.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"devDependencies": {
"@rsbuild/core": "~1.5.11",
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@rstest/core": "^0.4.1",
"@storybook/addon-docs": "^9.1.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"devDependencies": {
"@rsbuild/core": "~1.5.11",
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@rstest/core": "^0.4.1",
"@storybook/addon-docs": "^9.1.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test": "rstest"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@rstest/core": "^0.4.1",
"@testing-library/jest-dom": "^6.8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test": "rstest"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@rstest/core": "^0.4.1",
"@testing-library/jest-dom": "^6.8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"devDependencies": {
"@rsbuild/core": "~1.5.11",
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@storybook/addon-docs": "^9.1.7",
"@storybook/addon-essentials": "^9.0.0-alpha.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"devDependencies": {
"@rsbuild/core": "~1.5.11",
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@storybook/addon-docs": "^9.1.7",
"@storybook/addon-essentials": "^9.0.0-alpha.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"devDependencies": {
"@rsbuild/core": "~1.5.11",
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@storybook/addon-docs": "^9.1.7",
"@storybook/addon-essentials": "^9.0.0-alpha.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"devDependencies": {
"@rsbuild/core": "~1.5.11",
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@storybook/addon-docs": "^9.1.7",
"@storybook/addon-essentials": "^9.0.0-alpha.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test": "vitest run"
},
"devDependencies": {
"@rsbuild/plugin-react": "^1.4.0",
"@rsbuild/plugin-react": "^1.4.1",
"@rslib/core": "workspace:*",
"@testing-library/jest-dom": "^6.8.0",
"@testing-library/react": "^16.3.0",
Expand Down
Loading
Loading