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