@module-federation/manifest 0.0.0-next-20250926024003 → 0.0.0-perf-devtools-20260107043700

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