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