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