File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1
1
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
2
2
const { FederatedTypesPlugin } = require ( '@module-federation/typescript' ) ;
3
+ const { container } = require ( 'webpack' ) ;
4
+ const { ModuleFederationPlugin } = container ;
3
5
const path = require ( 'path' ) ;
4
6
5
7
const pkg = require ( './package.json' ) ;
@@ -37,6 +39,28 @@ module.exports = {
37
39
] ,
38
40
} ,
39
41
plugins : [
42
+ // Define federation config once and use for both plugins
43
+ new ModuleFederationPlugin ( {
44
+ name : 'app1' ,
45
+ filename : 'remoteEntry.js' ,
46
+ remotes : {
47
+ app2 : 'app2@http://localhost:3002/remoteEntry.js' ,
48
+ } ,
49
+ shared : [
50
+ {
51
+ react : {
52
+ singleton : true ,
53
+ requiredVersion : pkg . dependencies . react ,
54
+ } ,
55
+ } ,
56
+ {
57
+ 'react-dom' : {
58
+ singleton : true ,
59
+ requiredVersion : pkg . dependencies [ 'react-dom' ] ,
60
+ } ,
61
+ } ,
62
+ ] ,
63
+ } ) ,
40
64
new FederatedTypesPlugin ( {
41
65
federationConfig : {
42
66
name : 'app1' ,
Original file line number Diff line number Diff line change 1
1
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
2
2
const { FederatedTypesPlugin } = require ( '@module-federation/typescript' ) ;
3
+ const { container } = require ( 'webpack' ) ;
4
+ const { ModuleFederationPlugin } = container ;
3
5
const path = require ( 'path' ) ;
4
6
5
7
const pkg = require ( './package.json' ) ;
@@ -37,6 +39,27 @@ module.exports = {
37
39
] ,
38
40
} ,
39
41
plugins : [
42
+ new ModuleFederationPlugin ( {
43
+ name : 'app2' ,
44
+ filename : 'remoteEntry.js' ,
45
+ exposes : {
46
+ './Button' : './src/Button' ,
47
+ } ,
48
+ shared : [
49
+ {
50
+ react : {
51
+ singleton : true ,
52
+ requiredVersion : pkg . dependencies . react ,
53
+ } ,
54
+ } ,
55
+ {
56
+ 'react-dom' : {
57
+ singleton : true ,
58
+ requiredVersion : pkg . dependencies [ 'react-dom' ] ,
59
+ } ,
60
+ } ,
61
+ ] ,
62
+ } ) ,
40
63
new FederatedTypesPlugin ( {
41
64
federationConfig : {
42
65
name : 'app2' ,
You can’t perform that action at this time.
0 commit comments