@module-federation/manifest 0.0.0-next-20250926024003 → 0.0.0-refactor-manifest-20251013103938
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/dist/index.cjs.js +931 -1879
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +931 -1879
- package/dist/index.esm.js.map +1 -1
- package/dist/src/ManifestManager.d.ts +1 -3
- package/dist/src/ModuleHandler.d.ts +3 -0
- package/dist/src/StatsManager.d.ts +1 -3
- package/dist/src/StatsPlugin.d.ts +0 -1
- package/dist/src/utils.d.ts +0 -4
- package/package.json +4 -4
package/dist/index.cjs.js
CHANGED
|
@@ -1,286 +1,110 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var sdk = require('@module-federation/sdk');
|
|
3
4
|
var chalk = require('chalk');
|
|
4
5
|
var path = require('path');
|
|
5
|
-
var sdk = require('@module-federation/sdk');
|
|
6
6
|
var core = require('@module-federation/dts-plugin/core');
|
|
7
7
|
var fs = require('fs');
|
|
8
8
|
var managers = require('@module-federation/managers');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const PLUGIN_IDENTIFIER = 'Module Federation Manifest Plugin';
|
|
11
|
+
const HOT_UPDATE_SUFFIX = '.hot-update';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const createBundlerLogger = typeof sdk.createInfrastructureLogger === 'function'
|
|
14
|
+
? sdk.createInfrastructureLogger
|
|
15
|
+
: sdk.createLogger;
|
|
16
|
+
const logger = createBundlerLogger(chalk.cyan(`[ ${PLUGIN_IDENTIFIER} ]`));
|
|
14
17
|
|
|
15
|
-
function _array_like_to_array$2(arr, len) {
|
|
16
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
17
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
18
|
-
return arr2;
|
|
19
|
-
}
|
|
20
|
-
function _array_with_holes$2(arr) {
|
|
21
|
-
if (Array.isArray(arr)) return arr;
|
|
22
|
-
}
|
|
23
|
-
function _array_without_holes$1(arr) {
|
|
24
|
-
if (Array.isArray(arr)) return _array_like_to_array$2(arr);
|
|
25
|
-
}
|
|
26
|
-
function _define_property$2(obj, key, value) {
|
|
27
|
-
if (key in obj) {
|
|
28
|
-
Object.defineProperty(obj, key, {
|
|
29
|
-
value: value,
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
obj[key] = value;
|
|
36
|
-
}
|
|
37
|
-
return obj;
|
|
38
|
-
}
|
|
39
|
-
function _iterable_to_array$1(iter) {
|
|
40
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
41
|
-
}
|
|
42
|
-
function _iterable_to_array_limit$2(arr, i) {
|
|
43
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
44
|
-
if (_i == null) return;
|
|
45
|
-
var _arr = [];
|
|
46
|
-
var _n = true;
|
|
47
|
-
var _d = false;
|
|
48
|
-
var _s, _e;
|
|
49
|
-
try {
|
|
50
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
51
|
-
_arr.push(_s.value);
|
|
52
|
-
if (i && _arr.length === i) break;
|
|
53
|
-
}
|
|
54
|
-
} catch (err) {
|
|
55
|
-
_d = true;
|
|
56
|
-
_e = err;
|
|
57
|
-
} finally{
|
|
58
|
-
try {
|
|
59
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
60
|
-
} finally{
|
|
61
|
-
if (_d) throw _e;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return _arr;
|
|
65
|
-
}
|
|
66
|
-
function _non_iterable_rest$2() {
|
|
67
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
68
|
-
}
|
|
69
|
-
function _non_iterable_spread$1() {
|
|
70
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
71
|
-
}
|
|
72
|
-
function _object_spread$2(target) {
|
|
73
|
-
for(var i = 1; i < arguments.length; i++){
|
|
74
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
75
|
-
var ownKeys = Object.keys(source);
|
|
76
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
77
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
78
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
ownKeys.forEach(function(key) {
|
|
82
|
-
_define_property$2(target, key, source[key]);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return target;
|
|
86
|
-
}
|
|
87
|
-
function ownKeys$2(object, enumerableOnly) {
|
|
88
|
-
var keys = Object.keys(object);
|
|
89
|
-
if (Object.getOwnPropertySymbols) {
|
|
90
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
91
|
-
keys.push.apply(keys, symbols);
|
|
92
|
-
}
|
|
93
|
-
return keys;
|
|
94
|
-
}
|
|
95
|
-
function _object_spread_props$2(target, source) {
|
|
96
|
-
source = source != null ? source : {};
|
|
97
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
98
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
99
|
-
} else {
|
|
100
|
-
ownKeys$2(Object(source)).forEach(function(key) {
|
|
101
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return target;
|
|
105
|
-
}
|
|
106
|
-
function _sliced_to_array$2(arr, i) {
|
|
107
|
-
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
|
|
108
|
-
}
|
|
109
|
-
function _to_consumable_array$1(arr) {
|
|
110
|
-
return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread$1();
|
|
111
|
-
}
|
|
112
|
-
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
113
|
-
if (!o) return;
|
|
114
|
-
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
115
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
116
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
117
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
118
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
119
|
-
}
|
|
120
18
|
function isHotFile(file) {
|
|
121
19
|
return file.includes(HOT_UPDATE_SUFFIX);
|
|
122
20
|
}
|
|
123
|
-
|
|
124
|
-
assets.forEach(
|
|
21
|
+
const collectAssets = (assets, jsTargetSet, cssTargetSet) => {
|
|
22
|
+
assets.forEach((file) => {
|
|
125
23
|
if (file.endsWith('.css')) {
|
|
126
24
|
cssTargetSet.add(file);
|
|
127
|
-
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
128
27
|
if (isDev()) {
|
|
129
28
|
if (!isHotFile(file)) {
|
|
130
29
|
jsTargetSet.add(file);
|
|
131
30
|
}
|
|
132
|
-
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
133
33
|
jsTargetSet.add(file);
|
|
134
34
|
}
|
|
135
35
|
}
|
|
136
36
|
});
|
|
137
37
|
};
|
|
138
38
|
function getSharedModuleName(name) {
|
|
139
|
-
|
|
39
|
+
const [_type, _shared, _module, _shareScope, sharedInfo] = name.split(' ');
|
|
140
40
|
return sharedInfo.split('@').slice(0, -1).join('@');
|
|
141
41
|
}
|
|
142
42
|
function getAssetsByChunkIDs(compilation, chunkIDMap) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
Object.keys(chunkIDMap).forEach(
|
|
146
|
-
|
|
43
|
+
const arrayChunks = Array.from(compilation.chunks);
|
|
44
|
+
const assetMap = {};
|
|
45
|
+
Object.keys(chunkIDMap).forEach((key) => {
|
|
46
|
+
const chunkIDs = Array.from(chunkIDMap[key]);
|
|
147
47
|
if (!assetMap[key]) {
|
|
148
48
|
assetMap[key] = {
|
|
149
49
|
css: new Set(),
|
|
150
|
-
js: new Set()
|
|
50
|
+
js: new Set(),
|
|
151
51
|
};
|
|
152
52
|
}
|
|
153
|
-
chunkIDs.forEach(
|
|
154
|
-
|
|
155
|
-
return item.id === chunkID;
|
|
156
|
-
});
|
|
53
|
+
chunkIDs.forEach((chunkID) => {
|
|
54
|
+
const chunk = arrayChunks.find((item) => item.id === chunkID);
|
|
157
55
|
if (chunk) {
|
|
158
|
-
collectAssets(
|
|
56
|
+
collectAssets([...chunk.files], assetMap[key].js, assetMap[key].css);
|
|
159
57
|
}
|
|
160
58
|
});
|
|
161
59
|
});
|
|
162
|
-
|
|
163
|
-
Object.keys(assetMap).map(
|
|
60
|
+
const assets = {};
|
|
61
|
+
Object.keys(assetMap).map((key) => {
|
|
164
62
|
assets[key] = {
|
|
165
63
|
js: Array.from(assetMap[key].js),
|
|
166
|
-
css: Array.from(assetMap[key].css)
|
|
64
|
+
css: Array.from(assetMap[key].css),
|
|
167
65
|
};
|
|
168
66
|
});
|
|
169
67
|
return assets;
|
|
170
68
|
}
|
|
171
69
|
function findChunk(id, chunks) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
var chunk = _step.value;
|
|
176
|
-
if (id === chunk.id) {
|
|
177
|
-
return chunk;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
} catch (err) {
|
|
181
|
-
_didIteratorError = true;
|
|
182
|
-
_iteratorError = err;
|
|
183
|
-
} finally{
|
|
184
|
-
try {
|
|
185
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
186
|
-
_iterator.return();
|
|
187
|
-
}
|
|
188
|
-
} finally{
|
|
189
|
-
if (_didIteratorError) {
|
|
190
|
-
throw _iteratorError;
|
|
191
|
-
}
|
|
70
|
+
for (const chunk of chunks) {
|
|
71
|
+
if (id === chunk.id) {
|
|
72
|
+
return chunk;
|
|
192
73
|
}
|
|
193
74
|
}
|
|
194
75
|
}
|
|
195
76
|
function getSharedModules(stats, sharedModules) {
|
|
196
|
-
var _stats_modules;
|
|
197
77
|
// 获取入口文件就是实际内容的 module
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
entryContentModuleNames.push(sharedModule.name);
|
|
206
|
-
sum.push([
|
|
207
|
-
getSharedModuleName(module.issuerName),
|
|
208
|
-
module
|
|
209
|
-
]);
|
|
210
|
-
return sum;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
} catch (err) {
|
|
214
|
-
_didIteratorError = true;
|
|
215
|
-
_iteratorError = err;
|
|
216
|
-
} finally{
|
|
217
|
-
try {
|
|
218
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
219
|
-
_iterator.return();
|
|
220
|
-
}
|
|
221
|
-
} finally{
|
|
222
|
-
if (_didIteratorError) {
|
|
223
|
-
throw _iteratorError;
|
|
224
|
-
}
|
|
78
|
+
const entryContentModuleNames = [];
|
|
79
|
+
let effectiveSharedModules = stats.modules?.reduce((sum, module) => {
|
|
80
|
+
for (const sharedModule of sharedModules) {
|
|
81
|
+
if (sharedModule.name === module.issuerName) {
|
|
82
|
+
entryContentModuleNames.push(sharedModule.name);
|
|
83
|
+
sum.push([getSharedModuleName(module.issuerName), module]);
|
|
84
|
+
return sum;
|
|
225
85
|
}
|
|
226
86
|
}
|
|
227
87
|
return sum;
|
|
228
|
-
}, [])
|
|
88
|
+
}, []) || [];
|
|
229
89
|
// 获取入口文件仅作为 Re Export 的 module
|
|
230
|
-
|
|
231
|
-
return !entryContentModuleNames.includes(sharedModule.name);
|
|
232
|
-
});
|
|
90
|
+
const entryReExportModules = sharedModules.filter((sharedModule) => !entryContentModuleNames.includes(sharedModule.name));
|
|
233
91
|
if (entryReExportModules.length) {
|
|
234
|
-
effectiveSharedModules = effectiveSharedModules.concat(stats.modules.reduce(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
var entryReExportModule = _step.value;
|
|
240
|
-
if (flag) {
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
if (module.reasons) {
|
|
244
|
-
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
245
|
-
try {
|
|
246
|
-
for(var _iterator1 = module.reasons[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
247
|
-
var issueModule = _step1.value;
|
|
248
|
-
if (issueModule.moduleName === entryReExportModule.name) {
|
|
249
|
-
sum.push([
|
|
250
|
-
getSharedModuleName(entryReExportModule.name),
|
|
251
|
-
module
|
|
252
|
-
]);
|
|
253
|
-
flag = true;
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
} catch (err) {
|
|
258
|
-
_didIteratorError1 = true;
|
|
259
|
-
_iteratorError1 = err;
|
|
260
|
-
} finally{
|
|
261
|
-
try {
|
|
262
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
263
|
-
_iterator1.return();
|
|
264
|
-
}
|
|
265
|
-
} finally{
|
|
266
|
-
if (_didIteratorError1) {
|
|
267
|
-
throw _iteratorError1;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
92
|
+
effectiveSharedModules = effectiveSharedModules.concat(stats.modules.reduce((sum, module) => {
|
|
93
|
+
let flag = false;
|
|
94
|
+
for (const entryReExportModule of entryReExportModules) {
|
|
95
|
+
if (flag) {
|
|
96
|
+
break;
|
|
272
97
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
throw _iteratorError;
|
|
98
|
+
if (module.reasons) {
|
|
99
|
+
for (const issueModule of module.reasons) {
|
|
100
|
+
if (issueModule.moduleName === entryReExportModule.name) {
|
|
101
|
+
sum.push([
|
|
102
|
+
getSharedModuleName(entryReExportModule.name),
|
|
103
|
+
module,
|
|
104
|
+
]);
|
|
105
|
+
flag = true;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
284
108
|
}
|
|
285
109
|
}
|
|
286
110
|
}
|
|
@@ -290,37 +114,37 @@ function getSharedModules(stats, sharedModules) {
|
|
|
290
114
|
return effectiveSharedModules;
|
|
291
115
|
}
|
|
292
116
|
function getAssetsByChunk(chunk, entryPointNames) {
|
|
293
|
-
|
|
117
|
+
const assesSet = {
|
|
294
118
|
js: {
|
|
295
119
|
sync: new Set(),
|
|
296
|
-
async: new Set()
|
|
120
|
+
async: new Set(),
|
|
297
121
|
},
|
|
298
122
|
css: {
|
|
299
123
|
sync: new Set(),
|
|
300
|
-
async: new Set()
|
|
301
|
-
}
|
|
124
|
+
async: new Set(),
|
|
125
|
+
},
|
|
302
126
|
};
|
|
303
|
-
|
|
304
|
-
|
|
127
|
+
const collectChunkFiles = (targetChunk, type) => {
|
|
128
|
+
[...targetChunk.groupsIterable].forEach((chunkGroup) => {
|
|
305
129
|
if (chunkGroup.name && !entryPointNames.includes(chunkGroup.name)) {
|
|
306
130
|
collectAssets(chunkGroup.getFiles(), assesSet.js[type], assesSet.css[type]);
|
|
307
131
|
}
|
|
308
132
|
});
|
|
309
133
|
};
|
|
310
134
|
collectChunkFiles(chunk, 'sync');
|
|
311
|
-
|
|
312
|
-
collectAssets(
|
|
135
|
+
[...chunk.getAllAsyncChunks()].forEach((asyncChunk) => {
|
|
136
|
+
collectAssets([...asyncChunk.files], assesSet.js['async'], assesSet.css['async']);
|
|
313
137
|
collectChunkFiles(asyncChunk, 'async');
|
|
314
138
|
});
|
|
315
|
-
|
|
139
|
+
const assets = {
|
|
316
140
|
js: {
|
|
317
141
|
sync: Array.from(assesSet.js.sync),
|
|
318
|
-
async: Array.from(assesSet.js.async)
|
|
142
|
+
async: Array.from(assesSet.js.async),
|
|
319
143
|
},
|
|
320
144
|
css: {
|
|
321
145
|
sync: Array.from(assesSet.css.sync),
|
|
322
|
-
async: Array.from(assesSet.css.async)
|
|
323
|
-
}
|
|
146
|
+
async: Array.from(assesSet.css.async),
|
|
147
|
+
},
|
|
324
148
|
};
|
|
325
149
|
return assets;
|
|
326
150
|
}
|
|
@@ -330,7 +154,7 @@ function assert(condition, msg) {
|
|
|
330
154
|
}
|
|
331
155
|
}
|
|
332
156
|
function error(msg) {
|
|
333
|
-
throw new Error(
|
|
157
|
+
throw new Error(`[ ${PLUGIN_IDENTIFIER} ]: ${msg}`);
|
|
334
158
|
}
|
|
335
159
|
function isDev() {
|
|
336
160
|
return process.env['NODE_ENV'] === 'development';
|
|
@@ -338,462 +162,234 @@ function isDev() {
|
|
|
338
162
|
function getFileNameWithOutExt(str) {
|
|
339
163
|
return str.replace(path.extname(str), '');
|
|
340
164
|
}
|
|
341
|
-
function getFileName(manifestOptions) {
|
|
342
|
-
if (!manifestOptions) {
|
|
343
|
-
return {
|
|
344
|
-
statsFileName: sdk.StatsFileName,
|
|
345
|
-
manifestFileName: sdk.ManifestFileName
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
var filePath = typeof manifestOptions === 'boolean' ? '' : manifestOptions.filePath || '';
|
|
349
|
-
var fileName = typeof manifestOptions === 'boolean' ? '' : manifestOptions.fileName || '';
|
|
350
|
-
var JSON_EXT = '.json';
|
|
351
|
-
var addExt = function(name) {
|
|
352
|
-
if (name.endsWith(JSON_EXT)) {
|
|
353
|
-
return name;
|
|
354
|
-
}
|
|
355
|
-
return "".concat(name).concat(JSON_EXT);
|
|
356
|
-
};
|
|
357
|
-
var insertSuffix = function(name, suffix) {
|
|
358
|
-
return name.replace(JSON_EXT, "".concat(suffix).concat(JSON_EXT));
|
|
359
|
-
};
|
|
360
|
-
var manifestFileName = fileName ? addExt(fileName) : sdk.ManifestFileName;
|
|
361
|
-
var statsFileName = fileName ? insertSuffix(manifestFileName, '-stats') : sdk.StatsFileName;
|
|
362
|
-
return {
|
|
363
|
-
statsFileName: sdk.simpleJoinRemoteEntry(filePath, statsFileName),
|
|
364
|
-
manifestFileName: sdk.simpleJoinRemoteEntry(filePath, manifestFileName)
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
165
|
function getTypesMetaInfo(pluginOptions, context) {
|
|
368
|
-
|
|
166
|
+
const defaultRemoteOptions = {
|
|
369
167
|
generateAPITypes: true,
|
|
370
|
-
compileInChildProcess: true
|
|
168
|
+
compileInChildProcess: true,
|
|
371
169
|
};
|
|
372
|
-
|
|
170
|
+
const defaultTypesMetaInfo = {
|
|
373
171
|
path: '',
|
|
374
172
|
name: '',
|
|
375
173
|
zip: '',
|
|
376
|
-
api: ''
|
|
174
|
+
api: '',
|
|
377
175
|
};
|
|
378
176
|
try {
|
|
379
|
-
|
|
177
|
+
const normalizedDtsOptions = sdk.normalizeOptions(core.isTSProject(pluginOptions.dts, context), {
|
|
380
178
|
generateTypes: defaultRemoteOptions,
|
|
381
|
-
consumeTypes: {}
|
|
179
|
+
consumeTypes: {},
|
|
382
180
|
}, 'mfOptions.dts')(pluginOptions.dts);
|
|
383
181
|
if (normalizedDtsOptions === false) {
|
|
384
182
|
return defaultTypesMetaInfo;
|
|
385
183
|
}
|
|
386
|
-
|
|
184
|
+
const normalizedRemote = sdk.normalizeOptions(true, defaultRemoteOptions, 'mfOptions.dts.generateTypes')(normalizedDtsOptions.generateTypes);
|
|
387
185
|
if (normalizedRemote === false) {
|
|
388
186
|
return defaultTypesMetaInfo;
|
|
389
187
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
188
|
+
const { apiFileName, zipName, zipPrefix } = core.retrieveTypesAssetsInfo({
|
|
189
|
+
...normalizedRemote,
|
|
190
|
+
context,
|
|
191
|
+
moduleFederationConfig: pluginOptions,
|
|
192
|
+
});
|
|
193
|
+
const zip = path.join(zipPrefix, zipName);
|
|
194
|
+
const api = path.join(zipPrefix, apiFileName);
|
|
396
195
|
return {
|
|
397
196
|
path: '',
|
|
398
197
|
name: '',
|
|
399
|
-
zip
|
|
400
|
-
api
|
|
198
|
+
zip,
|
|
199
|
+
api,
|
|
401
200
|
};
|
|
402
|
-
}
|
|
403
|
-
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
logger.warn(`getTypesMetaInfo failed, it will use the default types meta info, and the errors as belows: ${err}`);
|
|
404
204
|
return defaultTypesMetaInfo;
|
|
405
205
|
}
|
|
406
206
|
}
|
|
407
207
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
var value = info.value;
|
|
412
|
-
} catch (error) {
|
|
413
|
-
reject(error);
|
|
414
|
-
return;
|
|
208
|
+
class ManifestManager {
|
|
209
|
+
constructor() {
|
|
210
|
+
this._options = {};
|
|
415
211
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
} else {
|
|
419
|
-
Promise.resolve(value).then(_next, _throw);
|
|
212
|
+
get manifest() {
|
|
213
|
+
return this._manifest;
|
|
420
214
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
return function() {
|
|
424
|
-
var self = this, args = arguments;
|
|
425
|
-
return new Promise(function(resolve, reject) {
|
|
426
|
-
var gen = fn.apply(self, args);
|
|
427
|
-
function _next(value) {
|
|
428
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
429
|
-
}
|
|
430
|
-
function _throw(err) {
|
|
431
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
432
|
-
}
|
|
433
|
-
_next(undefined);
|
|
434
|
-
});
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
function _class_call_check$3(instance, Constructor) {
|
|
438
|
-
if (!(instance instanceof Constructor)) {
|
|
439
|
-
throw new TypeError("Cannot call a class as a function");
|
|
215
|
+
init(options) {
|
|
216
|
+
this._options = options;
|
|
440
217
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
for(var i = 0; i < props.length; i++){
|
|
444
|
-
var descriptor = props[i];
|
|
445
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
446
|
-
descriptor.configurable = true;
|
|
447
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
448
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
218
|
+
get fileName() {
|
|
219
|
+
return sdk.getManifestFileName(this._options.manifest).manifestFileName;
|
|
449
220
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
"return": verb(2)
|
|
469
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
470
|
-
return this;
|
|
471
|
-
}), g;
|
|
472
|
-
function verb(n) {
|
|
473
|
-
return function(v) {
|
|
474
|
-
return step([
|
|
475
|
-
n,
|
|
476
|
-
v
|
|
477
|
-
]);
|
|
221
|
+
async generateManifest(options) {
|
|
222
|
+
const { compilation, publicPath, stats, compiler, bundler, additionalData, } = options;
|
|
223
|
+
const existedManifest = compilation.getAsset(this.fileName);
|
|
224
|
+
if (existedManifest) {
|
|
225
|
+
return {
|
|
226
|
+
manifest: JSON.parse(existedManifest.source.source().toString()),
|
|
227
|
+
filename: this.fileName,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
// Initialize manifest with required properties from stats
|
|
231
|
+
const { id, name, metaData } = stats;
|
|
232
|
+
const manifest = {
|
|
233
|
+
id,
|
|
234
|
+
name,
|
|
235
|
+
metaData,
|
|
236
|
+
shared: [],
|
|
237
|
+
remotes: [],
|
|
238
|
+
exposes: [],
|
|
478
239
|
};
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
_ = 0;
|
|
513
|
-
continue;
|
|
514
|
-
}
|
|
515
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
516
|
-
_.label = op[1];
|
|
517
|
-
break;
|
|
518
|
-
}
|
|
519
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
520
|
-
_.label = t[1];
|
|
521
|
-
t = op;
|
|
522
|
-
break;
|
|
523
|
-
}
|
|
524
|
-
if (t && _.label < t[2]) {
|
|
525
|
-
_.label = t[2];
|
|
526
|
-
_.ops.push(op);
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
if (t[2]) _.ops.pop();
|
|
530
|
-
_.trys.pop();
|
|
531
|
-
continue;
|
|
240
|
+
manifest.exposes = stats.exposes.reduce((sum, cur) => {
|
|
241
|
+
const expose = {
|
|
242
|
+
id: cur.id,
|
|
243
|
+
name: cur.name,
|
|
244
|
+
assets: cur.assets,
|
|
245
|
+
path: cur.path,
|
|
246
|
+
};
|
|
247
|
+
sum.push(expose);
|
|
248
|
+
return sum;
|
|
249
|
+
}, []);
|
|
250
|
+
manifest.shared = stats.shared.reduce((sum, cur) => {
|
|
251
|
+
const shared = {
|
|
252
|
+
id: cur.id,
|
|
253
|
+
name: cur.name,
|
|
254
|
+
version: cur.version,
|
|
255
|
+
singleton: cur.singleton,
|
|
256
|
+
requiredVersion: cur.requiredVersion,
|
|
257
|
+
hash: cur.hash,
|
|
258
|
+
assets: cur.assets,
|
|
259
|
+
};
|
|
260
|
+
sum.push(shared);
|
|
261
|
+
return sum;
|
|
262
|
+
}, []);
|
|
263
|
+
manifest.remotes = stats.remotes.reduce((sum, cur) => {
|
|
264
|
+
// @ts-ignore version/entry will be added as follow
|
|
265
|
+
const remote = {
|
|
266
|
+
federationContainerName: cur.federationContainerName,
|
|
267
|
+
moduleName: cur.moduleName,
|
|
268
|
+
alias: cur.alias,
|
|
269
|
+
};
|
|
270
|
+
if ('entry' in cur) {
|
|
271
|
+
// @ts-ignore
|
|
272
|
+
remote.entry = cur.entry;
|
|
532
273
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
274
|
+
else if ('version' in cur) {
|
|
275
|
+
// @ts-ignore
|
|
276
|
+
remote.entry = cur.version;
|
|
277
|
+
}
|
|
278
|
+
sum.push(remote);
|
|
279
|
+
return sum;
|
|
280
|
+
}, []);
|
|
281
|
+
this._manifest = manifest;
|
|
282
|
+
const manifestFileName = this.fileName;
|
|
283
|
+
if (additionalData) {
|
|
284
|
+
const ret = await additionalData({
|
|
285
|
+
manifest: this._manifest,
|
|
286
|
+
stats,
|
|
287
|
+
pluginOptions: this._options,
|
|
288
|
+
compiler,
|
|
289
|
+
compilation,
|
|
290
|
+
bundler,
|
|
291
|
+
});
|
|
292
|
+
this._manifest = ret || this._manifest;
|
|
293
|
+
}
|
|
294
|
+
compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(this._manifest, null, 2)));
|
|
295
|
+
if (isDev() &&
|
|
296
|
+
(process.env['MF_SSR_PRJ']
|
|
297
|
+
? compiler.options.target !== 'async-node'
|
|
298
|
+
: true)) {
|
|
299
|
+
logger.info(`Manifest Link: ${chalk.cyan(`${publicPath === 'auto' ? '{auto}/' : publicPath}${manifestFileName}`)} `);
|
|
542
300
|
}
|
|
543
|
-
if (op[0] & 5) throw op[1];
|
|
544
301
|
return {
|
|
545
|
-
|
|
546
|
-
|
|
302
|
+
manifest: this._manifest,
|
|
303
|
+
filename: manifestFileName,
|
|
547
304
|
};
|
|
548
305
|
}
|
|
549
306
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
307
|
+
|
|
308
|
+
const isNonEmptyString = (value) => {
|
|
309
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
310
|
+
};
|
|
311
|
+
const normalizeExposeValue = (exposeValue) => {
|
|
312
|
+
if (!exposeValue) {
|
|
313
|
+
return undefined;
|
|
554
314
|
}
|
|
555
|
-
|
|
556
|
-
{
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
return getFileName(this._options.manifest).manifestFileName;
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
key: "generateManifest",
|
|
576
|
-
value: function generateManifest(options) {
|
|
577
|
-
var extraOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
578
|
-
var _this = this;
|
|
579
|
-
return _async_to_generator$2(function() {
|
|
580
|
-
var compilation, publicPath, stats, compiler, bundler, additionalData, disableEmit, id, name, metaData, manifest, manifestFileName, ret;
|
|
581
|
-
return _ts_generator$2(this, function(_state) {
|
|
582
|
-
switch(_state.label){
|
|
583
|
-
case 0:
|
|
584
|
-
compilation = options.compilation, publicPath = options.publicPath, stats = options.stats, compiler = options.compiler, bundler = options.bundler, additionalData = options.additionalData;
|
|
585
|
-
disableEmit = extraOptions.disableEmit;
|
|
586
|
-
// Initialize manifest with required properties from stats
|
|
587
|
-
id = stats.id, name = stats.name, metaData = stats.metaData;
|
|
588
|
-
manifest = {
|
|
589
|
-
id: id,
|
|
590
|
-
name: name,
|
|
591
|
-
metaData: metaData,
|
|
592
|
-
shared: [],
|
|
593
|
-
remotes: [],
|
|
594
|
-
exposes: []
|
|
595
|
-
};
|
|
596
|
-
manifest.exposes = stats.exposes.reduce(function(sum, cur) {
|
|
597
|
-
var expose = {
|
|
598
|
-
id: cur.id,
|
|
599
|
-
name: cur.name,
|
|
600
|
-
assets: cur.assets,
|
|
601
|
-
path: cur.path
|
|
602
|
-
};
|
|
603
|
-
sum.push(expose);
|
|
604
|
-
return sum;
|
|
605
|
-
}, []);
|
|
606
|
-
manifest.shared = stats.shared.reduce(function(sum, cur) {
|
|
607
|
-
var shared = {
|
|
608
|
-
id: cur.id,
|
|
609
|
-
name: cur.name,
|
|
610
|
-
version: cur.version,
|
|
611
|
-
singleton: cur.singleton,
|
|
612
|
-
requiredVersion: cur.requiredVersion,
|
|
613
|
-
hash: cur.hash,
|
|
614
|
-
assets: cur.assets
|
|
615
|
-
};
|
|
616
|
-
sum.push(shared);
|
|
617
|
-
return sum;
|
|
618
|
-
}, []);
|
|
619
|
-
manifest.remotes = stats.remotes.reduce(function(sum, cur) {
|
|
620
|
-
// @ts-ignore version/entry will be added as follow
|
|
621
|
-
var remote = {
|
|
622
|
-
federationContainerName: cur.federationContainerName,
|
|
623
|
-
moduleName: cur.moduleName,
|
|
624
|
-
alias: cur.alias
|
|
625
|
-
};
|
|
626
|
-
if ('entry' in cur) {
|
|
627
|
-
// @ts-ignore
|
|
628
|
-
remote.entry = cur.entry;
|
|
629
|
-
} else if ('version' in cur) {
|
|
630
|
-
// @ts-ignore
|
|
631
|
-
remote.entry = cur.version;
|
|
632
|
-
}
|
|
633
|
-
sum.push(remote);
|
|
634
|
-
return sum;
|
|
635
|
-
}, []);
|
|
636
|
-
_this._manifest = manifest;
|
|
637
|
-
manifestFileName = _this.fileName;
|
|
638
|
-
if (!additionalData) return [
|
|
639
|
-
3,
|
|
640
|
-
2
|
|
641
|
-
];
|
|
642
|
-
return [
|
|
643
|
-
4,
|
|
644
|
-
additionalData({
|
|
645
|
-
manifest: _this._manifest,
|
|
646
|
-
stats: stats,
|
|
647
|
-
pluginOptions: _this._options,
|
|
648
|
-
compiler: compiler,
|
|
649
|
-
compilation: compilation,
|
|
650
|
-
bundler: bundler
|
|
651
|
-
})
|
|
652
|
-
];
|
|
653
|
-
case 1:
|
|
654
|
-
ret = _state.sent();
|
|
655
|
-
_this._manifest = ret || _this._manifest;
|
|
656
|
-
_state.label = 2;
|
|
657
|
-
case 2:
|
|
658
|
-
if (!disableEmit) {
|
|
659
|
-
compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
|
|
660
|
-
}
|
|
661
|
-
if (isDev() && (process.env['MF_SSR_PRJ'] ? compiler.options.target !== 'async-node' : true)) {
|
|
662
|
-
logger.info("Manifest Link: ".concat(chalk.cyan("".concat(publicPath === 'auto' ? '{auto}/' : publicPath).concat(manifestFileName)), " "));
|
|
663
|
-
}
|
|
664
|
-
return [
|
|
665
|
-
2,
|
|
666
|
-
{
|
|
667
|
-
manifest: _this._manifest,
|
|
668
|
-
filename: manifestFileName
|
|
669
|
-
}
|
|
670
|
-
];
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
})();
|
|
315
|
+
const toImportArray = (value) => {
|
|
316
|
+
if (isNonEmptyString(value)) {
|
|
317
|
+
return [value];
|
|
318
|
+
}
|
|
319
|
+
if (Array.isArray(value)) {
|
|
320
|
+
const normalized = value.filter(isNonEmptyString);
|
|
321
|
+
return normalized.length ? normalized : undefined;
|
|
322
|
+
}
|
|
323
|
+
return undefined;
|
|
324
|
+
};
|
|
325
|
+
if (typeof exposeValue === 'object') {
|
|
326
|
+
if ('import' in exposeValue) {
|
|
327
|
+
const { import: rawImport, name } = exposeValue;
|
|
328
|
+
const normalizedImport = toImportArray(rawImport);
|
|
329
|
+
if (!normalizedImport?.length) {
|
|
330
|
+
return undefined;
|
|
674
331
|
}
|
|
332
|
+
return {
|
|
333
|
+
import: normalizedImport,
|
|
334
|
+
...(isNonEmptyString(name) ? { name } : {}),
|
|
335
|
+
};
|
|
675
336
|
}
|
|
676
|
-
|
|
677
|
-
return ManifestManager;
|
|
678
|
-
}();
|
|
679
|
-
|
|
680
|
-
function _array_like_to_array$1(arr, len) {
|
|
681
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
682
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
683
|
-
return arr2;
|
|
684
|
-
}
|
|
685
|
-
function _array_with_holes$1(arr) {
|
|
686
|
-
if (Array.isArray(arr)) return arr;
|
|
687
|
-
}
|
|
688
|
-
function _class_call_check$2(instance, Constructor) {
|
|
689
|
-
if (!(instance instanceof Constructor)) {
|
|
690
|
-
throw new TypeError("Cannot call a class as a function");
|
|
337
|
+
return undefined;
|
|
691
338
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
var descriptor = props[i];
|
|
696
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
697
|
-
descriptor.configurable = true;
|
|
698
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
699
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
339
|
+
const normalizedImport = toImportArray(exposeValue);
|
|
340
|
+
if (!normalizedImport?.length) {
|
|
341
|
+
return undefined;
|
|
700
342
|
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
if (key in obj) {
|
|
708
|
-
Object.defineProperty(obj, key, {
|
|
709
|
-
value: value,
|
|
710
|
-
enumerable: true,
|
|
711
|
-
configurable: true,
|
|
712
|
-
writable: true
|
|
713
|
-
});
|
|
714
|
-
} else {
|
|
715
|
-
obj[key] = value;
|
|
343
|
+
return { import: normalizedImport };
|
|
344
|
+
};
|
|
345
|
+
const parseContainerExposeEntries = (identifier) => {
|
|
346
|
+
const startIndex = identifier.indexOf('[');
|
|
347
|
+
if (startIndex < 0) {
|
|
348
|
+
return undefined;
|
|
716
349
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
var _s, _e;
|
|
726
|
-
try {
|
|
727
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
728
|
-
_arr.push(_s.value);
|
|
729
|
-
if (i && _arr.length === i) break;
|
|
350
|
+
let depth = 0;
|
|
351
|
+
let inString = false;
|
|
352
|
+
let isEscaped = false;
|
|
353
|
+
for (let cursor = startIndex; cursor < identifier.length; cursor++) {
|
|
354
|
+
const char = identifier[cursor];
|
|
355
|
+
if (isEscaped) {
|
|
356
|
+
isEscaped = false;
|
|
357
|
+
continue;
|
|
730
358
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
} finally{
|
|
735
|
-
try {
|
|
736
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
737
|
-
} finally{
|
|
738
|
-
if (_d) throw _e;
|
|
359
|
+
if (char === '\\') {
|
|
360
|
+
isEscaped = true;
|
|
361
|
+
continue;
|
|
739
362
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
if (
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
363
|
+
if (char === '"') {
|
|
364
|
+
inString = !inString;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if (inString) {
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
if (char === '[') {
|
|
371
|
+
depth++;
|
|
372
|
+
}
|
|
373
|
+
else if (char === ']') {
|
|
374
|
+
depth--;
|
|
375
|
+
if (depth === 0) {
|
|
376
|
+
const serialized = identifier.slice(startIndex, cursor + 1);
|
|
377
|
+
try {
|
|
378
|
+
return JSON.parse(serialized);
|
|
379
|
+
}
|
|
380
|
+
catch {
|
|
381
|
+
return undefined;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
754
384
|
}
|
|
755
|
-
ownKeys.forEach(function(key) {
|
|
756
|
-
_define_property$1(target, key, source[key]);
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
return target;
|
|
760
|
-
}
|
|
761
|
-
function ownKeys$1(object, enumerableOnly) {
|
|
762
|
-
var keys = Object.keys(object);
|
|
763
|
-
if (Object.getOwnPropertySymbols) {
|
|
764
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
765
|
-
keys.push.apply(keys, symbols);
|
|
766
|
-
}
|
|
767
|
-
return keys;
|
|
768
|
-
}
|
|
769
|
-
function _object_spread_props$1(target, source) {
|
|
770
|
-
source = source != null ? source : {};
|
|
771
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
772
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
773
|
-
} else {
|
|
774
|
-
ownKeys$1(Object(source)).forEach(function(key) {
|
|
775
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
776
|
-
});
|
|
777
385
|
}
|
|
778
|
-
return
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
|
|
782
|
-
}
|
|
783
|
-
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
784
|
-
if (!o) return;
|
|
785
|
-
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
786
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
787
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
788
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
789
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
790
|
-
}
|
|
791
|
-
var getExposeName = function(exposeKey) {
|
|
386
|
+
return undefined;
|
|
387
|
+
};
|
|
388
|
+
const getExposeName = (exposeKey) => {
|
|
792
389
|
return exposeKey.replace('./', '');
|
|
793
390
|
};
|
|
794
|
-
function getExposeItem(
|
|
795
|
-
|
|
796
|
-
var exposeModuleName = getExposeName(exposeKey);
|
|
391
|
+
function getExposeItem({ exposeKey, name, file, }) {
|
|
392
|
+
const exposeModuleName = getExposeName(exposeKey);
|
|
797
393
|
return {
|
|
798
394
|
path: exposeKey,
|
|
799
395
|
id: sdk.composeKeyWithSeparator(name, exposeModuleName),
|
|
@@ -804,542 +400,331 @@ function getExposeItem(param) {
|
|
|
804
400
|
assets: {
|
|
805
401
|
js: {
|
|
806
402
|
async: [],
|
|
807
|
-
sync: []
|
|
403
|
+
sync: [],
|
|
808
404
|
},
|
|
809
405
|
css: {
|
|
810
406
|
async: [],
|
|
811
|
-
sync: []
|
|
812
|
-
}
|
|
813
|
-
}
|
|
407
|
+
sync: [],
|
|
408
|
+
},
|
|
409
|
+
},
|
|
814
410
|
};
|
|
815
411
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
var bundler = param.bundler;
|
|
819
|
-
_class_call_check$2(this, ModuleHandler);
|
|
412
|
+
class ModuleHandler {
|
|
413
|
+
constructor(options, modules, { bundler }) {
|
|
820
414
|
this._bundler = 'webpack';
|
|
821
415
|
this._remoteManager = new managers.RemoteManager();
|
|
822
416
|
this._sharedManager = new managers.SharedManager();
|
|
823
417
|
this._options = options;
|
|
824
418
|
this._modules = modules;
|
|
825
419
|
this._bundler = bundler;
|
|
420
|
+
this._containerManager = new managers.ContainerManager();
|
|
421
|
+
this._containerManager.init(options);
|
|
826
422
|
this._remoteManager = new managers.RemoteManager();
|
|
827
423
|
this._remoteManager.init(options);
|
|
828
424
|
this._sharedManager = new managers.SharedManager();
|
|
829
425
|
this._sharedManager.init(options);
|
|
830
426
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
427
|
+
get isRspack() {
|
|
428
|
+
return this._bundler === 'rspack';
|
|
429
|
+
}
|
|
430
|
+
_handleSharedModule(mod, sharedMap, exposesMap) {
|
|
431
|
+
const { identifier, moduleType } = mod;
|
|
432
|
+
if (!identifier) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const sharedManagerNormalizedOptions = this._sharedManager.normalizedOptions;
|
|
436
|
+
const initShared = (pkgName, pkgVersion) => {
|
|
437
|
+
if (sharedMap[pkgName]) {
|
|
438
|
+
return;
|
|
836
439
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
440
|
+
sharedMap[pkgName] = {
|
|
441
|
+
...sharedManagerNormalizedOptions[pkgName],
|
|
442
|
+
id: `${this._options.name}:${pkgName}`,
|
|
443
|
+
requiredVersion: sharedManagerNormalizedOptions[pkgName]?.requiredVersion ||
|
|
444
|
+
`^${pkgVersion}`,
|
|
445
|
+
name: pkgName,
|
|
446
|
+
version: pkgVersion,
|
|
447
|
+
assets: {
|
|
448
|
+
js: {
|
|
449
|
+
async: [],
|
|
450
|
+
sync: [],
|
|
451
|
+
},
|
|
452
|
+
css: {
|
|
453
|
+
async: [],
|
|
454
|
+
sync: [],
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
// @ts-ignore to deduplicate
|
|
458
|
+
usedIn: new Set(),
|
|
459
|
+
};
|
|
460
|
+
};
|
|
461
|
+
const collectRelationshipMap = (mod, pkgName) => {
|
|
462
|
+
const { issuerName, reasons } = mod;
|
|
463
|
+
if (issuerName) {
|
|
464
|
+
if (exposesMap[getFileNameWithOutExt(issuerName)]) {
|
|
465
|
+
const expose = exposesMap[getFileNameWithOutExt(issuerName)];
|
|
466
|
+
// @ts-ignore use Set to deduplicate
|
|
467
|
+
expose.requires.push(pkgName);
|
|
468
|
+
// @ts-ignore use Set to deduplicate
|
|
469
|
+
sharedMap[pkgName].usedIn.add(expose.path);
|
|
845
470
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
name: pkgName,
|
|
856
|
-
version: pkgVersion,
|
|
857
|
-
assets: {
|
|
858
|
-
js: {
|
|
859
|
-
async: [],
|
|
860
|
-
sync: []
|
|
861
|
-
},
|
|
862
|
-
css: {
|
|
863
|
-
async: [],
|
|
864
|
-
sync: []
|
|
865
|
-
}
|
|
866
|
-
},
|
|
867
|
-
// @ts-ignore to deduplicate
|
|
868
|
-
usedIn: new Set()
|
|
869
|
-
});
|
|
870
|
-
};
|
|
871
|
-
var collectRelationshipMap = function(mod, pkgName) {
|
|
872
|
-
var issuerName = mod.issuerName, reasons = mod.reasons;
|
|
873
|
-
if (issuerName) {
|
|
874
|
-
if (exposesMap[getFileNameWithOutExt(issuerName)]) {
|
|
875
|
-
var expose = exposesMap[getFileNameWithOutExt(issuerName)];
|
|
876
|
-
// @ts-ignore use Set to deduplicate
|
|
471
|
+
}
|
|
472
|
+
if (reasons) {
|
|
473
|
+
reasons.forEach(({ resolvedModule, moduleName }) => {
|
|
474
|
+
let exposeModName = this.isRspack ? moduleName : resolvedModule;
|
|
475
|
+
// filters out entrypoints
|
|
476
|
+
if (exposeModName) {
|
|
477
|
+
if (exposesMap[getFileNameWithOutExt(exposeModName)]) {
|
|
478
|
+
const expose = exposesMap[getFileNameWithOutExt(exposeModName)];
|
|
479
|
+
// @ts-ignore to deduplicate
|
|
877
480
|
expose.requires.push(pkgName);
|
|
878
|
-
// @ts-ignore
|
|
481
|
+
// @ts-ignore to deduplicate
|
|
879
482
|
sharedMap[pkgName].usedIn.add(expose.path);
|
|
880
483
|
}
|
|
881
484
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
const parseResolvedIdentifier = (nameAndVersion) => {
|
|
489
|
+
let name = '';
|
|
490
|
+
let version = '';
|
|
491
|
+
if (nameAndVersion.startsWith('@')) {
|
|
492
|
+
const splitInfo = nameAndVersion.split('@');
|
|
493
|
+
splitInfo[0] = '@';
|
|
494
|
+
name = splitInfo[0] + splitInfo[1];
|
|
495
|
+
version = splitInfo[2];
|
|
496
|
+
}
|
|
497
|
+
else if (nameAndVersion.includes('@')) {
|
|
498
|
+
[name, version] = nameAndVersion.split('@');
|
|
499
|
+
version = version.replace(/[\^~>|>=]/g, '');
|
|
500
|
+
}
|
|
501
|
+
return {
|
|
502
|
+
name,
|
|
503
|
+
version,
|
|
504
|
+
};
|
|
505
|
+
};
|
|
506
|
+
if (moduleType === 'provide-module') {
|
|
507
|
+
// identifier(rspack) = provide shared module (default) react@18.2.0 = /temp/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js
|
|
508
|
+
// identifier(webpack) = provide module (default) react@18.2.0 = /temp/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js
|
|
509
|
+
const data = identifier.split(' ');
|
|
510
|
+
const nameAndVersion = this.isRspack ? data[4] : data[3];
|
|
511
|
+
const { name, version } = parseResolvedIdentifier(nameAndVersion);
|
|
512
|
+
if (name && version) {
|
|
513
|
+
initShared(name, version);
|
|
514
|
+
collectRelationshipMap(mod, name);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (moduleType === 'consume-shared-module') {
|
|
518
|
+
// identifier(rspack) = consume shared module (default) lodash/get@^4.17.21 (strict) (fallback: /temp/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/get.js)
|
|
519
|
+
// identifier(webpack) = consume-shared-module|default|react-dom|!=1.8...2...0|false|/temp/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/index.js|true|false
|
|
520
|
+
const SEPARATOR = this.isRspack ? ' ' : '|';
|
|
521
|
+
const data = identifier.split(SEPARATOR);
|
|
522
|
+
let pkgName = '';
|
|
523
|
+
let pkgVersion = '';
|
|
524
|
+
if (this.isRspack) {
|
|
525
|
+
const nameAndVersion = data[4];
|
|
526
|
+
const res = parseResolvedIdentifier(nameAndVersion);
|
|
527
|
+
pkgName = res.name;
|
|
528
|
+
pkgVersion = res.version;
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
pkgName = data[2];
|
|
532
|
+
const pkgVersionRange = data[3];
|
|
533
|
+
pkgVersion = '';
|
|
534
|
+
if (pkgVersionRange.startsWith('=')) {
|
|
535
|
+
pkgVersion = data[3].replace('=', '');
|
|
927
536
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
pkgVersion = '';
|
|
944
|
-
if (pkgVersionRange.startsWith('=')) {
|
|
945
|
-
pkgVersion = data1[3].replace('=', '');
|
|
946
|
-
} else {
|
|
947
|
-
if (sharedManagerNormalizedOptions[pkgName]) {
|
|
948
|
-
pkgVersion = sharedManagerNormalizedOptions[pkgName].version;
|
|
949
|
-
} else {
|
|
950
|
-
var fullPkgName = pkgName.split('/').slice(0, -1).join('/');
|
|
951
|
-
// pkgName: react-dom/
|
|
952
|
-
if (sharedManagerNormalizedOptions["".concat(fullPkgName, "/")]) {
|
|
953
|
-
if (sharedManagerNormalizedOptions[fullPkgName]) {
|
|
954
|
-
pkgVersion = sharedManagerNormalizedOptions[fullPkgName].version;
|
|
955
|
-
} else {
|
|
956
|
-
pkgVersion = sharedManagerNormalizedOptions["".concat(fullPkgName, "/")].version;
|
|
957
|
-
}
|
|
958
|
-
}
|
|
537
|
+
else {
|
|
538
|
+
if (sharedManagerNormalizedOptions[pkgName]) {
|
|
539
|
+
pkgVersion = sharedManagerNormalizedOptions[pkgName].version;
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
const fullPkgName = pkgName.split('/').slice(0, -1).join('/');
|
|
543
|
+
// pkgName: react-dom/
|
|
544
|
+
if (sharedManagerNormalizedOptions[`${fullPkgName}/`]) {
|
|
545
|
+
if (sharedManagerNormalizedOptions[fullPkgName]) {
|
|
546
|
+
pkgVersion =
|
|
547
|
+
sharedManagerNormalizedOptions[fullPkgName].version;
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
pkgVersion =
|
|
551
|
+
sharedManagerNormalizedOptions[`${fullPkgName}/`].version;
|
|
959
552
|
}
|
|
960
553
|
}
|
|
961
554
|
}
|
|
962
|
-
if (pkgName && pkgVersion) {
|
|
963
|
-
initShared(pkgName, pkgVersion);
|
|
964
|
-
collectRelationshipMap(mod, pkgName);
|
|
965
|
-
}
|
|
966
555
|
}
|
|
967
556
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
value: function _handleRemoteModule(mod, remotes, remotesConsumerMap) {
|
|
972
|
-
var _this = this;
|
|
973
|
-
var identifier = mod.identifier, reasons = mod.reasons, nameForCondition = mod.nameForCondition;
|
|
974
|
-
if (!identifier) {
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
|
-
var remoteManagerNormalizedOptions = this._remoteManager.normalizedOptions;
|
|
978
|
-
// identifier = remote (default) webpack/container/reference/app2 ./Button
|
|
979
|
-
var data = identifier.split(' ');
|
|
980
|
-
if (data.length === 4) {
|
|
981
|
-
var moduleName = data[3].replace('./', '');
|
|
982
|
-
var remoteAlias = data[2].replace('webpack/container/reference/', '');
|
|
983
|
-
var normalizedRemote = remoteManagerNormalizedOptions[remoteAlias];
|
|
984
|
-
var basicRemote = {
|
|
985
|
-
alias: normalizedRemote.alias,
|
|
986
|
-
consumingFederationContainerName: this._options.name || '',
|
|
987
|
-
federationContainerName: remoteManagerNormalizedOptions[remoteAlias].name,
|
|
988
|
-
moduleName: moduleName,
|
|
989
|
-
// @ts-ignore to deduplicate
|
|
990
|
-
usedIn: new Set()
|
|
991
|
-
};
|
|
992
|
-
if (!nameForCondition) {
|
|
993
|
-
return;
|
|
994
|
-
}
|
|
995
|
-
var remote;
|
|
996
|
-
if ('version' in normalizedRemote) {
|
|
997
|
-
remote = _object_spread_props$1(_object_spread$1({}, basicRemote), {
|
|
998
|
-
version: normalizedRemote.version
|
|
999
|
-
});
|
|
1000
|
-
} else {
|
|
1001
|
-
remote = _object_spread_props$1(_object_spread$1({}, basicRemote), {
|
|
1002
|
-
entry: normalizedRemote.entry
|
|
1003
|
-
});
|
|
1004
|
-
}
|
|
1005
|
-
remotes.push(remote);
|
|
1006
|
-
remotesConsumerMap[nameForCondition] = remote;
|
|
1007
|
-
}
|
|
1008
|
-
if (reasons) {
|
|
1009
|
-
reasons.forEach(function(param) {
|
|
1010
|
-
var userRequest = param.userRequest, resolvedModule = param.resolvedModule, moduleName = param.moduleName;
|
|
1011
|
-
var exposeModName = _this.isRspack ? moduleName : resolvedModule;
|
|
1012
|
-
if (userRequest && exposeModName && remotesConsumerMap[userRequest]) {
|
|
1013
|
-
// @ts-ignore to deduplicate
|
|
1014
|
-
remotesConsumerMap[userRequest].usedIn.add(exposeModName.replace('./', ''));
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
557
|
+
if (pkgName && pkgVersion) {
|
|
558
|
+
initShared(pkgName, pkgVersion);
|
|
559
|
+
collectRelationshipMap(mod, pkgName);
|
|
1018
560
|
}
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
_handleRemoteModule(mod, remotes, remotesConsumerMap) {
|
|
564
|
+
const { identifier, reasons, nameForCondition } = mod;
|
|
565
|
+
if (!identifier) {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const remoteManagerNormalizedOptions = this._remoteManager.normalizedOptions;
|
|
569
|
+
// identifier = remote (default) webpack/container/reference/app2 ./Button
|
|
570
|
+
const data = identifier.split(' ');
|
|
571
|
+
if (data.length === 4) {
|
|
572
|
+
const moduleName = data[3].replace('./', '');
|
|
573
|
+
const remoteAlias = data[2].replace('webpack/container/reference/', '');
|
|
574
|
+
const normalizedRemote = remoteManagerNormalizedOptions[remoteAlias];
|
|
575
|
+
const basicRemote = {
|
|
576
|
+
alias: normalizedRemote.alias,
|
|
577
|
+
consumingFederationContainerName: this._options.name || '',
|
|
578
|
+
federationContainerName: remoteManagerNormalizedOptions[remoteAlias].name,
|
|
579
|
+
moduleName,
|
|
580
|
+
// @ts-ignore to deduplicate
|
|
581
|
+
usedIn: new Set(),
|
|
582
|
+
};
|
|
583
|
+
if (!nameForCondition) {
|
|
584
|
+
return;
|
|
1039
585
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
var remotes = [];
|
|
1046
|
-
var remotesConsumerMap = {};
|
|
1047
|
-
var exposesMap = {};
|
|
1048
|
-
var sharedMap = {};
|
|
1049
|
-
var isSharedModule = function(moduleType) {
|
|
1050
|
-
return Boolean(moduleType && [
|
|
1051
|
-
'provide-module',
|
|
1052
|
-
'consume-shared-module'
|
|
1053
|
-
].includes(moduleType));
|
|
586
|
+
let remote;
|
|
587
|
+
if ('version' in normalizedRemote) {
|
|
588
|
+
remote = {
|
|
589
|
+
...basicRemote,
|
|
590
|
+
version: normalizedRemote.version,
|
|
1054
591
|
};
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
var data = identifier.split(' ');
|
|
1061
|
-
return data[0] === 'remote';
|
|
1062
|
-
};
|
|
1063
|
-
// handle remote/expose
|
|
1064
|
-
this._modules.forEach(function(mod) {
|
|
1065
|
-
var identifier = mod.identifier; mod.reasons; mod.nameForCondition; var moduleType = mod.moduleType;
|
|
1066
|
-
if (!identifier) {
|
|
1067
|
-
return;
|
|
1068
|
-
}
|
|
1069
|
-
if (isSharedModule(moduleType)) {
|
|
1070
|
-
_this._handleSharedModule(mod, sharedMap, exposesMap);
|
|
1071
|
-
}
|
|
1072
|
-
if (isRemoteModule(identifier)) {
|
|
1073
|
-
_this._handleRemoteModule(mod, remotes, remotesConsumerMap);
|
|
1074
|
-
} else if (isContainerModule(identifier)) {
|
|
1075
|
-
_this._handleContainerModule(mod, exposesMap);
|
|
1076
|
-
}
|
|
1077
|
-
});
|
|
1078
|
-
return {
|
|
1079
|
-
remotes: remotes,
|
|
1080
|
-
exposesMap: exposesMap,
|
|
1081
|
-
sharedMap: sharedMap
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
remote = {
|
|
595
|
+
...basicRemote,
|
|
596
|
+
entry: normalizedRemote.entry,
|
|
1082
597
|
};
|
|
1083
598
|
}
|
|
599
|
+
remotes.push(remote);
|
|
600
|
+
remotesConsumerMap[nameForCondition] = remote;
|
|
601
|
+
}
|
|
602
|
+
if (reasons) {
|
|
603
|
+
reasons.forEach(({ userRequest, resolvedModule, moduleName }) => {
|
|
604
|
+
let exposeModName = this.isRspack ? moduleName : resolvedModule;
|
|
605
|
+
if (userRequest && exposeModName && remotesConsumerMap[userRequest]) {
|
|
606
|
+
// @ts-ignore to deduplicate
|
|
607
|
+
remotesConsumerMap[userRequest].usedIn.add(exposeModName.replace('./', ''));
|
|
608
|
+
}
|
|
609
|
+
});
|
|
1084
610
|
}
|
|
1085
|
-
]);
|
|
1086
|
-
return ModuleHandler;
|
|
1087
|
-
}();
|
|
1088
|
-
|
|
1089
|
-
/* eslint-disable max-lines-per-function */ /* eslint-disable @typescript-eslint/member-ordering */ /* eslint-disable max-depth */ function _array_like_to_array(arr, len) {
|
|
1090
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1091
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1092
|
-
return arr2;
|
|
1093
|
-
}
|
|
1094
|
-
function _array_with_holes(arr) {
|
|
1095
|
-
if (Array.isArray(arr)) return arr;
|
|
1096
|
-
}
|
|
1097
|
-
function _array_without_holes(arr) {
|
|
1098
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1099
|
-
}
|
|
1100
|
-
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1101
|
-
try {
|
|
1102
|
-
var info = gen[key](arg);
|
|
1103
|
-
var value = info.value;
|
|
1104
|
-
} catch (error) {
|
|
1105
|
-
reject(error);
|
|
1106
|
-
return;
|
|
1107
|
-
}
|
|
1108
|
-
if (info.done) {
|
|
1109
|
-
resolve(value);
|
|
1110
|
-
} else {
|
|
1111
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
function _async_to_generator$1(fn) {
|
|
1115
|
-
return function() {
|
|
1116
|
-
var self = this, args = arguments;
|
|
1117
|
-
return new Promise(function(resolve, reject) {
|
|
1118
|
-
var gen = fn.apply(self, args);
|
|
1119
|
-
function _next(value) {
|
|
1120
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
1121
|
-
}
|
|
1122
|
-
function _throw(err) {
|
|
1123
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1124
|
-
}
|
|
1125
|
-
_next(undefined);
|
|
1126
|
-
});
|
|
1127
|
-
};
|
|
1128
|
-
}
|
|
1129
|
-
function _class_call_check$1(instance, Constructor) {
|
|
1130
|
-
if (!(instance instanceof Constructor)) {
|
|
1131
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
function _defineProperties$1(target, props) {
|
|
1135
|
-
for(var i = 0; i < props.length; i++){
|
|
1136
|
-
var descriptor = props[i];
|
|
1137
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1138
|
-
descriptor.configurable = true;
|
|
1139
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
1140
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1141
611
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
612
|
+
_handleContainerModule(mod, exposesMap) {
|
|
613
|
+
const { identifier } = mod;
|
|
614
|
+
if (!identifier) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
// identifier: container entry (default) [[".",{"import":["./src/routes/page.tsx"],"name":"__federation_expose_default_export"}]]'
|
|
618
|
+
const entries = parseContainerExposeEntries(identifier) ??
|
|
619
|
+
this._getContainerExposeEntriesFromOptions();
|
|
620
|
+
if (!entries) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
entries.forEach(([prefixedName, file]) => {
|
|
624
|
+
// TODO: support multiple import
|
|
625
|
+
exposesMap[getFileNameWithOutExt(file.import[0])] = getExposeItem({
|
|
626
|
+
exposeKey: prefixedName,
|
|
627
|
+
name: this._options.name,
|
|
628
|
+
file,
|
|
629
|
+
});
|
|
1154
630
|
});
|
|
1155
|
-
} else {
|
|
1156
|
-
obj[key] = value;
|
|
1157
631
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
try {
|
|
1171
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
1172
|
-
_arr.push(_s.value);
|
|
1173
|
-
if (i && _arr.length === i) break;
|
|
632
|
+
_getContainerExposeEntriesFromOptions() {
|
|
633
|
+
const exposes = this._containerManager.containerPluginExposesOptions;
|
|
634
|
+
const normalizedEntries = Object.entries(exposes).reduce((acc, [exposeKey, exposeOptions]) => {
|
|
635
|
+
const normalizedExpose = normalizeExposeValue(exposeOptions);
|
|
636
|
+
if (!normalizedExpose?.import.length) {
|
|
637
|
+
return acc;
|
|
638
|
+
}
|
|
639
|
+
acc.push([exposeKey, normalizedExpose]);
|
|
640
|
+
return acc;
|
|
641
|
+
}, []);
|
|
642
|
+
if (normalizedEntries.length) {
|
|
643
|
+
return normalizedEntries;
|
|
1174
644
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
} finally{
|
|
1179
|
-
try {
|
|
1180
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1181
|
-
} finally{
|
|
1182
|
-
if (_d) throw _e;
|
|
645
|
+
const rawExposes = this._options.exposes;
|
|
646
|
+
if (!rawExposes || Array.isArray(rawExposes)) {
|
|
647
|
+
return undefined;
|
|
1183
648
|
}
|
|
649
|
+
const normalizedFromOptions = Object.entries(rawExposes).reduce((acc, [exposeKey, exposeOptions]) => {
|
|
650
|
+
const normalizedExpose = normalizeExposeValue(exposeOptions);
|
|
651
|
+
if (!normalizedExpose?.import.length) {
|
|
652
|
+
return acc;
|
|
653
|
+
}
|
|
654
|
+
acc.push([exposeKey, normalizedExpose]);
|
|
655
|
+
return acc;
|
|
656
|
+
}, []);
|
|
657
|
+
return normalizedFromOptions.length ? normalizedFromOptions : undefined;
|
|
1184
658
|
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1189
|
-
}
|
|
1190
|
-
function _non_iterable_spread() {
|
|
1191
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1192
|
-
}
|
|
1193
|
-
function _object_spread(target) {
|
|
1194
|
-
for(var i = 1; i < arguments.length; i++){
|
|
1195
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
1196
|
-
var ownKeys = Object.keys(source);
|
|
1197
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
1198
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
1199
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
1200
|
-
}));
|
|
659
|
+
_initializeExposesFromOptions(exposesMap) {
|
|
660
|
+
if (!this._options.name || !this._containerManager.enable) {
|
|
661
|
+
return;
|
|
1201
662
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
1220
|
-
} else {
|
|
1221
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
1222
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
663
|
+
const exposes = this._containerManager.containerPluginExposesOptions;
|
|
664
|
+
Object.entries(exposes).forEach(([exposeKey, exposeOptions]) => {
|
|
665
|
+
if (!exposeOptions.import?.length) {
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
const [exposeImport] = exposeOptions.import;
|
|
669
|
+
if (!exposeImport) {
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
const exposeMapKey = getFileNameWithOutExt(exposeImport);
|
|
673
|
+
if (!exposesMap[exposeMapKey]) {
|
|
674
|
+
exposesMap[exposeMapKey] = getExposeItem({
|
|
675
|
+
exposeKey,
|
|
676
|
+
name: this._options.name,
|
|
677
|
+
file: exposeOptions,
|
|
678
|
+
});
|
|
679
|
+
}
|
|
1223
680
|
});
|
|
1224
681
|
}
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
"@swc/helpers - typeof";
|
|
1235
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1236
|
-
}
|
|
1237
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
1238
|
-
if (!o) return;
|
|
1239
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1240
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1241
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1242
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1243
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1244
|
-
}
|
|
1245
|
-
function _ts_generator$1(thisArg, body) {
|
|
1246
|
-
var f, y, t, g, _ = {
|
|
1247
|
-
label: 0,
|
|
1248
|
-
sent: function() {
|
|
1249
|
-
if (t[0] & 1) throw t[1];
|
|
1250
|
-
return t[1];
|
|
1251
|
-
},
|
|
1252
|
-
trys: [],
|
|
1253
|
-
ops: []
|
|
1254
|
-
};
|
|
1255
|
-
return g = {
|
|
1256
|
-
next: verb(0),
|
|
1257
|
-
"throw": verb(1),
|
|
1258
|
-
"return": verb(2)
|
|
1259
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
1260
|
-
return this;
|
|
1261
|
-
}), g;
|
|
1262
|
-
function verb(n) {
|
|
1263
|
-
return function(v) {
|
|
1264
|
-
return step([
|
|
1265
|
-
n,
|
|
1266
|
-
v
|
|
1267
|
-
]);
|
|
682
|
+
collect() {
|
|
683
|
+
const remotes = [];
|
|
684
|
+
const remotesConsumerMap = {};
|
|
685
|
+
const exposesMap = {};
|
|
686
|
+
const sharedMap = {};
|
|
687
|
+
this._initializeExposesFromOptions(exposesMap);
|
|
688
|
+
const isSharedModule = (moduleType) => {
|
|
689
|
+
return Boolean(moduleType &&
|
|
690
|
+
['provide-module', 'consume-shared-module'].includes(moduleType));
|
|
1268
691
|
};
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
case 1:
|
|
1281
|
-
t = op;
|
|
1282
|
-
break;
|
|
1283
|
-
case 4:
|
|
1284
|
-
_.label++;
|
|
1285
|
-
return {
|
|
1286
|
-
value: op[1],
|
|
1287
|
-
done: false
|
|
1288
|
-
};
|
|
1289
|
-
case 5:
|
|
1290
|
-
_.label++;
|
|
1291
|
-
y = op[1];
|
|
1292
|
-
op = [
|
|
1293
|
-
0
|
|
1294
|
-
];
|
|
1295
|
-
continue;
|
|
1296
|
-
case 7:
|
|
1297
|
-
op = _.ops.pop();
|
|
1298
|
-
_.trys.pop();
|
|
1299
|
-
continue;
|
|
1300
|
-
default:
|
|
1301
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1302
|
-
_ = 0;
|
|
1303
|
-
continue;
|
|
1304
|
-
}
|
|
1305
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1306
|
-
_.label = op[1];
|
|
1307
|
-
break;
|
|
1308
|
-
}
|
|
1309
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1310
|
-
_.label = t[1];
|
|
1311
|
-
t = op;
|
|
1312
|
-
break;
|
|
1313
|
-
}
|
|
1314
|
-
if (t && _.label < t[2]) {
|
|
1315
|
-
_.label = t[2];
|
|
1316
|
-
_.ops.push(op);
|
|
1317
|
-
break;
|
|
1318
|
-
}
|
|
1319
|
-
if (t[2]) _.ops.pop();
|
|
1320
|
-
_.trys.pop();
|
|
1321
|
-
continue;
|
|
692
|
+
const isContainerModule = (identifier) => {
|
|
693
|
+
return identifier.startsWith('container entry');
|
|
694
|
+
};
|
|
695
|
+
const isRemoteModule = (identifier) => {
|
|
696
|
+
return identifier.startsWith('remote ');
|
|
697
|
+
};
|
|
698
|
+
// handle remote/expose
|
|
699
|
+
this._modules.forEach((mod) => {
|
|
700
|
+
const { identifier, reasons, nameForCondition, moduleType } = mod;
|
|
701
|
+
if (!identifier) {
|
|
702
|
+
return;
|
|
1322
703
|
}
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
704
|
+
if (isSharedModule(moduleType)) {
|
|
705
|
+
this._handleSharedModule(mod, sharedMap, exposesMap);
|
|
706
|
+
}
|
|
707
|
+
if (isRemoteModule(identifier)) {
|
|
708
|
+
this._handleRemoteModule(mod, remotes, remotesConsumerMap);
|
|
709
|
+
}
|
|
710
|
+
else if (!this._containerManager.enable &&
|
|
711
|
+
isContainerModule(identifier)) {
|
|
712
|
+
this._handleContainerModule(mod, exposesMap);
|
|
713
|
+
}
|
|
714
|
+
});
|
|
1334
715
|
return {
|
|
1335
|
-
|
|
1336
|
-
|
|
716
|
+
remotes,
|
|
717
|
+
exposesMap,
|
|
718
|
+
sharedMap,
|
|
1337
719
|
};
|
|
1338
720
|
}
|
|
1339
721
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
722
|
+
|
|
723
|
+
/* eslint-disable max-lines-per-function */
|
|
724
|
+
/* eslint-disable @typescript-eslint/member-ordering */
|
|
725
|
+
/* eslint-disable max-depth */
|
|
726
|
+
class StatsManager {
|
|
727
|
+
constructor() {
|
|
1343
728
|
this._options = {};
|
|
1344
729
|
this._bundler = 'webpack';
|
|
1345
730
|
this._containerManager = new managers.ContainerManager();
|
|
@@ -1347,696 +732,401 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1347
732
|
this._sharedManager = new managers.SharedManager();
|
|
1348
733
|
this._pkgJsonManager = new managers.PKGJsonManager();
|
|
1349
734
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
735
|
+
getBuildInfo(context) {
|
|
736
|
+
const rootPath = context || process.cwd();
|
|
737
|
+
const pkg = this._pkgJsonManager.readPKGJson(rootPath);
|
|
738
|
+
return {
|
|
739
|
+
buildVersion: managers.utils.getBuildVersion(rootPath),
|
|
740
|
+
buildName: managers.utils.getBuildName() || pkg['name'],
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
get fileName() {
|
|
744
|
+
return sdk.getManifestFileName(this._options.manifest).statsFileName;
|
|
745
|
+
}
|
|
746
|
+
_getMetaData(compiler, compilation, extraOptions) {
|
|
747
|
+
const { context } = compiler.options;
|
|
748
|
+
const { _options: { name }, } = this;
|
|
749
|
+
const buildInfo = this.getBuildInfo(context);
|
|
750
|
+
const type = this._pkgJsonManager.getExposeGarfishModuleType(context || process.cwd());
|
|
751
|
+
const getRemoteEntryName = () => {
|
|
752
|
+
if (!this._containerManager.enable) {
|
|
753
|
+
return '';
|
|
1360
754
|
}
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
755
|
+
assert(name, 'name is required');
|
|
756
|
+
const remoteEntryPoint = compilation.entrypoints.get(name);
|
|
757
|
+
assert(remoteEntryPoint, 'Can not get remoteEntry entryPoint!');
|
|
758
|
+
const remoteEntryNameChunk = compilation.namedChunks.get(name);
|
|
759
|
+
assert(remoteEntryNameChunk, 'Can not get remoteEntry chunk!');
|
|
760
|
+
const files = Array.from(remoteEntryNameChunk.files).filter((f) => !f.includes(HOT_UPDATE_SUFFIX) && !f.endsWith('.css'));
|
|
761
|
+
assert(files.length > 0, 'no files found for remoteEntry chunk');
|
|
762
|
+
assert(files.length === 1, `remoteEntry chunk should not have multiple files!, current files: ${files.join(',')}`);
|
|
763
|
+
const remoteEntryName = files[0];
|
|
764
|
+
return remoteEntryName;
|
|
765
|
+
};
|
|
766
|
+
const globalName = this._containerManager.globalEntryName;
|
|
767
|
+
assert(globalName, 'Can not get library.name, please ensure you have set library.name and the type is "string" !');
|
|
768
|
+
assert(this._pluginVersion, 'Can not get pluginVersion, please ensure you have set pluginVersion !');
|
|
769
|
+
const metaData = {
|
|
770
|
+
name: name,
|
|
771
|
+
type,
|
|
772
|
+
buildInfo,
|
|
773
|
+
remoteEntry: {
|
|
774
|
+
name: getRemoteEntryName(),
|
|
775
|
+
path: '',
|
|
776
|
+
// same as the types supported by runtime, currently only global/var/script is supported
|
|
777
|
+
type: this._options?.library?.type ||
|
|
778
|
+
'global',
|
|
779
|
+
},
|
|
780
|
+
types: getTypesMetaInfo(this._options, compiler.context),
|
|
781
|
+
globalName: globalName,
|
|
782
|
+
pluginVersion: this._pluginVersion,
|
|
783
|
+
};
|
|
784
|
+
let prefetchInterface = false;
|
|
785
|
+
const prefetchFilePath = path.resolve(compiler.options.context || process.cwd(), `node_modules/.mf/${sdk.encodeName(name)}/${sdk.MFPrefetchCommon.fileName}`);
|
|
786
|
+
const existPrefetch = fs.existsSync(prefetchFilePath);
|
|
787
|
+
if (existPrefetch) {
|
|
788
|
+
const content = fs.readFileSync(prefetchFilePath).toString();
|
|
789
|
+
if (content) {
|
|
790
|
+
prefetchInterface = true;
|
|
1366
791
|
}
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
792
|
+
}
|
|
793
|
+
metaData.prefetchInterface = prefetchInterface;
|
|
794
|
+
if (this._options.getPublicPath) {
|
|
795
|
+
if ('publicPath' in metaData) {
|
|
796
|
+
delete metaData.publicPath;
|
|
797
|
+
}
|
|
798
|
+
return {
|
|
799
|
+
...metaData,
|
|
800
|
+
getPublicPath: this._options.getPublicPath,
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
return {
|
|
804
|
+
...metaData,
|
|
805
|
+
publicPath: this.getPublicPath(compiler),
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
_getFilteredModules(stats) {
|
|
809
|
+
const filteredModules = stats.modules.filter((module) => {
|
|
810
|
+
if (!module || !module.name) {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
const array = [
|
|
814
|
+
module.name.includes('container entry'),
|
|
815
|
+
module.name.includes('remote '),
|
|
816
|
+
module.name.includes('shared module '),
|
|
817
|
+
module.name.includes('provide module '),
|
|
818
|
+
];
|
|
819
|
+
return array.some((item) => item);
|
|
820
|
+
});
|
|
821
|
+
return filteredModules;
|
|
822
|
+
}
|
|
823
|
+
_getModuleAssets(compilation, entryPointNames) {
|
|
824
|
+
const { chunks } = compilation;
|
|
825
|
+
const { exposeFileNameImportMap } = this._containerManager;
|
|
826
|
+
const assets = {};
|
|
827
|
+
chunks.forEach((chunk) => {
|
|
828
|
+
if (typeof chunk.name === 'string' &&
|
|
829
|
+
exposeFileNameImportMap[chunk.name]) {
|
|
830
|
+
// TODO: support multiple import
|
|
831
|
+
const exposeKey = exposeFileNameImportMap[chunk.name][0];
|
|
832
|
+
assets[getFileNameWithOutExt(exposeKey)] = getAssetsByChunk(chunk, entryPointNames);
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
return assets;
|
|
836
|
+
}
|
|
837
|
+
_getProvideSharedAssets(compilation, stats, entryPointNames) {
|
|
838
|
+
const sharedModules = stats.modules.filter((module) => {
|
|
839
|
+
if (!module || !module.name) {
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
842
|
+
const array = [module.name.includes('consume shared module ')];
|
|
843
|
+
return array.some((item) => item);
|
|
844
|
+
});
|
|
845
|
+
const manifestOverrideChunkIDMap = {};
|
|
846
|
+
const effectiveSharedModules = getSharedModules(stats, sharedModules);
|
|
847
|
+
effectiveSharedModules.forEach((item) => {
|
|
848
|
+
const [sharedModuleName, sharedModule] = item;
|
|
849
|
+
if (!manifestOverrideChunkIDMap[sharedModuleName]) {
|
|
850
|
+
manifestOverrideChunkIDMap[sharedModuleName] = {
|
|
851
|
+
async: new Set(),
|
|
852
|
+
sync: new Set(),
|
|
1410
853
|
};
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
prefetchInterface = true;
|
|
1418
|
-
}
|
|
854
|
+
}
|
|
855
|
+
sharedModule.chunks.forEach((chunkID) => {
|
|
856
|
+
const chunk = findChunk(chunkID, compilation.chunks);
|
|
857
|
+
manifestOverrideChunkIDMap[sharedModuleName].sync.add(chunkID);
|
|
858
|
+
if (!chunk) {
|
|
859
|
+
return;
|
|
1419
860
|
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
delete metaData.publicPath;
|
|
861
|
+
[...chunk.groupsIterable].forEach((group) => {
|
|
862
|
+
if (group.name && !entryPointNames.includes(group.name)) {
|
|
863
|
+
manifestOverrideChunkIDMap[sharedModuleName].sync.add(group.id);
|
|
1424
864
|
}
|
|
1425
|
-
return _object_spread_props(_object_spread({}, metaData), {
|
|
1426
|
-
getPublicPath: this._options.getPublicPath
|
|
1427
|
-
});
|
|
1428
|
-
}
|
|
1429
|
-
return _object_spread_props(_object_spread({}, metaData), {
|
|
1430
|
-
publicPath: this.getPublicPath(compiler)
|
|
1431
865
|
});
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
{
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
866
|
+
});
|
|
867
|
+
});
|
|
868
|
+
const assets = {
|
|
869
|
+
js: {
|
|
870
|
+
async: [],
|
|
871
|
+
sync: [],
|
|
872
|
+
},
|
|
873
|
+
css: {
|
|
874
|
+
async: [],
|
|
875
|
+
sync: [],
|
|
876
|
+
},
|
|
877
|
+
};
|
|
878
|
+
Object.keys(manifestOverrideChunkIDMap).forEach((override) => {
|
|
879
|
+
const asyncAssets = getAssetsByChunkIDs(compilation, {
|
|
880
|
+
[override]: manifestOverrideChunkIDMap[override].async,
|
|
881
|
+
});
|
|
882
|
+
const syncAssets = getAssetsByChunkIDs(compilation, {
|
|
883
|
+
[override]: manifestOverrideChunkIDMap[override].sync,
|
|
884
|
+
});
|
|
885
|
+
assets[override] = {
|
|
886
|
+
js: {
|
|
887
|
+
async: asyncAssets[override].js,
|
|
888
|
+
sync: syncAssets[override].js,
|
|
889
|
+
},
|
|
890
|
+
css: {
|
|
891
|
+
async: asyncAssets[override].css,
|
|
892
|
+
sync: syncAssets[override].css,
|
|
893
|
+
},
|
|
894
|
+
};
|
|
895
|
+
});
|
|
896
|
+
return assets;
|
|
897
|
+
}
|
|
898
|
+
async _generateStats(compiler, compilation, extraOptions) {
|
|
899
|
+
try {
|
|
900
|
+
const { name, manifest: manifestOptions = {}, exposes = {}, } = this._options;
|
|
901
|
+
const metaData = this._getMetaData(compiler, compilation, extraOptions);
|
|
902
|
+
const stats = {
|
|
903
|
+
id: name,
|
|
904
|
+
name: name,
|
|
905
|
+
metaData,
|
|
906
|
+
shared: [],
|
|
907
|
+
remotes: [],
|
|
908
|
+
exposes: [],
|
|
909
|
+
};
|
|
910
|
+
if (typeof manifestOptions === 'object' &&
|
|
911
|
+
manifestOptions.disableAssetsAnalyze) {
|
|
912
|
+
const remotes = this._remoteManager.statsRemoteWithEmptyUsedIn;
|
|
913
|
+
stats.remotes = remotes;
|
|
914
|
+
stats.exposes = Object.keys(exposes).map((exposeKey) => {
|
|
915
|
+
return getExposeItem({
|
|
916
|
+
exposeKey,
|
|
917
|
+
name: name,
|
|
918
|
+
file: {
|
|
919
|
+
import: exposes[exposeKey].import,
|
|
920
|
+
},
|
|
1449
921
|
});
|
|
1450
922
|
});
|
|
1451
|
-
return
|
|
923
|
+
return stats;
|
|
1452
924
|
}
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
925
|
+
const liveStats = compilation.getStats();
|
|
926
|
+
const statsOptions = {
|
|
927
|
+
all: false,
|
|
928
|
+
modules: true,
|
|
929
|
+
builtAt: true,
|
|
930
|
+
hash: true,
|
|
931
|
+
ids: true,
|
|
932
|
+
version: true,
|
|
933
|
+
entrypoints: true,
|
|
934
|
+
assets: false,
|
|
935
|
+
chunks: false,
|
|
936
|
+
reasons: true,
|
|
937
|
+
};
|
|
938
|
+
if (this._bundler === 'webpack') {
|
|
939
|
+
statsOptions['cached'] = true;
|
|
1468
940
|
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
941
|
+
statsOptions['cachedModules'] = true;
|
|
942
|
+
const webpackStats = liveStats.toJson(statsOptions);
|
|
943
|
+
const filteredModules = this._getFilteredModules(webpackStats);
|
|
944
|
+
const moduleHandler = new ModuleHandler(this._options, filteredModules, {
|
|
945
|
+
bundler: this._bundler,
|
|
946
|
+
});
|
|
947
|
+
const { remotes, exposesMap, sharedMap } = moduleHandler.collect();
|
|
948
|
+
const entryPointNames = [...compilation.entrypoints.values()]
|
|
949
|
+
.map((e) => e.name)
|
|
950
|
+
.filter((v) => !!v);
|
|
951
|
+
await Promise.all([
|
|
952
|
+
new Promise((resolve) => {
|
|
953
|
+
const sharedAssets = this._getProvideSharedAssets(compilation, webpackStats, entryPointNames);
|
|
954
|
+
Object.keys(sharedMap).forEach((sharedKey) => {
|
|
955
|
+
const assets = sharedAssets[sharedKey];
|
|
956
|
+
if (assets) {
|
|
957
|
+
sharedMap[sharedKey].assets = assets;
|
|
958
|
+
}
|
|
1482
959
|
});
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
960
|
+
resolve();
|
|
961
|
+
}),
|
|
962
|
+
new Promise((resolve) => {
|
|
963
|
+
const moduleAssets = this._getModuleAssets(compilation, entryPointNames);
|
|
964
|
+
Object.keys(exposesMap).forEach((exposeKey) => {
|
|
965
|
+
const assets = moduleAssets[exposeKey];
|
|
966
|
+
if (assets) {
|
|
967
|
+
exposesMap[exposeKey].assets = assets;
|
|
968
|
+
}
|
|
969
|
+
exposesMap[exposeKey].requires = Array.from(new Set(exposesMap[exposeKey].requires));
|
|
970
|
+
});
|
|
971
|
+
resolve();
|
|
972
|
+
}),
|
|
973
|
+
]);
|
|
974
|
+
await Promise.all([
|
|
975
|
+
new Promise((resolve) => {
|
|
976
|
+
const remoteMemo = new Set();
|
|
977
|
+
stats.remotes = remotes.map((remote) => {
|
|
978
|
+
remoteMemo.add(remote.federationContainerName);
|
|
979
|
+
return {
|
|
980
|
+
...remote,
|
|
981
|
+
usedIn: Array.from(remote.usedIn.values()),
|
|
1492
982
|
};
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
return;
|
|
983
|
+
});
|
|
984
|
+
const statsRemoteWithEmptyUsedIn = this._remoteManager.statsRemoteWithEmptyUsedIn;
|
|
985
|
+
statsRemoteWithEmptyUsedIn.forEach((remoteInfo) => {
|
|
986
|
+
if (!remoteMemo.has(remoteInfo.federationContainerName)) {
|
|
987
|
+
stats.remotes.push(remoteInfo);
|
|
1499
988
|
}
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
989
|
+
});
|
|
990
|
+
resolve();
|
|
991
|
+
}),
|
|
992
|
+
new Promise((resolve) => {
|
|
993
|
+
stats.shared = Object.values(sharedMap).map((shared) => ({
|
|
994
|
+
...shared,
|
|
995
|
+
usedIn: Array.from(shared.usedIn),
|
|
996
|
+
}));
|
|
997
|
+
resolve();
|
|
998
|
+
}),
|
|
999
|
+
]);
|
|
1000
|
+
await new Promise((resolve) => {
|
|
1001
|
+
const sharedAssets = stats.shared.reduce((sum, shared) => {
|
|
1002
|
+
const { js, css } = shared.assets;
|
|
1003
|
+
[...js.sync, ...js.async, ...css.async, css.sync].forEach((asset) => {
|
|
1004
|
+
sum.add(asset);
|
|
1005
|
+
});
|
|
1006
|
+
return sum;
|
|
1007
|
+
}, new Set());
|
|
1008
|
+
const { fileExposeKeyMap } = this._containerManager;
|
|
1009
|
+
stats.exposes = [];
|
|
1010
|
+
Object.entries(fileExposeKeyMap).forEach(([exposeFileWithoutExt, exposeKeySet]) => {
|
|
1011
|
+
const expose = exposesMap[exposeFileWithoutExt] || {
|
|
1012
|
+
assets: {
|
|
1013
|
+
js: { sync: [], async: [] },
|
|
1014
|
+
css: { sync: [], async: [] },
|
|
1015
|
+
},
|
|
1016
|
+
};
|
|
1017
|
+
exposeKeySet.forEach((exposeKey) => {
|
|
1018
|
+
const { js, css } = expose.assets;
|
|
1019
|
+
const exposeModuleName = getExposeName(exposeKey);
|
|
1020
|
+
stats.exposes.push({
|
|
1021
|
+
...expose,
|
|
1022
|
+
path: exposeKey,
|
|
1023
|
+
id: sdk.composeKeyWithSeparator(this._options.name, exposeModuleName),
|
|
1024
|
+
name: exposeModuleName,
|
|
1025
|
+
assets: {
|
|
1026
|
+
js: {
|
|
1027
|
+
sync: js.sync.filter((asset) => !sharedAssets.has(asset)),
|
|
1028
|
+
async: js.async.filter((asset) => !sharedAssets.has(asset)),
|
|
1029
|
+
},
|
|
1030
|
+
css: {
|
|
1031
|
+
sync: css.sync.filter((asset) => !sharedAssets.has(asset)),
|
|
1032
|
+
async: css.async.filter((asset) => !sharedAssets.has(asset)),
|
|
1033
|
+
},
|
|
1034
|
+
},
|
|
1504
1035
|
});
|
|
1505
1036
|
});
|
|
1506
1037
|
});
|
|
1507
|
-
|
|
1508
|
-
js
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
assets[override] = {
|
|
1521
|
-
js: {
|
|
1522
|
-
async: asyncAssets[override].js,
|
|
1523
|
-
sync: syncAssets[override].js
|
|
1038
|
+
Object.values(exposesMap).map((expose) => {
|
|
1039
|
+
const { js, css } = expose.assets;
|
|
1040
|
+
return {
|
|
1041
|
+
...expose,
|
|
1042
|
+
assets: {
|
|
1043
|
+
js: {
|
|
1044
|
+
sync: js.sync.filter((asset) => !sharedAssets.has(asset)),
|
|
1045
|
+
async: js.async.filter((asset) => !sharedAssets.has(asset)),
|
|
1046
|
+
},
|
|
1047
|
+
css: {
|
|
1048
|
+
sync: css.sync.filter((asset) => !sharedAssets.has(asset)),
|
|
1049
|
+
async: css.async.filter((asset) => !sharedAssets.has(asset)),
|
|
1050
|
+
},
|
|
1524
1051
|
},
|
|
1525
|
-
css: {
|
|
1526
|
-
async: asyncAssets[override].css,
|
|
1527
|
-
sync: syncAssets[override].css
|
|
1528
|
-
}
|
|
1529
1052
|
};
|
|
1530
1053
|
});
|
|
1531
|
-
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
var _this = this;
|
|
1538
|
-
return _async_to_generator$1(function() {
|
|
1539
|
-
var _this__options, name, tmp, manifestOptions, _this__options_exposes, exposes, metaData, stats, remotes, liveStats, statsOptions, webpackStats, filteredModules, moduleHandler, _moduleHandler_collect, remotes1, exposesMap, sharedMap, entryPointNames, err;
|
|
1540
|
-
return _ts_generator$1(this, function(_state) {
|
|
1541
|
-
switch(_state.label){
|
|
1542
|
-
case 0:
|
|
1543
|
-
_state.trys.push([
|
|
1544
|
-
0,
|
|
1545
|
-
4,
|
|
1546
|
-
,
|
|
1547
|
-
5
|
|
1548
|
-
]);
|
|
1549
|
-
_this__options = _this._options, name = _this__options.name, tmp = _this__options.manifest, manifestOptions = tmp === void 0 ? {} : tmp, _this__options_exposes = _this__options.exposes, exposes = _this__options_exposes === void 0 ? {} : _this__options_exposes;
|
|
1550
|
-
metaData = _this._getMetaData(compiler, compilation, extraOptions);
|
|
1551
|
-
stats = {
|
|
1552
|
-
id: name,
|
|
1553
|
-
name: name,
|
|
1554
|
-
metaData: metaData,
|
|
1555
|
-
shared: [],
|
|
1556
|
-
remotes: [],
|
|
1557
|
-
exposes: []
|
|
1558
|
-
};
|
|
1559
|
-
if ((typeof manifestOptions === "undefined" ? "undefined" : _type_of$1(manifestOptions)) === 'object' && manifestOptions.disableAssetsAnalyze) {
|
|
1560
|
-
remotes = _this._remoteManager.statsRemoteWithEmptyUsedIn;
|
|
1561
|
-
stats.remotes = remotes;
|
|
1562
|
-
stats.exposes = Object.keys(exposes).map(function(exposeKey) {
|
|
1563
|
-
return getExposeItem({
|
|
1564
|
-
exposeKey: exposeKey,
|
|
1565
|
-
name: name,
|
|
1566
|
-
file: {
|
|
1567
|
-
import: exposes[exposeKey].import
|
|
1568
|
-
}
|
|
1569
|
-
});
|
|
1570
|
-
});
|
|
1571
|
-
return [
|
|
1572
|
-
2,
|
|
1573
|
-
stats
|
|
1574
|
-
];
|
|
1575
|
-
}
|
|
1576
|
-
liveStats = compilation.getStats();
|
|
1577
|
-
statsOptions = {
|
|
1578
|
-
all: false,
|
|
1579
|
-
modules: true,
|
|
1580
|
-
builtAt: true,
|
|
1581
|
-
hash: true,
|
|
1582
|
-
ids: true,
|
|
1583
|
-
version: true,
|
|
1584
|
-
entrypoints: true,
|
|
1585
|
-
assets: false,
|
|
1586
|
-
chunks: false,
|
|
1587
|
-
reasons: true
|
|
1588
|
-
};
|
|
1589
|
-
if (_this._bundler === 'webpack') {
|
|
1590
|
-
statsOptions['cached'] = true;
|
|
1591
|
-
}
|
|
1592
|
-
statsOptions['cachedModules'] = true;
|
|
1593
|
-
webpackStats = liveStats.toJson(statsOptions);
|
|
1594
|
-
filteredModules = _this._getFilteredModules(webpackStats);
|
|
1595
|
-
moduleHandler = new ModuleHandler(_this._options, filteredModules, {
|
|
1596
|
-
bundler: _this._bundler
|
|
1597
|
-
});
|
|
1598
|
-
_moduleHandler_collect = moduleHandler.collect(), remotes1 = _moduleHandler_collect.remotes, exposesMap = _moduleHandler_collect.exposesMap, sharedMap = _moduleHandler_collect.sharedMap;
|
|
1599
|
-
entryPointNames = _to_consumable_array(compilation.entrypoints.values()).map(function(e) {
|
|
1600
|
-
return e.name;
|
|
1601
|
-
}).filter(function(v) {
|
|
1602
|
-
return !!v;
|
|
1603
|
-
});
|
|
1604
|
-
return [
|
|
1605
|
-
4,
|
|
1606
|
-
Promise.all([
|
|
1607
|
-
new Promise(function(resolve) {
|
|
1608
|
-
var sharedAssets = _this._getProvideSharedAssets(compilation, webpackStats, entryPointNames);
|
|
1609
|
-
Object.keys(sharedMap).forEach(function(sharedKey) {
|
|
1610
|
-
var assets = sharedAssets[sharedKey];
|
|
1611
|
-
if (assets) {
|
|
1612
|
-
sharedMap[sharedKey].assets = assets;
|
|
1613
|
-
}
|
|
1614
|
-
});
|
|
1615
|
-
resolve();
|
|
1616
|
-
}),
|
|
1617
|
-
new Promise(function(resolve) {
|
|
1618
|
-
var moduleAssets = _this._getModuleAssets(compilation, entryPointNames);
|
|
1619
|
-
Object.keys(exposesMap).forEach(function(exposeKey) {
|
|
1620
|
-
var assets = moduleAssets[exposeKey];
|
|
1621
|
-
if (assets) {
|
|
1622
|
-
exposesMap[exposeKey].assets = assets;
|
|
1623
|
-
}
|
|
1624
|
-
exposesMap[exposeKey].requires = Array.from(new Set(exposesMap[exposeKey].requires));
|
|
1625
|
-
});
|
|
1626
|
-
resolve();
|
|
1627
|
-
})
|
|
1628
|
-
])
|
|
1629
|
-
];
|
|
1630
|
-
case 1:
|
|
1631
|
-
_state.sent();
|
|
1632
|
-
return [
|
|
1633
|
-
4,
|
|
1634
|
-
Promise.all([
|
|
1635
|
-
new Promise(function(resolve) {
|
|
1636
|
-
var remoteMemo = new Set();
|
|
1637
|
-
stats.remotes = remotes1.map(function(remote) {
|
|
1638
|
-
remoteMemo.add(remote.federationContainerName);
|
|
1639
|
-
return _object_spread_props(_object_spread({}, remote), {
|
|
1640
|
-
usedIn: Array.from(remote.usedIn.values())
|
|
1641
|
-
});
|
|
1642
|
-
});
|
|
1643
|
-
var statsRemoteWithEmptyUsedIn = _this._remoteManager.statsRemoteWithEmptyUsedIn;
|
|
1644
|
-
statsRemoteWithEmptyUsedIn.forEach(function(remoteInfo) {
|
|
1645
|
-
if (!remoteMemo.has(remoteInfo.federationContainerName)) {
|
|
1646
|
-
stats.remotes.push(remoteInfo);
|
|
1647
|
-
}
|
|
1648
|
-
});
|
|
1649
|
-
resolve();
|
|
1650
|
-
}),
|
|
1651
|
-
new Promise(function(resolve) {
|
|
1652
|
-
stats.shared = Object.values(sharedMap).map(function(shared) {
|
|
1653
|
-
return _object_spread_props(_object_spread({}, shared), {
|
|
1654
|
-
usedIn: Array.from(shared.usedIn)
|
|
1655
|
-
});
|
|
1656
|
-
});
|
|
1657
|
-
resolve();
|
|
1658
|
-
})
|
|
1659
|
-
])
|
|
1660
|
-
];
|
|
1661
|
-
case 2:
|
|
1662
|
-
_state.sent();
|
|
1663
|
-
return [
|
|
1664
|
-
4,
|
|
1665
|
-
new Promise(function(resolve) {
|
|
1666
|
-
var sharedAssets = stats.shared.reduce(function(sum, shared) {
|
|
1667
|
-
var _shared_assets = shared.assets, js = _shared_assets.js, css = _shared_assets.css;
|
|
1668
|
-
_to_consumable_array(js.sync).concat(_to_consumable_array(js.async), _to_consumable_array(css.async), [
|
|
1669
|
-
css.sync
|
|
1670
|
-
]).forEach(function(asset) {
|
|
1671
|
-
sum.add(asset);
|
|
1672
|
-
});
|
|
1673
|
-
return sum;
|
|
1674
|
-
}, new Set());
|
|
1675
|
-
var fileExposeKeyMap = _this._containerManager.fileExposeKeyMap;
|
|
1676
|
-
stats.exposes = [];
|
|
1677
|
-
Object.entries(fileExposeKeyMap).forEach(function(param) {
|
|
1678
|
-
var _param = _sliced_to_array(param, 2), exposeFileWithoutExt = _param[0], exposeKeySet = _param[1];
|
|
1679
|
-
var expose = exposesMap[exposeFileWithoutExt] || {
|
|
1680
|
-
assets: {
|
|
1681
|
-
js: {
|
|
1682
|
-
sync: [],
|
|
1683
|
-
async: []
|
|
1684
|
-
},
|
|
1685
|
-
css: {
|
|
1686
|
-
sync: [],
|
|
1687
|
-
async: []
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
|
-
};
|
|
1691
|
-
exposeKeySet.forEach(function(exposeKey) {
|
|
1692
|
-
var _expose_assets = expose.assets, js = _expose_assets.js, css = _expose_assets.css;
|
|
1693
|
-
var exposeModuleName = getExposeName(exposeKey);
|
|
1694
|
-
stats.exposes.push(_object_spread_props(_object_spread({}, expose), {
|
|
1695
|
-
path: exposeKey,
|
|
1696
|
-
id: sdk.composeKeyWithSeparator(_this._options.name, exposeModuleName),
|
|
1697
|
-
name: exposeModuleName,
|
|
1698
|
-
assets: {
|
|
1699
|
-
js: {
|
|
1700
|
-
sync: js.sync.filter(function(asset) {
|
|
1701
|
-
return !sharedAssets.has(asset);
|
|
1702
|
-
}),
|
|
1703
|
-
async: js.async.filter(function(asset) {
|
|
1704
|
-
return !sharedAssets.has(asset);
|
|
1705
|
-
})
|
|
1706
|
-
},
|
|
1707
|
-
css: {
|
|
1708
|
-
sync: css.sync.filter(function(asset) {
|
|
1709
|
-
return !sharedAssets.has(asset);
|
|
1710
|
-
}),
|
|
1711
|
-
async: css.async.filter(function(asset) {
|
|
1712
|
-
return !sharedAssets.has(asset);
|
|
1713
|
-
})
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
}));
|
|
1717
|
-
});
|
|
1718
|
-
});
|
|
1719
|
-
Object.values(exposesMap).map(function(expose) {
|
|
1720
|
-
var _expose_assets = expose.assets, js = _expose_assets.js, css = _expose_assets.css;
|
|
1721
|
-
return _object_spread_props(_object_spread({}, expose), {
|
|
1722
|
-
assets: {
|
|
1723
|
-
js: {
|
|
1724
|
-
sync: js.sync.filter(function(asset) {
|
|
1725
|
-
return !sharedAssets.has(asset);
|
|
1726
|
-
}),
|
|
1727
|
-
async: js.async.filter(function(asset) {
|
|
1728
|
-
return !sharedAssets.has(asset);
|
|
1729
|
-
})
|
|
1730
|
-
},
|
|
1731
|
-
css: {
|
|
1732
|
-
sync: css.sync.filter(function(asset) {
|
|
1733
|
-
return !sharedAssets.has(asset);
|
|
1734
|
-
}),
|
|
1735
|
-
async: css.async.filter(function(asset) {
|
|
1736
|
-
return !sharedAssets.has(asset);
|
|
1737
|
-
})
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
});
|
|
1741
|
-
});
|
|
1742
|
-
resolve();
|
|
1743
|
-
})
|
|
1744
|
-
];
|
|
1745
|
-
case 3:
|
|
1746
|
-
_state.sent();
|
|
1747
|
-
return [
|
|
1748
|
-
2,
|
|
1749
|
-
stats
|
|
1750
|
-
];
|
|
1751
|
-
case 4:
|
|
1752
|
-
err = _state.sent();
|
|
1753
|
-
throw err;
|
|
1754
|
-
case 5:
|
|
1755
|
-
return [
|
|
1756
|
-
2
|
|
1757
|
-
];
|
|
1758
|
-
}
|
|
1759
|
-
});
|
|
1760
|
-
})();
|
|
1761
|
-
}
|
|
1762
|
-
},
|
|
1763
|
-
{
|
|
1764
|
-
key: "getPublicPath",
|
|
1765
|
-
value: function getPublicPath(compiler) {
|
|
1766
|
-
if (this._publicPath) {
|
|
1767
|
-
return this._publicPath;
|
|
1768
|
-
}
|
|
1769
|
-
var _compiler_options = compiler.options, _compiler_options_output = _compiler_options.output, originalPublicPath = _compiler_options_output.publicPath;
|
|
1770
|
-
var publicPath = originalPublicPath;
|
|
1771
|
-
this._publicPath = publicPath;
|
|
1772
|
-
return publicPath;
|
|
1773
|
-
}
|
|
1774
|
-
},
|
|
1775
|
-
{
|
|
1776
|
-
key: "init",
|
|
1777
|
-
value: function init(options, param) {
|
|
1778
|
-
var pluginVersion = param.pluginVersion, bundler = param.bundler;
|
|
1779
|
-
this._options = options;
|
|
1780
|
-
this._pluginVersion = pluginVersion;
|
|
1781
|
-
this._bundler = bundler;
|
|
1782
|
-
this._containerManager = new managers.ContainerManager();
|
|
1783
|
-
this._containerManager.init(options);
|
|
1784
|
-
this._remoteManager = new managers.RemoteManager();
|
|
1785
|
-
this._remoteManager.init(options);
|
|
1786
|
-
this._sharedManager = new managers.SharedManager();
|
|
1787
|
-
this._sharedManager.init(options);
|
|
1788
|
-
}
|
|
1789
|
-
},
|
|
1790
|
-
{
|
|
1791
|
-
key: "generateStats",
|
|
1792
|
-
value: function generateStats(compiler, compilation) {
|
|
1793
|
-
var extraOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1794
|
-
var _this = this;
|
|
1795
|
-
return _async_to_generator$1(function() {
|
|
1796
|
-
var disableEmit, existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
|
|
1797
|
-
return _ts_generator$1(this, function(_state) {
|
|
1798
|
-
switch(_state.label){
|
|
1799
|
-
case 0:
|
|
1800
|
-
_state.trys.push([
|
|
1801
|
-
0,
|
|
1802
|
-
4,
|
|
1803
|
-
,
|
|
1804
|
-
5
|
|
1805
|
-
]);
|
|
1806
|
-
disableEmit = extraOptions.disableEmit;
|
|
1807
|
-
existedStats = compilation.getAsset(_this.fileName);
|
|
1808
|
-
if (existedStats && !isDev()) {
|
|
1809
|
-
return [
|
|
1810
|
-
2,
|
|
1811
|
-
{
|
|
1812
|
-
stats: JSON.parse(existedStats.source.source().toString()),
|
|
1813
|
-
filename: _this.fileName
|
|
1814
|
-
}
|
|
1815
|
-
];
|
|
1816
|
-
}
|
|
1817
|
-
_this__options = _this._options, tmp = _this__options.manifest, manifestOptions = tmp === void 0 ? {} : tmp;
|
|
1818
|
-
return [
|
|
1819
|
-
4,
|
|
1820
|
-
_this._generateStats(compiler, compilation)
|
|
1821
|
-
];
|
|
1822
|
-
case 1:
|
|
1823
|
-
stats = _state.sent();
|
|
1824
|
-
if (!((typeof manifestOptions === "undefined" ? "undefined" : _type_of$1(manifestOptions)) === 'object' && manifestOptions.additionalData)) return [
|
|
1825
|
-
3,
|
|
1826
|
-
3
|
|
1827
|
-
];
|
|
1828
|
-
return [
|
|
1829
|
-
4,
|
|
1830
|
-
manifestOptions.additionalData({
|
|
1831
|
-
stats: stats,
|
|
1832
|
-
pluginOptions: _this._options,
|
|
1833
|
-
compiler: compiler,
|
|
1834
|
-
compilation: compilation,
|
|
1835
|
-
bundler: _this._bundler
|
|
1836
|
-
})
|
|
1837
|
-
];
|
|
1838
|
-
case 2:
|
|
1839
|
-
ret = _state.sent();
|
|
1840
|
-
stats = ret || stats;
|
|
1841
|
-
_state.label = 3;
|
|
1842
|
-
case 3:
|
|
1843
|
-
if (!disableEmit) {
|
|
1844
|
-
compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
|
|
1845
|
-
}
|
|
1846
|
-
return [
|
|
1847
|
-
2,
|
|
1848
|
-
{
|
|
1849
|
-
stats: stats,
|
|
1850
|
-
filename: _this.fileName
|
|
1851
|
-
}
|
|
1852
|
-
];
|
|
1853
|
-
case 4:
|
|
1854
|
-
err = _state.sent();
|
|
1855
|
-
throw err;
|
|
1856
|
-
case 5:
|
|
1857
|
-
return [
|
|
1858
|
-
2
|
|
1859
|
-
];
|
|
1860
|
-
}
|
|
1861
|
-
});
|
|
1862
|
-
})();
|
|
1863
|
-
}
|
|
1864
|
-
},
|
|
1865
|
-
{
|
|
1866
|
-
key: "validate",
|
|
1867
|
-
value: function validate(compiler) {
|
|
1868
|
-
var _compiler_options = compiler.options, publicPath = _compiler_options.output.publicPath;
|
|
1869
|
-
if (typeof publicPath !== 'string') {
|
|
1870
|
-
logger.warn("Manifest will not generate, because publicPath can only be string, but got '".concat(publicPath, "'"));
|
|
1871
|
-
return false;
|
|
1872
|
-
} else if (publicPath === 'auto') {
|
|
1873
|
-
logger.warn("Manifest will use absolute path resolution via its host at runtime, reason: publicPath='".concat(publicPath, "'"));
|
|
1874
|
-
return true;
|
|
1875
|
-
}
|
|
1876
|
-
return true;
|
|
1877
|
-
}
|
|
1054
|
+
resolve();
|
|
1055
|
+
});
|
|
1056
|
+
return stats;
|
|
1057
|
+
}
|
|
1058
|
+
catch (err) {
|
|
1059
|
+
throw err;
|
|
1878
1060
|
}
|
|
1879
|
-
]);
|
|
1880
|
-
return StatsManager;
|
|
1881
|
-
}();
|
|
1882
|
-
|
|
1883
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1884
|
-
try {
|
|
1885
|
-
var info = gen[key](arg);
|
|
1886
|
-
var value = info.value;
|
|
1887
|
-
} catch (error) {
|
|
1888
|
-
reject(error);
|
|
1889
|
-
return;
|
|
1890
1061
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1062
|
+
getPublicPath(compiler) {
|
|
1063
|
+
if (this._publicPath) {
|
|
1064
|
+
return this._publicPath;
|
|
1065
|
+
}
|
|
1066
|
+
const { output: { publicPath: originalPublicPath }, } = compiler.options;
|
|
1067
|
+
let publicPath = originalPublicPath;
|
|
1068
|
+
this._publicPath = publicPath;
|
|
1069
|
+
return publicPath;
|
|
1895
1070
|
}
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1071
|
+
init(options, { pluginVersion, bundler, }) {
|
|
1072
|
+
this._options = options;
|
|
1073
|
+
this._pluginVersion = pluginVersion;
|
|
1074
|
+
this._bundler = bundler;
|
|
1075
|
+
this._containerManager = new managers.ContainerManager();
|
|
1076
|
+
this._containerManager.init(options);
|
|
1077
|
+
this._remoteManager = new managers.RemoteManager();
|
|
1078
|
+
this._remoteManager.init(options);
|
|
1079
|
+
this._sharedManager = new managers.SharedManager();
|
|
1080
|
+
this._sharedManager.init(options);
|
|
1081
|
+
}
|
|
1082
|
+
async generateStats(compiler, compilation) {
|
|
1083
|
+
try {
|
|
1084
|
+
const existedStats = compilation.getAsset(this.fileName);
|
|
1085
|
+
if (existedStats) {
|
|
1086
|
+
return {
|
|
1087
|
+
stats: JSON.parse(existedStats.source.source().toString()),
|
|
1088
|
+
filename: this.fileName,
|
|
1089
|
+
};
|
|
1904
1090
|
}
|
|
1905
|
-
|
|
1906
|
-
|
|
1091
|
+
const { manifest: manifestOptions = {} } = this._options;
|
|
1092
|
+
let stats = await this._generateStats(compiler, compilation);
|
|
1093
|
+
if (typeof manifestOptions === 'object' &&
|
|
1094
|
+
manifestOptions.additionalData) {
|
|
1095
|
+
const ret = await manifestOptions.additionalData({
|
|
1096
|
+
stats,
|
|
1097
|
+
pluginOptions: this._options,
|
|
1098
|
+
compiler,
|
|
1099
|
+
compilation,
|
|
1100
|
+
bundler: this._bundler,
|
|
1101
|
+
});
|
|
1102
|
+
stats = ret || stats;
|
|
1907
1103
|
}
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
}
|
|
1917
|
-
function _defineProperties(target, props) {
|
|
1918
|
-
for(var i = 0; i < props.length; i++){
|
|
1919
|
-
var descriptor = props[i];
|
|
1920
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1921
|
-
descriptor.configurable = true;
|
|
1922
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
1923
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
1927
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
1928
|
-
return Constructor;
|
|
1929
|
-
}
|
|
1930
|
-
function _instanceof(left, right) {
|
|
1931
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
1932
|
-
return !!right[Symbol.hasInstance](left);
|
|
1933
|
-
} else {
|
|
1934
|
-
return left instanceof right;
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
function _type_of(obj) {
|
|
1938
|
-
"@swc/helpers - typeof";
|
|
1939
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1940
|
-
}
|
|
1941
|
-
function _ts_generator(thisArg, body) {
|
|
1942
|
-
var f, y, t, g, _ = {
|
|
1943
|
-
label: 0,
|
|
1944
|
-
sent: function() {
|
|
1945
|
-
if (t[0] & 1) throw t[1];
|
|
1946
|
-
return t[1];
|
|
1947
|
-
},
|
|
1948
|
-
trys: [],
|
|
1949
|
-
ops: []
|
|
1950
|
-
};
|
|
1951
|
-
return g = {
|
|
1952
|
-
next: verb(0),
|
|
1953
|
-
"throw": verb(1),
|
|
1954
|
-
"return": verb(2)
|
|
1955
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
1956
|
-
return this;
|
|
1957
|
-
}), g;
|
|
1958
|
-
function verb(n) {
|
|
1959
|
-
return function(v) {
|
|
1960
|
-
return step([
|
|
1961
|
-
n,
|
|
1962
|
-
v
|
|
1963
|
-
]);
|
|
1964
|
-
};
|
|
1104
|
+
compilation.emitAsset(this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
|
|
1105
|
+
return {
|
|
1106
|
+
stats,
|
|
1107
|
+
filename: this.fileName,
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
catch (err) {
|
|
1111
|
+
throw err;
|
|
1112
|
+
}
|
|
1965
1113
|
}
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
op[0] & 2,
|
|
1972
|
-
t.value
|
|
1973
|
-
];
|
|
1974
|
-
switch(op[0]){
|
|
1975
|
-
case 0:
|
|
1976
|
-
case 1:
|
|
1977
|
-
t = op;
|
|
1978
|
-
break;
|
|
1979
|
-
case 4:
|
|
1980
|
-
_.label++;
|
|
1981
|
-
return {
|
|
1982
|
-
value: op[1],
|
|
1983
|
-
done: false
|
|
1984
|
-
};
|
|
1985
|
-
case 5:
|
|
1986
|
-
_.label++;
|
|
1987
|
-
y = op[1];
|
|
1988
|
-
op = [
|
|
1989
|
-
0
|
|
1990
|
-
];
|
|
1991
|
-
continue;
|
|
1992
|
-
case 7:
|
|
1993
|
-
op = _.ops.pop();
|
|
1994
|
-
_.trys.pop();
|
|
1995
|
-
continue;
|
|
1996
|
-
default:
|
|
1997
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1998
|
-
_ = 0;
|
|
1999
|
-
continue;
|
|
2000
|
-
}
|
|
2001
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
2002
|
-
_.label = op[1];
|
|
2003
|
-
break;
|
|
2004
|
-
}
|
|
2005
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
2006
|
-
_.label = t[1];
|
|
2007
|
-
t = op;
|
|
2008
|
-
break;
|
|
2009
|
-
}
|
|
2010
|
-
if (t && _.label < t[2]) {
|
|
2011
|
-
_.label = t[2];
|
|
2012
|
-
_.ops.push(op);
|
|
2013
|
-
break;
|
|
2014
|
-
}
|
|
2015
|
-
if (t[2]) _.ops.pop();
|
|
2016
|
-
_.trys.pop();
|
|
2017
|
-
continue;
|
|
2018
|
-
}
|
|
2019
|
-
op = body.call(thisArg, _);
|
|
2020
|
-
} catch (e) {
|
|
2021
|
-
op = [
|
|
2022
|
-
6,
|
|
2023
|
-
e
|
|
2024
|
-
];
|
|
2025
|
-
y = 0;
|
|
2026
|
-
} finally{
|
|
2027
|
-
f = t = 0;
|
|
1114
|
+
validate(compiler) {
|
|
1115
|
+
const { output: { publicPath }, } = compiler.options;
|
|
1116
|
+
if (typeof publicPath !== 'string') {
|
|
1117
|
+
logger.warn(`Manifest will not generate, because publicPath can only be string, but got '${publicPath}'`);
|
|
1118
|
+
return false;
|
|
2028
1119
|
}
|
|
2029
|
-
if (
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
1120
|
+
else if (publicPath === 'auto') {
|
|
1121
|
+
logger.warn(`Manifest will use absolute path resolution via its host at runtime, reason: publicPath='${publicPath}'`);
|
|
1122
|
+
return true;
|
|
1123
|
+
}
|
|
1124
|
+
return true;
|
|
2034
1125
|
}
|
|
2035
1126
|
}
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
_class_call_check(this, StatsPlugin);
|
|
1127
|
+
|
|
1128
|
+
class StatsPlugin {
|
|
1129
|
+
constructor(options, { pluginVersion, bundler, }) {
|
|
2040
1130
|
this.name = 'StatsPlugin';
|
|
2041
1131
|
this._options = {};
|
|
2042
1132
|
this._statsManager = new StatsManager();
|
|
@@ -2046,93 +1136,55 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2046
1136
|
try {
|
|
2047
1137
|
this._options = options;
|
|
2048
1138
|
this._bundler = bundler;
|
|
2049
|
-
this.
|
|
2050
|
-
this._statsManager.init(this._options, {
|
|
2051
|
-
pluginVersion: pluginVersion,
|
|
2052
|
-
bundler: bundler
|
|
2053
|
-
});
|
|
1139
|
+
this._statsManager.init(this._options, { pluginVersion, bundler });
|
|
2054
1140
|
this._manifestManager.init(this._options);
|
|
2055
|
-
}
|
|
2056
|
-
|
|
2057
|
-
|
|
1141
|
+
}
|
|
1142
|
+
catch (err) {
|
|
1143
|
+
if (err instanceof Error) {
|
|
1144
|
+
err.message = `[ ${PLUGIN_IDENTIFIER} ]: Manifest will not generate, because: ${err.message}`;
|
|
2058
1145
|
}
|
|
2059
1146
|
logger.error(err);
|
|
2060
1147
|
this._enable = false;
|
|
2061
1148
|
}
|
|
2062
1149
|
}
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
var res = this._statsManager.validate(compiler);
|
|
2072
|
-
if (!res) {
|
|
2073
|
-
return;
|
|
2074
|
-
}
|
|
2075
|
-
compiler.hooks.thisCompilation.tap('generateStats', function(compilation) {
|
|
2076
|
-
var _this1 = _this;
|
|
2077
|
-
compilation.hooks.processAssets.tapPromise({
|
|
2078
|
-
name: 'generateStats',
|
|
2079
|
-
// @ts-ignore use runtime variable in case peer dep not installed
|
|
2080
|
-
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
2081
|
-
}, /*#__PURE__*/ _async_to_generator(function() {
|
|
2082
|
-
return _ts_generator(this, function(_state) {
|
|
2083
|
-
switch(_state.label){
|
|
2084
|
-
case 0:
|
|
2085
|
-
if (!(_this1._options.manifest !== false)) return [
|
|
2086
|
-
3,
|
|
2087
|
-
3
|
|
2088
|
-
];
|
|
2089
|
-
return [
|
|
2090
|
-
4,
|
|
2091
|
-
_this1._statsManager.generateStats(compiler, compilation, {
|
|
2092
|
-
disableEmit: _this1.disableEmit
|
|
2093
|
-
})
|
|
2094
|
-
];
|
|
2095
|
-
case 1:
|
|
2096
|
-
_this1.statsInfo = _state.sent();
|
|
2097
|
-
return [
|
|
2098
|
-
4,
|
|
2099
|
-
_this1._manifestManager.generateManifest({
|
|
2100
|
-
compilation: compilation,
|
|
2101
|
-
stats: _this1.statsInfo.stats,
|
|
2102
|
-
publicPath: _this1._statsManager.getPublicPath(compiler),
|
|
2103
|
-
compiler: compiler,
|
|
2104
|
-
bundler: _this1._bundler,
|
|
2105
|
-
additionalData: _type_of(_this1._options.manifest) === 'object' ? _this1._options.manifest.additionalData : undefined
|
|
2106
|
-
}, {
|
|
2107
|
-
disableEmit: _this1.disableEmit
|
|
2108
|
-
})
|
|
2109
|
-
];
|
|
2110
|
-
case 2:
|
|
2111
|
-
_this1.manifestInfo = _state.sent();
|
|
2112
|
-
_state.label = 3;
|
|
2113
|
-
case 3:
|
|
2114
|
-
return [
|
|
2115
|
-
2
|
|
2116
|
-
];
|
|
2117
|
-
}
|
|
2118
|
-
});
|
|
2119
|
-
}));
|
|
2120
|
-
});
|
|
2121
|
-
}
|
|
2122
|
-
},
|
|
2123
|
-
{
|
|
2124
|
-
key: "resourceInfo",
|
|
2125
|
-
get: function get() {
|
|
2126
|
-
return {
|
|
2127
|
-
stats: this.statsInfo,
|
|
2128
|
-
manifest: this.manifestInfo
|
|
2129
|
-
};
|
|
2130
|
-
}
|
|
1150
|
+
apply(compiler) {
|
|
1151
|
+
sdk.bindLoggerToCompiler(logger, compiler, PLUGIN_IDENTIFIER);
|
|
1152
|
+
if (!this._enable) {
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
const res = this._statsManager.validate(compiler);
|
|
1156
|
+
if (!res) {
|
|
1157
|
+
return;
|
|
2131
1158
|
}
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
1159
|
+
compiler.hooks.thisCompilation.tap('generateStats', (compilation) => {
|
|
1160
|
+
compilation.hooks.processAssets.tapPromise({
|
|
1161
|
+
name: 'generateStats',
|
|
1162
|
+
// @ts-ignore use runtime variable in case peer dep not installed
|
|
1163
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,
|
|
1164
|
+
}, async () => {
|
|
1165
|
+
if (this._options.manifest !== false) {
|
|
1166
|
+
this.statsInfo = await this._statsManager.generateStats(compiler, compilation);
|
|
1167
|
+
this.manifestInfo = await this._manifestManager.generateManifest({
|
|
1168
|
+
compilation,
|
|
1169
|
+
stats: this.statsInfo.stats,
|
|
1170
|
+
publicPath: this._statsManager.getPublicPath(compiler),
|
|
1171
|
+
compiler,
|
|
1172
|
+
bundler: this._bundler,
|
|
1173
|
+
additionalData: typeof this._options.manifest === 'object'
|
|
1174
|
+
? this._options.manifest.additionalData
|
|
1175
|
+
: undefined,
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
});
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
get resourceInfo() {
|
|
1182
|
+
return {
|
|
1183
|
+
stats: this.statsInfo,
|
|
1184
|
+
manifest: this.manifestInfo,
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
2136
1188
|
|
|
2137
1189
|
exports.ManifestManager = ManifestManager;
|
|
2138
1190
|
exports.StatsManager = StatsManager;
|