@@ -39,8 +39,6 @@ module.exports = {
39
39
filename: ' remoteEntry.js' ,
40
40
remotes: {
41
41
app2: " app2@http://localhost:9002/remoteEntry.js" ,
42
- " react-router" : " app4reactRouter@https://unpkg.com/react-router@6.4.3/dist/umd/react-router.production.min.js" ,
43
- " @remix-run/router" : " app5remixRouter@https://unpkg.com/@remix-run/router@1.0.3/dist/router.umd.min.js"
44
42
},
45
43
exposes: {
46
44
' ./App' : ' ./src/App' ,
@@ -49,9 +47,9 @@ module.exports = {
49
47
}),
50
48
new UmdPlugin ({
51
49
// The matched remotes are loaded in umd mode
52
- includeRemotes : [ / react-router / , " @remix-run/router " ],
53
- dependencies : {
54
- automatic : [ " shareScopes " , " remotes " ],
50
+ remotes : {
51
+ " react-router " : " app4reactRouter@https://unpkg.com/react-router@6.4.3/dist/umd/react-router.production.min.js " ,
52
+ " @remix-run/router " : " app5remixRouter@https://unpkg.com/@remix-run/router@1.0.3/dist/router.umd.min.js "
55
53
}
56
54
}),
57
55
new UmdPlugin ({
@@ -66,8 +64,7 @@ module.exports = {
66
64
67
65
| options | desc | interface | default | examles |
68
66
| -------------------------------| -------------------------------------------------------------------------------------------| :-----------------------------------------------| -----------------------------------| :--------------------------------------------------|
69
- | includeRemotes | match umd remotes | Array<RegExp \| string> | string> | string> |
70
- | excludeRemotes | exclude umd remotes | Array<RegExp \| string> | string> | string> |
67
+ | remotes | umd remotes | { remoteKey: "{global}@{url}" } | {} | string> |
71
68
| dependencies.automatic | Automatically match dependencies with the same name in remotes and shared | enum array | [ "shareScopes", "remotes"] | |
72
69
| dependencies.referenceShares | umd dependencies use by shares | refer to __ * shared* __ config | {} | {react: {singleton: true, requiredVersion: "17"}} |
73
70
| dependencies.referenceRemotes | umd dependencies use by remotes | Map<string, string> | {} | {react: "app5"} |
@@ -100,12 +97,10 @@ const {UniversalModuleFederationPlugin} = require("universal-module-federation-p
100
97
101
98
plugins: [
102
99
new UniversalModuleFederationPlugin ({
103
- includeRemotes: [/ . * / ],
104
- excludeRemotes: [],
100
+ remotes: {},
105
101
runtimeInject: {
106
102
injectVars: {},
107
103
initial : () => {},
108
- beforeImport (url , options ) {},
109
104
import (url , options ) {}
110
105
}
111
106
})
@@ -117,8 +112,7 @@ plugins: [
117
112
// webpack.config.js
118
113
plugins: [
119
114
new UniversalModuleFederationPlugin ({
120
- includeRemotes: [/ . * / ],
121
- excludeRemotes: [],
115
+ remotes: { app2: " app2@http://xxx.js" },
122
116
runtimeInject: {
123
117
// You can access "__umf__.$injectVars.testInjectVar" in any of the following runtime hooks
124
118
injectVars: {
@@ -160,14 +154,13 @@ plugins: [
160
154
161
155
## UniversalModuleFederationPlugin API
162
156
163
- | options | desc | default | examles |
164
- | ----------------------------------------------| ------------------------------------------------------------------------------------------------| ---------| :--------------------|
165
- | includeRemotes | match umf remotes | [ ] | [ /umf-app/, "app3"] |
166
- | excludeRemotes | exclude umf remotes | [ ] | [ "app2"] |
167
- | runtimeInject.injectVars | Inject variables for other runtime hooks, any runtime hook can using "\_\_ umf\_\_ .$injectVars" | {} | {test: 123} |
168
- | runtimeInject.initial(): promise | initial runtime hooks | [ ] | |
169
- | runtimeInject.beforeImport(url, options): promise <url > | Triggered before each remote is introduced | [ ] | |
170
- | runtimeInject.import(url, options): promise <module > | Introduce the hook of remote, need to return a container{init, get} | [ ] | |
157
+ | options | desc | default | examles |
158
+ | -------------------------------------------------------| ------------------------------------------------------------------------------------------------| ----------------------------------| :---------------------------|
159
+ | remotes | umf remotes | { remoteKey: "{global}@{url}" } | {app2: "app@http://xx.js"} |
160
+ | runtimeInject.injectVars | Inject variables for other runtime hooks, any runtime hook can using "\_\_ umf\_\_ .$injectVars" | {} | {test: 123} |
161
+ | runtimeInject.initial(): promise | initial runtime hooks | [ ] | |
162
+ | runtimeInject.beforeImport(url, options): promise <url > | Triggered before each remote is introduced | [ ] | |
163
+ | runtimeInject.import(url, options): promise <module > | Introduce the hook of remote, need to return a container{init, get} | [ ] | |
171
164
172
165
#### \_\_ umf\_\_
173
166
@@ -195,17 +188,15 @@ const {UniversalModuleFederationPlugin} = require("universal-module-federation-p
195
188
module .exports = {
196
189
plugins: [
197
190
new ModuleFederationPlugin ({
198
- // ...,
191
+ shared: { react: { singleton: true } },
192
+ }),
193
+ new UniversalModuleFederationPlugin ({
199
194
remotes: {
200
195
// 1: {name}@{url}
201
196
// 2: {name}@{dynamic semver remote}
202
197
app2: " app2@http://localhost:3000/remoteEntry.js" ,
203
198
" mf-app-01" : " mfapp01@mf-app-01@1.0.2/dist/remoteEntry.js"
204
199
},
205
- shared: { react: { singleton: true } },
206
- }),
207
- new UniversalModuleFederationPlugin ({
208
- includeRemotes: [/ . / ],
209
200
runtimeInject: {
210
201
resolvePath ({name, version, entry, query}) {
211
202
return ` https://cdn.jsdelivr.net/npm/${ name} @${ version} /${ entry} ?${ query} `
0 commit comments