@@ -35,6 +35,51 @@ yarn add @module-federation/node
35
35
## 🚀 Usage
36
36
37
37
There are two approaches to using the plugins exported from this package, dependent on your use case.
38
+ ### Use as Runtime Plugin
39
+
40
+ ` module-federation/enhanced ` supports runtime plugins.
41
+
42
+ ``` js
43
+ const { ModuleFederationPlugin } = require (' @module-federation/enhanced' );
44
+
45
+ const options = {
46
+ target: ' async-node' ,
47
+ output: {
48
+ chunkFilename: ' [id]-[chunkhash].js' // important to hash chunks
49
+ },
50
+ plugins: [
51
+ new ModuleFederationPlugin ({
52
+ name: ' app1' ,
53
+ exposes: {},
54
+ remotes: {
55
+ app2: ' app2@http://'
56
+ },
57
+ runtimePlugins: [
58
+ require .resolve (' @module-federation/node/runtimePlugin' )
59
+ ],
60
+ remoteType: ' script' ,
61
+ library: { type: ' commonjs-module' , name: ' app1' }
62
+ })
63
+ ]
64
+ };
65
+
66
+ ```
67
+
68
+ or you can enable it with some presets via UniversalFederation
69
+
70
+ ``` js
71
+ new UniversalFederationPlugin ({
72
+ name: ' website2' ,
73
+ library: { type: ' commonjs-module' },
74
+ isServer: true , // or false
75
+ remotes: {},
76
+ filename: ' remoteEntry.js' ,
77
+ useRuntimePlugin: true , // uses the module-federation/enhanced runtime plugin api
78
+ exposes: {
79
+ ' ./SharedComponent' : ' ./remoteServer/SharedComponent' ,
80
+ },
81
+ })
82
+ ```
38
83
39
84
### UniversalFederationPlugin
40
85
@@ -61,6 +106,7 @@ const config = {
61
106
isServer: true , // or false
62
107
remotes: {},
63
108
filename: ' remoteEntry.js' ,
109
+ useRuntimePlugin: true , // uses the module-federation/enhanced runtime plugins
64
110
exposes: {
65
111
' ./SharedComponent' : ' ./remoteServer/SharedComponent' ,
66
112
},
0 commit comments