@module-federation/node 0.0.0-next-20240922002332 → 0.0.0-next-20240923034121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -20
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -35,9 +35,10 @@ 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
|
+
|
|
38
39
|
### Use as Runtime Plugin
|
|
39
40
|
|
|
40
|
-
`module-federation/enhanced` supports runtime plugins.
|
|
41
|
+
`module-federation/enhanced` supports runtime plugins.
|
|
41
42
|
|
|
42
43
|
```js
|
|
43
44
|
const { ModuleFederationPlugin } = require('@module-federation/enhanced');
|
|
@@ -45,40 +46,37 @@ const { ModuleFederationPlugin } = require('@module-federation/enhanced');
|
|
|
45
46
|
const options = {
|
|
46
47
|
target: 'async-node',
|
|
47
48
|
output: {
|
|
48
|
-
chunkFilename: '[id]-[chunkhash].js' // important to hash chunks
|
|
49
|
+
chunkFilename: '[id]-[chunkhash].js', // important to hash chunks
|
|
49
50
|
},
|
|
50
51
|
plugins: [
|
|
51
52
|
new ModuleFederationPlugin({
|
|
52
53
|
name: 'app1',
|
|
53
54
|
exposes: {},
|
|
54
55
|
remotes: {
|
|
55
|
-
app2: 'app2@http://'
|
|
56
|
+
app2: 'app2@http://',
|
|
56
57
|
},
|
|
57
|
-
runtimePlugins: [
|
|
58
|
-
require.resolve('@module-federation/node/runtimePlugin')
|
|
59
|
-
],
|
|
58
|
+
runtimePlugins: [require.resolve('@module-federation/node/runtimePlugin')],
|
|
60
59
|
remoteType: 'script',
|
|
61
|
-
library: { type: 'commonjs-module', name: 'app1' }
|
|
62
|
-
})
|
|
63
|
-
]
|
|
60
|
+
library: { type: 'commonjs-module', name: 'app1' },
|
|
61
|
+
}),
|
|
62
|
+
],
|
|
64
63
|
};
|
|
65
|
-
|
|
66
64
|
```
|
|
67
65
|
|
|
68
66
|
or you can enable it with some presets via UniversalFederation
|
|
69
67
|
|
|
70
68
|
```js
|
|
71
69
|
new UniversalFederationPlugin({
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
name: 'website2',
|
|
71
|
+
library: { type: 'commonjs-module' },
|
|
72
|
+
isServer: true, // or false
|
|
73
|
+
remotes: {},
|
|
74
|
+
filename: 'remoteEntry.js',
|
|
75
|
+
useRuntimePlugin: true, // uses the module-federation/enhanced runtime plugin api
|
|
76
|
+
exposes: {
|
|
77
|
+
'./SharedComponent': './remoteServer/SharedComponent',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
82
80
|
```
|
|
83
81
|
|
|
84
82
|
### UniversalFederationPlugin
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"public": true,
|
|
3
3
|
"name": "@module-federation/node",
|
|
4
|
-
"version": "0.0.0-next-
|
|
4
|
+
"version": "0.0.0-next-20240923034121",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"btoa": "1.2.1",
|
|
65
65
|
"encoding": "^0.1.13",
|
|
66
66
|
"node-fetch": "2.7.0",
|
|
67
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
68
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
69
|
-
"@module-federation/utilities": "0.0.0-next-
|
|
70
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
67
|
+
"@module-federation/enhanced": "0.0.0-next-20240923034121",
|
|
68
|
+
"@module-federation/sdk": "0.0.0-next-20240923034121",
|
|
69
|
+
"@module-federation/utilities": "0.0.0-next-20240923034121",
|
|
70
|
+
"@module-federation/runtime": "0.0.0-next-20240923034121"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"react": "^16||^17||^18",
|