diff --git a/examples/module-federation/mf-react-component/rslib.config.ts b/examples/module-federation/mf-react-component/rslib.config.ts index 95d535810..287a8260a 100644 --- a/examples/module-federation/mf-react-component/rslib.config.ts +++ b/examples/module-federation/mf-react-component/rslib.config.ts @@ -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: { @@ -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, + }, + }, + }), + ], }); diff --git a/website/docs/en/guide/advanced/module-federation.mdx b/website/docs/en/guide/advanced/module-federation.mdx index 9b33f51a1..6cf8f1013 100644 --- a/website/docs/en/guide/advanced/module-federation.mdx +++ b/website/docs/en/guide/advanced/module-federation.mdx @@ -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, - }, - }, - }), + ], }, ], @@ -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, + }, + }, + }), + ], }); ``` diff --git a/website/docs/zh/guide/advanced/module-federation.mdx b/website/docs/zh/guide/advanced/module-federation.mdx index 3af43d191..c0d24a4b6 100644 --- a/website/docs/zh/guide/advanced/module-federation.mdx +++ b/website/docs/zh/guide/advanced/module-federation.mdx @@ -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 下使用 @@ -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, + }, + }, + }), + ], }); ```