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