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

chore: hoist mf plugin to global #656

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
34 changes: 17 additions & 17 deletions examples/module-federation/mf-react-component/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,6 @@ export default defineConfig({
dev: {
assetPrefix: 'http://localhost:3001/mf',
},
plugins: [
pluginModuleFederation({
name: 'rslib_provider',
exposes: {
'.': './src/index.tsx',
},
shared: {
react: {
singleton: true,
},
'react-dom': {
singleton: true,
},
},
}),
],
},
],
source: {
Expand All @@ -58,5 +42,21 @@ export default defineConfig({
server: {
port: 3001,
},
plugins: [pluginReact()],
plugins: [
pluginReact(),
pluginModuleFederation({
name: 'rslib_provider',
exposes: {
'.': './src/index.tsx',
},
shared: {
react: {
singleton: true,
},
'react-dom': {
singleton: true,
},
},
}),
],
});
37 changes: 20 additions & 17 deletions website/docs/en/guide/advanced/module-federation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,7 @@ export default defineConfig({
assetPrefix: 'http://localhost:3001/mf',
},
plugins: [
pluginModuleFederation({
name: 'rslib_provider',
exposes: {
// add expose here
},
// can not add 'remote' here, because you may build 'esm' or 'cjs' assets in one build.
// if you want the Rslib package use remote module, please see below.
shared: {
react: {
singleton: true,
},
'react-dom': {
singleton: true,
},
},
}),

],
},
],
Expand All @@ -78,7 +63,25 @@ export default defineConfig({
output: {
target: 'web',
},
plugins: [pluginReact()],
plugins: [
pluginReact()
pluginModuleFederation({
name: 'rslib_provider',
exposes: {
// add expose here
},
// can not add 'remote' here, because you may build 'esm' or 'cjs' assets in one build.
// if you want the Rslib package use remote module, please see below.
shared: {
react: {
singleton: true,
},
'react-dom': {
singleton: true,
},
},
}),
],
});
```

Expand Down
38 changes: 19 additions & 19 deletions website/docs/zh/guide/advanced/module-federation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,6 @@ export default defineConfig({
dev: {
assetPrefix: 'http://localhost:3001/mf',
},
plugins: [
pluginModuleFederation({
name: 'rslib_provider',
exposes: {
// 这里添加 expose
},
// 此处无法添加 "remote",因为你可能会在一次构建中构建 "esm" 或 "cjs" 产物。
// 如果你希望 Rslib 包使用远程模块,请参考下面。
shared: {
react: {
singleton: true,
},
'react-dom': {
singleton: true,
},
},
}),
],
},
],
// Storybook 在 dev 下使用
Expand All @@ -78,7 +60,25 @@ export default defineConfig({
output: {
target: 'web',
},
plugins: [pluginReact()],
plugins: [
pluginReact()
pluginModuleFederation({
name: 'rslib_provider',
exposes: {
// 这里添加 expose
},
// 此处无法添加 "remote",因为你可能会在一次构建中构建 "esm" 或 "cjs" 产物。
// 如果你希望 Rslib 包使用远程模块,请参考下面。
shared: {
react: {
singleton: true,
},
'react-dom': {
singleton: true,
},
},
}),
],
});
```

Expand Down
Loading