File tree Expand file tree Collapse file tree 3 files changed +56
-53
lines changed
examples/module-federation/mf-react-component Expand file tree Collapse file tree 3 files changed +56
-53
lines changed Original file line number Diff line number Diff line change @@ -33,22 +33,6 @@ export default defineConfig({
3333 dev : {
3434 assetPrefix : 'http://localhost:3001/mf' ,
3535 } ,
36- plugins : [
37- pluginModuleFederation ( {
38- name : 'rslib_provider' ,
39- exposes : {
40- '.' : './src/index.tsx' ,
41- } ,
42- shared : {
43- react : {
44- singleton : true ,
45- } ,
46- 'react-dom' : {
47- singleton : true ,
48- } ,
49- } ,
50- } ) ,
51- ] ,
5236 } ,
5337 ] ,
5438 source : {
@@ -58,5 +42,21 @@ export default defineConfig({
5842 server : {
5943 port : 3001 ,
6044 } ,
61- plugins : [ pluginReact ( ) ] ,
45+ plugins : [
46+ pluginReact ( ) ,
47+ pluginModuleFederation ( {
48+ name : 'rslib_provider' ,
49+ exposes : {
50+ '.' : './src/index.tsx' ,
51+ } ,
52+ shared : {
53+ react : {
54+ singleton : true ,
55+ } ,
56+ 'react-dom' : {
57+ singleton : true ,
58+ } ,
59+ } ,
60+ } ) ,
61+ ] ,
6262} ) ;
Original file line number Diff line number Diff line change @@ -52,22 +52,7 @@ export default defineConfig({
5252 assetPrefix: ' http://localhost:3001/mf' ,
5353 },
5454 plugins: [
55- pluginModuleFederation ({
56- name: ' rslib_provider' ,
57- exposes: {
58- // add expose here
59- },
60- // can not add 'remote' here, because you may build 'esm' or 'cjs' assets in one build.
61- // if you want the Rslib package use remote module, please see below.
62- shared: {
63- react: {
64- singleton: true ,
65- },
66- ' react-dom' : {
67- singleton: true ,
68- },
69- },
70- }),
55+
7156 ],
7257 },
7358 ],
@@ -78,7 +63,25 @@ export default defineConfig({
7863 output: {
7964 target: ' web' ,
8065 },
81- plugins: [pluginReact ()],
66+ plugins: [
67+ pluginReact ()
68+ pluginModuleFederation ({
69+ name: ' rslib_provider' ,
70+ exposes: {
71+ // add expose here
72+ },
73+ // can not add 'remote' here, because you may build 'esm' or 'cjs' assets in one build.
74+ // if you want the Rslib package use remote module, please see below.
75+ shared: {
76+ react: {
77+ singleton: true ,
78+ },
79+ ' react-dom' : {
80+ singleton: true ,
81+ },
82+ },
83+ }),
84+ ],
8285});
8386```
8487
Original file line number Diff line number Diff line change @@ -51,24 +51,6 @@ export default defineConfig({
5151 dev: {
5252 assetPrefix: ' http://localhost:3001/mf' ,
5353 },
54- plugins: [
55- pluginModuleFederation ({
56- name: ' rslib_provider' ,
57- exposes: {
58- // 这里添加 expose
59- },
60- // 此处无法添加 "remote",因为你可能会在一次构建中构建 "esm" 或 "cjs" 产物。
61- // 如果你希望 Rslib 包使用远程模块,请参考下面。
62- shared: {
63- react: {
64- singleton: true ,
65- },
66- ' react-dom' : {
67- singleton: true ,
68- },
69- },
70- }),
71- ],
7254 },
7355 ],
7456 // Storybook 在 dev 下使用
@@ -78,7 +60,25 @@ export default defineConfig({
7860 output: {
7961 target: ' web' ,
8062 },
81- plugins: [pluginReact ()],
63+ plugins: [
64+ pluginReact ()
65+ pluginModuleFederation ({
66+ name: ' rslib_provider' ,
67+ exposes: {
68+ // 这里添加 expose
69+ },
70+ // 此处无法添加 "remote",因为你可能会在一次构建中构建 "esm" 或 "cjs" 产物。
71+ // 如果你希望 Rslib 包使用远程模块,请参考下面。
72+ shared: {
73+ react: {
74+ singleton: true ,
75+ },
76+ ' react-dom' : {
77+ singleton: true ,
78+ },
79+ },
80+ }),
81+ ],
8282});
8383```
8484
You can’t perform that action at this time.
0 commit comments