@modern-js/plugin-garfish 2.14.0 → 2.16.0
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/CHANGELOG.md +27 -0
- package/dist/cjs/cli/index.js +224 -236
- package/dist/cjs/cli/utils.js +24 -48
- package/dist/cjs/deps/index.js +12 -35
- package/dist/cjs/index.js +26 -36
- package/dist/cjs/runtime/index.js +24 -44
- package/dist/cjs/runtime/loadable.js +46 -58
- package/dist/cjs/runtime/plugin.js +86 -82
- package/dist/cjs/runtime/useModuleApps.js +70 -56
- package/dist/cjs/runtime/utils/Context.js +18 -36
- package/dist/cjs/runtime/utils/MApp.js +88 -87
- package/dist/cjs/runtime/utils/apps.js +114 -94
- package/dist/cjs/runtime/utils/setExternal.js +23 -41
- package/dist/cjs/util.js +21 -40
- package/dist/esm/cli/index.js +409 -402
- package/dist/esm/cli/utils.js +25 -26
- package/dist/esm/deps/index.js +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/runtime/index.js +3 -4
- package/dist/esm/runtime/loadable.js +226 -210
- package/dist/esm/runtime/plugin.js +456 -426
- package/dist/esm/runtime/useModuleApps.js +49 -50
- package/dist/esm/runtime/utils/Context.js +1 -1
- package/dist/esm/runtime/utils/MApp.js +337 -316
- package/dist/esm/runtime/utils/apps.js +468 -442
- package/dist/esm/runtime/utils/setExternal.js +9 -9
- package/dist/esm/util.js +4 -5
- package/dist/esm-node/cli/index.js +209 -219
- package/dist/esm-node/cli/utils.js +15 -30
- package/dist/esm-node/deps/index.js +1 -4
- package/dist/esm-node/index.js +1 -4
- package/dist/esm-node/runtime/index.js +3 -10
- package/dist/esm-node/runtime/loadable.js +34 -31
- package/dist/esm-node/runtime/plugin.js +50 -33
- package/dist/esm-node/runtime/useModuleApps.js +12 -19
- package/dist/esm-node/runtime/utils/Context.js +2 -5
- package/dist/esm-node/runtime/utils/MApp.js +61 -40
- package/dist/esm-node/runtime/utils/apps.js +38 -44
- package/dist/esm-node/runtime/utils/setExternal.js +5 -5
- package/dist/esm-node/util.js +4 -9
- package/package.json +15 -12
package/dist/esm/cli/index.js
CHANGED
|
@@ -1,422 +1,429 @@
|
|
|
1
1
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(void 0);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
function _define_property(obj, key, value) {
|
|
31
|
+
if (key in obj) {
|
|
32
|
+
Object.defineProperty(obj, key, {
|
|
33
|
+
value,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
obj[key] = value;
|
|
40
|
+
}
|
|
41
|
+
return obj;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
ownKeys.forEach(function(key) {
|
|
53
|
-
_defineProperty(target, key, source[key]);
|
|
54
|
-
});
|
|
43
|
+
function _object_spread(target) {
|
|
44
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
45
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
+
var ownKeys = Object.keys(source);
|
|
47
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
+
}));
|
|
55
51
|
}
|
|
56
|
-
|
|
52
|
+
ownKeys.forEach(function(key) {
|
|
53
|
+
_define_property(target, key, source[key]);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return target;
|
|
57
57
|
}
|
|
58
|
-
var __generator =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
var __generator = function(thisArg, body) {
|
|
59
|
+
var f, y, t, g, _ = {
|
|
60
|
+
label: 0,
|
|
61
|
+
sent: function() {
|
|
62
|
+
if (t[0] & 1)
|
|
63
|
+
throw t[1];
|
|
64
|
+
return t[1];
|
|
65
|
+
},
|
|
66
|
+
trys: [],
|
|
67
|
+
ops: []
|
|
68
|
+
};
|
|
69
|
+
return g = {
|
|
70
|
+
next: verb(0),
|
|
71
|
+
"throw": verb(1),
|
|
72
|
+
"return": verb(2)
|
|
73
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
74
|
+
return this;
|
|
75
|
+
}), g;
|
|
76
|
+
function verb(n) {
|
|
77
|
+
return function(v) {
|
|
78
|
+
return step([
|
|
79
|
+
n,
|
|
80
|
+
v
|
|
81
|
+
]);
|
|
67
82
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
break;
|
|
96
|
-
case 4:
|
|
97
|
-
_.label++;
|
|
98
|
-
return {
|
|
99
|
-
value: op[1],
|
|
100
|
-
done: false
|
|
101
|
-
};
|
|
102
|
-
case 5:
|
|
103
|
-
_.label++;
|
|
104
|
-
y = op[1];
|
|
105
|
-
op = [
|
|
106
|
-
0
|
|
107
|
-
];
|
|
108
|
-
continue;
|
|
109
|
-
case 7:
|
|
110
|
-
op = _.ops.pop();
|
|
111
|
-
_.trys.pop();
|
|
112
|
-
continue;
|
|
113
|
-
default:
|
|
114
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
115
|
-
_ = 0;
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
119
|
-
_.label = op[1];
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
123
|
-
_.label = t[1];
|
|
124
|
-
t = op;
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
if (t && _.label < t[2]) {
|
|
128
|
-
_.label = t[2];
|
|
129
|
-
_.ops.push(op);
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
if (t[2]) _.ops.pop();
|
|
133
|
-
_.trys.pop();
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
op = body.call(thisArg, _);
|
|
137
|
-
} catch (e) {
|
|
83
|
+
}
|
|
84
|
+
function step(op) {
|
|
85
|
+
if (f)
|
|
86
|
+
throw new TypeError("Generator is already executing.");
|
|
87
|
+
while (_)
|
|
88
|
+
try {
|
|
89
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
90
|
+
return t;
|
|
91
|
+
if (y = 0, t)
|
|
92
|
+
op = [
|
|
93
|
+
op[0] & 2,
|
|
94
|
+
t.value
|
|
95
|
+
];
|
|
96
|
+
switch (op[0]) {
|
|
97
|
+
case 0:
|
|
98
|
+
case 1:
|
|
99
|
+
t = op;
|
|
100
|
+
break;
|
|
101
|
+
case 4:
|
|
102
|
+
_.label++;
|
|
103
|
+
return {
|
|
104
|
+
value: op[1],
|
|
105
|
+
done: false
|
|
106
|
+
};
|
|
107
|
+
case 5:
|
|
108
|
+
_.label++;
|
|
109
|
+
y = op[1];
|
|
138
110
|
op = [
|
|
139
|
-
|
|
140
|
-
e
|
|
111
|
+
0
|
|
141
112
|
];
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
113
|
+
continue;
|
|
114
|
+
case 7:
|
|
115
|
+
op = _.ops.pop();
|
|
116
|
+
_.trys.pop();
|
|
117
|
+
continue;
|
|
118
|
+
default:
|
|
119
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
120
|
+
_ = 0;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
124
|
+
_.label = op[1];
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
128
|
+
_.label = t[1];
|
|
129
|
+
t = op;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
if (t && _.label < t[2]) {
|
|
133
|
+
_.label = t[2];
|
|
134
|
+
_.ops.push(op);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
if (t[2])
|
|
138
|
+
_.ops.pop();
|
|
139
|
+
_.trys.pop();
|
|
140
|
+
continue;
|
|
145
141
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
142
|
+
op = body.call(thisArg, _);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
op = [
|
|
145
|
+
6,
|
|
146
|
+
e
|
|
147
|
+
];
|
|
148
|
+
y = 0;
|
|
149
|
+
} finally {
|
|
150
|
+
f = t = 0;
|
|
151
|
+
}
|
|
152
|
+
if (op[0] & 5)
|
|
153
|
+
throw op[1];
|
|
154
|
+
return {
|
|
155
|
+
value: op[0] ? op[1] : void 0,
|
|
156
|
+
done: true
|
|
157
|
+
};
|
|
158
|
+
}
|
|
152
159
|
};
|
|
153
160
|
import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from "@modern-js/utils";
|
|
154
161
|
import { logger } from "../util";
|
|
155
162
|
import { getRuntimeConfig, makeProvider, makeRenderFunction, setRuntimeConfig, generateAsyncEntry } from "./utils";
|
|
156
|
-
var externals = {
|
|
157
|
-
|
|
158
|
-
|
|
163
|
+
export var externals = {
|
|
164
|
+
"react-dom": "react-dom",
|
|
165
|
+
react: "react"
|
|
159
166
|
};
|
|
160
|
-
function getDefaultMicroFrontedConfig(microFrontend) {
|
|
161
|
-
|
|
162
|
-
return {
|
|
163
|
-
enableHtmlEntry: true,
|
|
164
|
-
externalBasicLibrary: false,
|
|
165
|
-
moduleApp: ""
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
return _objectSpread({
|
|
169
|
-
enableHtmlEntry: true,
|
|
170
|
-
externalBasicLibrary: false
|
|
171
|
-
}, microFrontend);
|
|
172
|
-
}
|
|
173
|
-
var cli_default = function() {
|
|
174
|
-
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref_pluginName = _ref.pluginName, pluginName = _ref_pluginName === void 0 ? "@modern-js/plugin-garfish" : _ref_pluginName, _ref_runtimePluginName = _ref.runtimePluginName, runtimePluginName = _ref_runtimePluginName === void 0 ? "@modern-js/runtime/plugins" : _ref_runtimePluginName;
|
|
167
|
+
export function getDefaultMicroFrontedConfig(microFrontend) {
|
|
168
|
+
if (microFrontend === true) {
|
|
175
169
|
return {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
};
|
|
291
|
-
},
|
|
292
|
-
addRuntimeExports: function addRuntimeExports() {
|
|
293
|
-
var config = useResolvedConfigContext();
|
|
294
|
-
var masterApp = getRuntimeConfig(config).masterApp;
|
|
295
|
-
if (masterApp) {
|
|
296
|
-
var addExportStatement = "export { default as garfish, default as masterApp } from '".concat(pluginName, "/runtime'");
|
|
297
|
-
logger("exportStatement", addExportStatement);
|
|
298
|
-
pluginsExportsUtils.addExport(addExportStatement);
|
|
299
|
-
}
|
|
300
|
-
var otherExportStatement = "export { hoistNonReactStatics } from '".concat(pluginName, "/deps'");
|
|
301
|
-
logger("otherExportStatement", otherExportStatement);
|
|
302
|
-
pluginsExportsUtils.addExport(otherExportStatement);
|
|
303
|
-
},
|
|
304
|
-
modifyEntryImports: function modifyEntryImports(param) {
|
|
305
|
-
var entrypoint = param.entrypoint, imports = param.imports;
|
|
306
|
-
var config = useResolvedConfigContext();
|
|
307
|
-
var masterApp = getRuntimeConfig(config).masterApp;
|
|
308
|
-
if (masterApp) {
|
|
309
|
-
imports.push({
|
|
310
|
-
value: runtimePluginName,
|
|
311
|
-
specifiers: [
|
|
312
|
-
{
|
|
313
|
-
imported: "garfish"
|
|
314
|
-
}
|
|
315
|
-
]
|
|
316
|
-
});
|
|
317
|
-
imports.push({
|
|
318
|
-
value: runtimePluginName,
|
|
319
|
-
specifiers: [
|
|
320
|
-
{
|
|
321
|
-
imported: "masterApp"
|
|
322
|
-
}
|
|
323
|
-
]
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
imports.push({
|
|
327
|
-
value: runtimePluginName,
|
|
328
|
-
specifiers: [
|
|
329
|
-
{
|
|
330
|
-
imported: "hoistNonReactStatics"
|
|
331
|
-
}
|
|
332
|
-
]
|
|
333
|
-
});
|
|
334
|
-
imports.push({
|
|
335
|
-
value: "react-dom",
|
|
336
|
-
specifiers: [
|
|
337
|
-
{
|
|
338
|
-
imported: "unmountComponentAtNode"
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
imported: "createPortal"
|
|
342
|
-
}
|
|
343
|
-
]
|
|
170
|
+
enableHtmlEntry: true,
|
|
171
|
+
externalBasicLibrary: false,
|
|
172
|
+
moduleApp: ""
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return _object_spread({
|
|
176
|
+
enableHtmlEntry: true,
|
|
177
|
+
externalBasicLibrary: false
|
|
178
|
+
}, microFrontend);
|
|
179
|
+
}
|
|
180
|
+
export default function() {
|
|
181
|
+
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref_pluginName = _ref.pluginName, pluginName = _ref_pluginName === void 0 ? "@modern-js/plugin-garfish" : _ref_pluginName, _ref_runtimePluginName = _ref.runtimePluginName, runtimePluginName = _ref_runtimePluginName === void 0 ? "@modern-js/runtime/plugins" : _ref_runtimePluginName;
|
|
182
|
+
return {
|
|
183
|
+
name: "@modern-js/plugin-garfish",
|
|
184
|
+
setup: function(param) {
|
|
185
|
+
var useAppContext = param.useAppContext, useResolvedConfigContext = param.useResolvedConfigContext, useConfigContext = param.useConfigContext;
|
|
186
|
+
var pluginsExportsUtils;
|
|
187
|
+
return {
|
|
188
|
+
validateSchema: function validateSchema() {
|
|
189
|
+
return PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
|
|
190
|
+
},
|
|
191
|
+
resolvedConfig: function() {
|
|
192
|
+
var _ref2 = _async_to_generator(function(config) {
|
|
193
|
+
var resolved, _getRuntimeConfig, masterApp, router, nConfig, _useConfig_server, _router_historyOptions, useConfig, baseUrl;
|
|
194
|
+
return __generator(this, function(_state) {
|
|
195
|
+
resolved = config.resolved;
|
|
196
|
+
_getRuntimeConfig = getRuntimeConfig(resolved), masterApp = _getRuntimeConfig.masterApp, router = _getRuntimeConfig.router;
|
|
197
|
+
nConfig = {
|
|
198
|
+
resolved: _object_spread({}, resolved)
|
|
199
|
+
};
|
|
200
|
+
if (masterApp) {
|
|
201
|
+
;
|
|
202
|
+
useConfig = useConfigContext();
|
|
203
|
+
baseUrl = useConfig === null || useConfig === void 0 ? void 0 : (_useConfig_server = useConfig.server) === null || _useConfig_server === void 0 ? void 0 : _useConfig_server.baseUrl;
|
|
204
|
+
if (Array.isArray(baseUrl)) {
|
|
205
|
+
throw new Error("Now Micro-Front-End mode dose not support multiple baseUrl, you can set it as a string");
|
|
206
|
+
}
|
|
207
|
+
setRuntimeConfig(nConfig.resolved, "masterApp", Object.assign(typeof masterApp === "object" ? _object_spread({}, masterApp) : {}, {
|
|
208
|
+
basename: baseUrl || (router === null || router === void 0 ? void 0 : (_router_historyOptions = router.historyOptions) === null || _router_historyOptions === void 0 ? void 0 : _router_historyOptions.basename) || (router === null || router === void 0 ? void 0 : router.basename) || "/"
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
logger("resolvedConfig", {
|
|
212
|
+
output: nConfig.resolved.output,
|
|
213
|
+
runtime: nConfig.resolved.runtime,
|
|
214
|
+
deploy: nConfig.resolved.deploy,
|
|
215
|
+
server: nConfig.resolved.server
|
|
216
|
+
});
|
|
217
|
+
return [
|
|
218
|
+
2,
|
|
219
|
+
nConfig
|
|
220
|
+
];
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
return function(config) {
|
|
224
|
+
return _ref2.apply(this, arguments);
|
|
225
|
+
};
|
|
226
|
+
}(),
|
|
227
|
+
config: function config() {
|
|
228
|
+
var _useConfig_output, _useConfig_deploy;
|
|
229
|
+
var useConfig = useConfigContext();
|
|
230
|
+
logger("useConfig", useConfig);
|
|
231
|
+
var config2 = useAppContext();
|
|
232
|
+
pluginsExportsUtils = createRuntimeExportsUtils(config2.internalDirectory, "plugins");
|
|
233
|
+
var disableCssExtract = ((_useConfig_output = useConfig.output) === null || _useConfig_output === void 0 ? void 0 : _useConfig_output.disableCssExtract) || false;
|
|
234
|
+
if ((_useConfig_deploy = useConfig.deploy) === null || _useConfig_deploy === void 0 ? void 0 : _useConfig_deploy.microFrontend) {
|
|
235
|
+
var _useConfig_deploy1;
|
|
236
|
+
var enableHtmlEntry = getDefaultMicroFrontedConfig((_useConfig_deploy1 = useConfig.deploy) === null || _useConfig_deploy1 === void 0 ? void 0 : _useConfig_deploy1.microFrontend).enableHtmlEntry;
|
|
237
|
+
if (!enableHtmlEntry) {
|
|
238
|
+
disableCssExtract = true;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
output: {
|
|
243
|
+
disableCssExtract
|
|
244
|
+
},
|
|
245
|
+
source: {
|
|
246
|
+
alias: {
|
|
247
|
+
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
|
|
248
|
+
"@modern-js/runtime/garfish": "@modern-js/plugin-garfish/runtime"
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
tools: {
|
|
252
|
+
devServer: {
|
|
253
|
+
headers: {
|
|
254
|
+
"Access-Control-Allow-Origin": "*"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
webpackChain: function(chain, param2) {
|
|
258
|
+
var webpack = param2.webpack, env = param2.env, CHAIN_ID = param2.CHAIN_ID;
|
|
259
|
+
var _resolveOptions_deploy, _resolveWebpackConfig_resolve;
|
|
260
|
+
var resolveOptions = useResolvedConfigContext();
|
|
261
|
+
if (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
|
|
262
|
+
var _useConfig_dev, _resolveOptions_server, _resolveOptions_deploy1;
|
|
263
|
+
chain.output.libraryTarget("umd");
|
|
264
|
+
if (!((_useConfig_dev = useConfig.dev) === null || _useConfig_dev === void 0 ? void 0 : _useConfig_dev.assetPrefix) && (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_server = resolveOptions.server) === null || _resolveOptions_server === void 0 ? void 0 : _resolveOptions_server.port) && env === "development") {
|
|
265
|
+
chain.output.publicPath("//localhost:".concat(resolveOptions.server.port, "/"));
|
|
266
|
+
}
|
|
267
|
+
if (webpack.BannerPlugin) {
|
|
268
|
+
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [
|
|
269
|
+
{
|
|
270
|
+
banner: "Micro front-end"
|
|
271
|
+
}
|
|
272
|
+
]);
|
|
273
|
+
}
|
|
274
|
+
var _getDefaultMicroFrontedConfig = getDefaultMicroFrontedConfig((_resolveOptions_deploy1 = resolveOptions.deploy) === null || _resolveOptions_deploy1 === void 0 ? void 0 : _resolveOptions_deploy1.microFrontend), enableHtmlEntry2 = _getDefaultMicroFrontedConfig.enableHtmlEntry, externalBasicLibrary = _getDefaultMicroFrontedConfig.externalBasicLibrary;
|
|
275
|
+
if (externalBasicLibrary) {
|
|
276
|
+
chain.externals(externals);
|
|
277
|
+
}
|
|
278
|
+
if (!enableHtmlEntry2) {
|
|
279
|
+
chain.output.filename("index.js");
|
|
280
|
+
chain.plugins.delete("".concat(CHAIN_ID.PLUGIN.HTML, "-main"));
|
|
281
|
+
chain.optimization.runtimeChunk(false);
|
|
282
|
+
chain.optimization.splitChunks({
|
|
283
|
+
chunks: "async"
|
|
344
284
|
});
|
|
345
|
-
|
|
346
|
-
imports: imports,
|
|
347
|
-
entrypoint: entrypoint
|
|
348
|
-
};
|
|
349
|
-
},
|
|
350
|
-
modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param) {
|
|
351
|
-
var entrypoint = param.entrypoint, plugins = param.plugins;
|
|
352
|
-
var config = useResolvedConfigContext();
|
|
353
|
-
var masterApp = getRuntimeConfig(config).masterApp;
|
|
354
|
-
if (masterApp) {
|
|
355
|
-
logger("garfishPlugin options", masterApp);
|
|
356
|
-
plugins.push({
|
|
357
|
-
name: "garfish",
|
|
358
|
-
args: "masterApp",
|
|
359
|
-
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
return {
|
|
363
|
-
entrypoint: entrypoint,
|
|
364
|
-
plugins: plugins
|
|
365
|
-
};
|
|
366
|
-
},
|
|
367
|
-
modifyEntryRenderFunction: function modifyEntryRenderFunction(param) {
|
|
368
|
-
var entrypoint = param.entrypoint, code = param.code;
|
|
369
|
-
var _config_deploy;
|
|
370
|
-
var config = useResolvedConfigContext();
|
|
371
|
-
if (!(config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend)) {
|
|
372
|
-
return {
|
|
373
|
-
entrypoint: entrypoint,
|
|
374
|
-
code: code
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
var nCode = makeRenderFunction(code);
|
|
378
|
-
logger("makeRenderFunction", nCode);
|
|
379
|
-
return {
|
|
380
|
-
entrypoint: entrypoint,
|
|
381
|
-
code: nCode
|
|
382
|
-
};
|
|
383
|
-
},
|
|
384
|
-
modifyAsyncEntry: function modifyAsyncEntry(param) {
|
|
385
|
-
var entrypoint = param.entrypoint, code = param.code;
|
|
386
|
-
var _config_deploy, _config_source;
|
|
387
|
-
var config = useResolvedConfigContext();
|
|
388
|
-
var finalCode = code;
|
|
389
|
-
if ((config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) && (config === null || config === void 0 ? void 0 : (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.enableAsyncEntry)) {
|
|
390
|
-
finalCode = generateAsyncEntry(code);
|
|
391
|
-
return {
|
|
392
|
-
entrypoint: entrypoint,
|
|
393
|
-
code: "".concat(finalCode)
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
return {
|
|
397
|
-
entrypoint: entrypoint,
|
|
398
|
-
code: finalCode
|
|
399
|
-
};
|
|
400
|
-
},
|
|
401
|
-
modifyEntryExport: function modifyEntryExport(param) {
|
|
402
|
-
var entrypoint = param.entrypoint, exportStatement = param.exportStatement;
|
|
403
|
-
var _config_deploy;
|
|
404
|
-
var config = useResolvedConfigContext();
|
|
405
|
-
if (config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
|
|
406
|
-
var exportStatementCode = makeProvider();
|
|
407
|
-
logger("exportStatement", exportStatementCode);
|
|
408
|
-
return {
|
|
409
|
-
entrypoint: entrypoint,
|
|
410
|
-
exportStatement: exportStatementCode
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
return {
|
|
414
|
-
entrypoint: entrypoint,
|
|
415
|
-
exportStatement: exportStatement
|
|
416
|
-
};
|
|
285
|
+
}
|
|
417
286
|
}
|
|
287
|
+
var resolveWebpackConfig = chain.toConfig();
|
|
288
|
+
logger("webpackConfig", {
|
|
289
|
+
output: resolveWebpackConfig.output,
|
|
290
|
+
externals: resolveWebpackConfig.externals,
|
|
291
|
+
env,
|
|
292
|
+
alias: (_resolveWebpackConfig_resolve = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig_resolve === void 0 ? void 0 : _resolveWebpackConfig_resolve.alias,
|
|
293
|
+
plugins: resolveWebpackConfig.plugins
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
},
|
|
299
|
+
addRuntimeExports: function addRuntimeExports() {
|
|
300
|
+
var config = useResolvedConfigContext();
|
|
301
|
+
var masterApp = getRuntimeConfig(config).masterApp;
|
|
302
|
+
if (masterApp) {
|
|
303
|
+
var addExportStatement = "export { default as garfish, default as masterApp } from '".concat(pluginName, "/runtime'");
|
|
304
|
+
logger("exportStatement", addExportStatement);
|
|
305
|
+
pluginsExportsUtils.addExport(addExportStatement);
|
|
306
|
+
}
|
|
307
|
+
var otherExportStatement = "export { hoistNonReactStatics } from '".concat(pluginName, "/deps'");
|
|
308
|
+
logger("otherExportStatement", otherExportStatement);
|
|
309
|
+
pluginsExportsUtils.addExport(otherExportStatement);
|
|
310
|
+
},
|
|
311
|
+
modifyEntryImports: function modifyEntryImports(param2) {
|
|
312
|
+
var entrypoint = param2.entrypoint, imports = param2.imports;
|
|
313
|
+
var config = useResolvedConfigContext();
|
|
314
|
+
var masterApp = getRuntimeConfig(config).masterApp;
|
|
315
|
+
if (masterApp) {
|
|
316
|
+
imports.push({
|
|
317
|
+
value: runtimePluginName,
|
|
318
|
+
specifiers: [
|
|
319
|
+
{
|
|
320
|
+
imported: "garfish"
|
|
321
|
+
}
|
|
322
|
+
]
|
|
323
|
+
});
|
|
324
|
+
imports.push({
|
|
325
|
+
value: runtimePluginName,
|
|
326
|
+
specifiers: [
|
|
327
|
+
{
|
|
328
|
+
imported: "masterApp"
|
|
329
|
+
}
|
|
330
|
+
]
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
imports.push({
|
|
334
|
+
value: runtimePluginName,
|
|
335
|
+
specifiers: [
|
|
336
|
+
{
|
|
337
|
+
imported: "hoistNonReactStatics"
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
});
|
|
341
|
+
imports.push({
|
|
342
|
+
value: "react-dom",
|
|
343
|
+
specifiers: [
|
|
344
|
+
{
|
|
345
|
+
imported: "unmountComponentAtNode"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
imported: "createPortal"
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
});
|
|
352
|
+
return {
|
|
353
|
+
imports,
|
|
354
|
+
entrypoint
|
|
355
|
+
};
|
|
356
|
+
},
|
|
357
|
+
modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param2) {
|
|
358
|
+
var entrypoint = param2.entrypoint, plugins = param2.plugins;
|
|
359
|
+
var config = useResolvedConfigContext();
|
|
360
|
+
var masterApp = getRuntimeConfig(config).masterApp;
|
|
361
|
+
if (masterApp) {
|
|
362
|
+
logger("garfishPlugin options", masterApp);
|
|
363
|
+
plugins.push({
|
|
364
|
+
name: "garfish",
|
|
365
|
+
args: "masterApp",
|
|
366
|
+
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
return {
|
|
370
|
+
entrypoint,
|
|
371
|
+
plugins
|
|
372
|
+
};
|
|
373
|
+
},
|
|
374
|
+
modifyEntryRenderFunction: function modifyEntryRenderFunction(param2) {
|
|
375
|
+
var entrypoint = param2.entrypoint, code = param2.code;
|
|
376
|
+
var _config_deploy;
|
|
377
|
+
var config = useResolvedConfigContext();
|
|
378
|
+
if (!(config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend)) {
|
|
379
|
+
return {
|
|
380
|
+
entrypoint,
|
|
381
|
+
code
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
var nCode = makeRenderFunction(code);
|
|
385
|
+
logger("makeRenderFunction", nCode);
|
|
386
|
+
return {
|
|
387
|
+
entrypoint,
|
|
388
|
+
code: nCode
|
|
389
|
+
};
|
|
390
|
+
},
|
|
391
|
+
modifyAsyncEntry: function modifyAsyncEntry(param2) {
|
|
392
|
+
var entrypoint = param2.entrypoint, code = param2.code;
|
|
393
|
+
var _config_deploy, _config_source;
|
|
394
|
+
var config = useResolvedConfigContext();
|
|
395
|
+
var finalCode = code;
|
|
396
|
+
if ((config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) && (config === null || config === void 0 ? void 0 : (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.enableAsyncEntry)) {
|
|
397
|
+
finalCode = generateAsyncEntry(code);
|
|
398
|
+
return {
|
|
399
|
+
entrypoint,
|
|
400
|
+
code: "".concat(finalCode)
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
entrypoint,
|
|
405
|
+
code: finalCode
|
|
406
|
+
};
|
|
407
|
+
},
|
|
408
|
+
modifyEntryExport: function modifyEntryExport(param2) {
|
|
409
|
+
var entrypoint = param2.entrypoint, exportStatement = param2.exportStatement;
|
|
410
|
+
var _config_deploy;
|
|
411
|
+
var config = useResolvedConfigContext();
|
|
412
|
+
if (config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
|
|
413
|
+
var exportStatementCode = makeProvider();
|
|
414
|
+
logger("exportStatement", exportStatementCode);
|
|
415
|
+
return {
|
|
416
|
+
entrypoint,
|
|
417
|
+
exportStatement: exportStatementCode
|
|
418
418
|
};
|
|
419
|
+
}
|
|
420
|
+
return {
|
|
421
|
+
entrypoint,
|
|
422
|
+
exportStatement
|
|
423
|
+
};
|
|
419
424
|
}
|
|
420
|
-
|
|
421
|
-
}
|
|
422
|
-
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
;
|