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

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