File tree Expand file tree Collapse file tree 2 files changed +32
-18
lines changed Expand file tree Collapse file tree 2 files changed +32
-18
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
2
2
const ModuleFederationPlugin = require ( 'webpack' ) . container . ModuleFederationPlugin ;
3
3
const path = require ( 'path' ) ;
4
4
5
+ const deps = require ( './package.json' ) . dependencies ;
6
+
5
7
module . exports = {
6
8
entry : './src/index' ,
7
9
mode : 'development' ,
@@ -42,16 +44,21 @@ module.exports = {
42
44
remotes : {
43
45
app2 : 'app2@http://localhost:3002/remoteEntry.js' ,
44
46
} ,
45
- shared : [
46
- ' react' ,
47
- 'react-dom' ,
48
- {
49
- 'shared-context_shared-library' : {
50
- import : 'shared-context_shared-library' ,
51
- requiredVersion : require ( '../shared-library/package.json' ) . version ,
52
- } ,
47
+ shared : {
48
+ react : {
49
+ singleton : true ,
50
+ requiredVersion : deps . react ,
51
+ } ,
52
+ 'react-dom' : {
53
+ singleton : true ,
54
+ requiredVersion : deps [ 'react-dom' ] ,
53
55
} ,
54
- ] ,
56
+ 'shared-context_shared-library' : {
57
+ import : 'shared-context_shared-library' ,
58
+ requiredVersion : require ( '../shared-library/package.json' ) . version ,
59
+ singleton : true ,
60
+ } ,
61
+ } ,
55
62
} ) ,
56
63
new HtmlWebpackPlugin ( {
57
64
template : './public/index.html' ,
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
2
2
const ModuleFederationPlugin = require ( 'webpack' ) . container . ModuleFederationPlugin ;
3
3
const path = require ( 'path' ) ;
4
4
5
+ const deps = require ( './package.json' ) . dependencies ;
6
+
5
7
module . exports = {
6
8
entry : './src/index' ,
7
9
mode : 'development' ,
@@ -43,16 +45,21 @@ module.exports = {
43
45
exposes : {
44
46
'./Welcome' : './src/Welcome' ,
45
47
} ,
46
- shared : [
47
- ' react' ,
48
- 'react-dom' ,
49
- {
50
- 'shared-context_shared-library' : {
51
- import : 'shared-context_shared-library' ,
52
- requiredVersion : require ( '../shared-library/package.json' ) . version ,
53
- } ,
48
+ shared : {
49
+ react : {
50
+ singleton : true ,
51
+ requiredVersion : deps . react ,
52
+ } ,
53
+ 'react-dom' : {
54
+ singleton : true ,
55
+ requiredVersion : deps [ 'react-dom' ] ,
54
56
} ,
55
- ] ,
57
+ 'shared-context_shared-library' : {
58
+ import : 'shared-context_shared-library' ,
59
+ requiredVersion : require ( '../shared-library/package.json' ) . version ,
60
+ singleton : true ,
61
+ } ,
62
+ } ,
56
63
} ) ,
57
64
new HtmlWebpackPlugin ( {
58
65
template : './public/index.html' ,
You can’t perform that action at this time.
0 commit comments