Skip to content

Commit a1d46b7

Browse files
authored
chore(rsbuild-plugin): split setUp function to help extend (#3215)
1 parent 5b347f5 commit a1d46b7

File tree

22 files changed

+624
-516
lines changed

22 files changed

+624
-516
lines changed

.changeset/angry-spoons-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/rsbuild-plugin': patch
3+
---
4+
5+
chore(rsbuild-plugin): split setUp function to help extend

.changeset/spicy-roses-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/storybook-addon': patch
3+
---
4+
5+
chore: export plugin name

apps/rslib-module/.storybook/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const config: StorybookConfig = {
2929
options: {
3030
remotes: {
3131
'rslib-module':
32-
'rslib-module@http://localhost:3001/mf/mf-manifest.json',
32+
'rslib_provider@http://localhost:3001/mf-manifest.json',
3333
},
3434
},
3535
},

apps/rslib-module/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"types": "./dist/cjs/index.d.ts",
1414
"scripts": {
1515
"build": "rslib build",
16-
"dev": "rslib mf dev",
16+
"dev": "rslib mf-dev",
17+
"build:watch": "rslib build --watch",
1718
"serve": "pnpm build && http-server -p 3001 ./dist/ --cors",
1819
"storybook": "storybook dev -p 6006"
1920
},
@@ -22,7 +23,7 @@
2223
"@module-federation/rsbuild-plugin": "workspace:*",
2324
"@module-federation/storybook-addon": "workspace:*",
2425
"@rsbuild/plugin-react": "^1.0.6",
25-
"@rslib/core": "^0.0.18",
26+
"@rslib/core": "0.2.0",
2627
"@types/react": "^18.3.11",
2728
"http-server": "^14.1.1",
2829
"react": "^18.3.1",

apps/rslib-module/rslib.config.ts

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,27 @@ export default defineConfig({
3535
distPath: {
3636
root: './dist/mf',
3737
},
38-
assetPrefix: 'http://localhost:3000/mf',
39-
minify: true,
4038
},
41-
dev: {
42-
assetPrefix: 'http://localhost:3001/mf',
43-
},
44-
// just for dev
4539
server: {
4640
port: 3001,
4741
},
48-
plugins: [
49-
pluginModuleFederation({
50-
name: 'rslib_provider',
51-
exposes: {
52-
'.': './src/index.tsx',
53-
},
54-
shared: {
55-
react: {
56-
singleton: true,
57-
},
58-
'react-dom': {
59-
singleton: true,
60-
},
61-
},
62-
}),
63-
],
6442
},
6543
],
66-
plugins: [pluginReact()],
44+
plugins: [
45+
pluginReact(),
46+
pluginModuleFederation({
47+
name: 'rslib_provider',
48+
exposes: {
49+
'.': './src/index.tsx',
50+
},
51+
shared: {
52+
react: {
53+
singleton: true,
54+
},
55+
'react-dom': {
56+
singleton: true,
57+
},
58+
},
59+
}),
60+
],
6761
});

packages/enhanced/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { moduleFederationPlugin } from '@module-federation/sdk';
2-
export { default as ModuleFederationPlugin } from './wrapper/ModuleFederationPlugin';
2+
export {
3+
default as ModuleFederationPlugin,
4+
PLUGIN_NAME,
5+
} from './wrapper/ModuleFederationPlugin';
36
export { default as ContainerReferencePlugin } from './wrapper/ContainerReferencePlugin';
47
export { default as SharePlugin } from './wrapper/SharePlugin';
58
export { default as ContainerPlugin } from './wrapper/ContainerPlugin';

packages/enhanced/src/rspack.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export { ModuleFederationPlugin } from '@module-federation/rspack/plugin';
1+
export {
2+
ModuleFederationPlugin,
3+
PLUGIN_NAME,
4+
} from '@module-federation/rspack/plugin';

packages/enhanced/src/webpack.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
import { default as ModuleFederationPlugin } from './wrapper/ModuleFederationPlugin';
1+
import {
2+
default as ModuleFederationPlugin,
3+
PLUGIN_NAME,
4+
} from './wrapper/ModuleFederationPlugin';
25

3-
export { ModuleFederationPlugin };
6+
export { ModuleFederationPlugin, PLUGIN_NAME };

packages/enhanced/src/wrapper/ModuleFederationPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import path from 'node:path';
1313
import fs from 'node:fs';
1414
import ReactBridgePlugin from '@module-federation/bridge-react-webpack-plugin';
1515

16-
const PLUGIN_NAME = 'ModuleFederationPlugin';
16+
export const PLUGIN_NAME = 'ModuleFederationPlugin';
1717

1818
export default class ModuleFederationPlugin implements WebpackPluginInstance {
1919
private _options: moduleFederationPlugin.ModuleFederationPluginOptions;

packages/modernjs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"license": "MIT",
8989
"dependencies": {
9090
"@modern-js/node-bundle-require": "2.60.6",
91+
"@module-federation/rsbuild-plugin": "workspace:*",
9192
"@modern-js/utils": "2.60.6",
9293
"@module-federation/enhanced": "workspace:*",
9394
"@module-federation/node": "workspace:*",

0 commit comments

Comments
 (0)