@module-federation/manifest 0.0.0-next-20240617071542 → 0.0.0-next-20240617084909

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
@@ -2,18 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var path = require('path');
6
- var fs = require('fs');
7
5
  var chalk = require('chalk');
6
+ var path = require('path');
8
7
  var sdk = require('@module-federation/sdk');
9
8
  var core = require('@module-federation/dts-plugin/core');
10
9
  var managers = require('@module-federation/managers');
11
10
 
12
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
12
 
14
- var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
15
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
16
13
  var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
14
+ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
17
15
 
18
16
  var PLUGIN_IDENTIFIER = 'Module Federation Manifest Plugin';
19
17
  var HOT_UPDATE_SUFFIX = '.hot-update';
@@ -149,6 +147,24 @@ function _templateObject$2() {
149
147
  };
150
148
  return data;
151
149
  }
150
+ function isHotFile(file) {
151
+ return file.includes(HOT_UPDATE_SUFFIX);
152
+ }
153
+ var collectAssets = function(assets, jsTargetSet, cssTargetSet) {
154
+ assets.forEach(function(file) {
155
+ if (file.endsWith('.css')) {
156
+ cssTargetSet.add(file);
157
+ } else {
158
+ if (isDev()) {
159
+ if (!isHotFile(file)) {
160
+ jsTargetSet.add(file);
161
+ }
162
+ } else {
163
+ jsTargetSet.add(file);
164
+ }
165
+ }
166
+ });
167
+ };
152
168
  function getSharedModuleName(name) {
153
169
  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];
154
170
  return sharedInfo.split('@').slice(0, -1).join('@');
@@ -169,19 +185,7 @@ function getAssetsByChunkIDs(compilation, chunkIDMap) {
169
185
  return item.id === chunkID;
170
186
  });
171
187
  if (chunk) {
172
- _to_consumable_array(chunk.files).forEach(function(asset) {
173
- if (asset.endsWith('.css')) {
174
- assetMap[key].css.add(asset);
175
- } else {
176
- if (process.env['NODE_ENV'] === 'development') {
177
- if (!asset.includes(HOT_UPDATE_SUFFIX)) {
178
- assetMap[key].js.add(asset);
179
- }
180
- } else {
181
- assetMap[key].js.add(asset);
182
- }
183
- }
184
- });
188
+ collectAssets(_to_consumable_array(chunk.files), assetMap[key].js, assetMap[key].css);
185
189
  }
186
190
  });
187
191
  });
@@ -328,24 +332,12 @@ function getAssetsByChunk(chunk) {
328
332
  };
329
333
  var collectChunkFiles = function(targetChunk, type) {
330
334
  _to_consumable_array(targetChunk.groupsIterable).forEach(function(chunkGroup) {
331
- chunkGroup.getFiles().forEach(function(file) {
332
- if (file.endsWith('.css')) {
333
- assesSet.css[type].add(file);
334
- } else {
335
- assesSet.js[type].add(file);
336
- }
337
- });
335
+ collectAssets(chunkGroup.getFiles(), assesSet.js[type], assesSet.css[type]);
338
336
  });
339
337
  };
340
338
  collectChunkFiles(chunk, 'sync');
341
339
  _to_consumable_array(chunk.getAllAsyncChunks()).forEach(function(asyncChunk) {
342
- asyncChunk.files.forEach(function(file) {
343
- if (file.endsWith('.css')) {
344
- assesSet.css.async.add(file);
345
- } else {
346
- assesSet.js.async.add(file);
347
- }
348
- });
340
+ collectAssets(_to_consumable_array(asyncChunk.files), assesSet.js['async'], assesSet.css['async']);
349
341
  collectChunkFiles(asyncChunk, 'async');
350
342
  });
351
343
  var assets = {
@@ -662,7 +654,7 @@ var ManifestManager = /*#__PURE__*/ function() {
662
654
  value: function generateManifest(options) {
663
655
  var _this = this;
664
656
  return _async_to_generator$2(function() {
665
- var compilation, publicPath, stats, compiler, bundler, additionalData, manifest, prefetchInterface, prefetchFilePath, existPrefetch, content, manifestFileName, ret;
657
+ var compilation, publicPath, stats, compiler, bundler, additionalData, manifest, manifestFileName, ret;
666
658
  return _ts_generator$2(this, function(_state) {
667
659
  switch(_state.label){
668
660
  case 0:
@@ -711,16 +703,6 @@ var ManifestManager = /*#__PURE__*/ function() {
711
703
  sum.push(remote);
712
704
  return sum;
713
705
  }, []);
714
- prefetchInterface = false;
715
- prefetchFilePath = path__default["default"].resolve(compiler.options.context || process.cwd(), "node_modules/.mf/".concat(sdk.encodeName(stats.name), "/").concat(sdk.MFPrefetchCommon.fileName));
716
- existPrefetch = fs__default["default"].existsSync(prefetchFilePath);
717
- if (existPrefetch) {
718
- content = fs__default["default"].readFileSync(prefetchFilePath).toString();
719
- if (content) {
720
- prefetchInterface = true;
721
- }
722
- }
723
- stats.metaData.prefetchInterface = prefetchInterface;
724
706
  _this._manifest = manifest;
725
707
  manifestFileName = _this.fileName;
726
708
  if (!additionalData) return [
@@ -910,11 +892,13 @@ var ModuleHandler = /*#__PURE__*/ function() {
910
892
  }
911
893
  var sharedManagerNormalizedOptions = this._sharedManager.normalizedOptions;
912
894
  var initShared = function(pkgName, pkgVersion) {
895
+ var _sharedManagerNormalizedOptions_pkgName;
913
896
  if (sharedMap[pkgName]) {
914
897
  return;
915
898
  }
916
899
  sharedMap[pkgName] = _object_spread_props$1(_object_spread$1({}, sharedManagerNormalizedOptions[pkgName]), {
917
900
  id: "".concat(_this._options.name, ":").concat(pkgName),
901
+ requiredVersion: ((_sharedManagerNormalizedOptions_pkgName = sharedManagerNormalizedOptions[pkgName]) === null || _sharedManagerNormalizedOptions_pkgName === void 0 ? void 0 : _sharedManagerNormalizedOptions_pkgName.requiredVersion) || "^".concat(pkgVersion),
918
902
  name: pkgName,
919
903
  version: pkgVersion,
920
904
  assets: {
@@ -1311,6 +1295,10 @@ function _tagged_template_literal(strings, raw) {
1311
1295
  }
1312
1296
  }));
1313
1297
  }
1298
+ function _type_of$1(obj) {
1299
+ "@swc/helpers - typeof";
1300
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1301
+ }
1314
1302
  function _unsupported_iterable_to_array(o, minLen) {
1315
1303
  if (!o) return;
1316
1304
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -1469,6 +1457,7 @@ var StatsManager = /*#__PURE__*/ function() {
1469
1457
  key: "_getMetaData",
1470
1458
  value: function _getMetaData(compiler, compilation, extraOptions) {
1471
1459
  var _this = this;
1460
+ var _this__options_library, _this__options;
1472
1461
  var context = compiler.options.context;
1473
1462
  var _this1 = this, name = _this1._options.name, buildInfo = _this1.buildInfo;
1474
1463
  var type = this._pkgJsonManager.getExposeGarfishModuleType(context || process.cwd());
@@ -1499,7 +1488,7 @@ var StatsManager = /*#__PURE__*/ function() {
1499
1488
  name: getRemoteEntryName(),
1500
1489
  path: '',
1501
1490
  // same as the types supported by runtime, currently only global/var/script is supported
1502
- type: 'global'
1491
+ 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'
1503
1492
  },
1504
1493
  types: getTypesMetaInfo(this._options, compiler.context),
1505
1494
  globalName: globalName,
@@ -1633,7 +1622,7 @@ var StatsManager = /*#__PURE__*/ function() {
1633
1622
  remotes: [],
1634
1623
  exposes: []
1635
1624
  };
1636
- if (typeof manifestOptions === 'object' && manifestOptions.disableAssetsAnalyze) {
1625
+ if ((typeof manifestOptions === "undefined" ? "undefined" : _type_of$1(manifestOptions)) === 'object' && manifestOptions.disableAssetsAnalyze) {
1637
1626
  remotes = _this._remoteManager.statsRemoteWithEmptyUsedIn;
1638
1627
  stats.remotes = remotes;
1639
1628
  return [
@@ -1793,7 +1782,7 @@ var StatsManager = /*#__PURE__*/ function() {
1793
1782
  ];
1794
1783
  case 1:
1795
1784
  stats = _state.sent();
1796
- if (!(typeof manifestOptions === 'object' && manifestOptions.additionalData)) return [
1785
+ if (!((typeof manifestOptions === "undefined" ? "undefined" : _type_of$1(manifestOptions)) === 'object' && manifestOptions.additionalData)) return [
1797
1786
  3,
1798
1787
  3
1799
1788
  ];
@@ -1915,6 +1904,10 @@ function _instanceof(left, right) {
1915
1904
  return left instanceof right;
1916
1905
  }
1917
1906
  }
1907
+ function _type_of(obj) {
1908
+ "@swc/helpers - typeof";
1909
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1910
+ }
1918
1911
  function _ts_generator(thisArg, body) {
1919
1912
  var f, y, t, g, _ = {
1920
1913
  label: 0,
@@ -2075,7 +2068,7 @@ var StatsPlugin = /*#__PURE__*/ function() {
2075
2068
  publicPath: _this1._statsManager.getPublicPath(compiler),
2076
2069
  compiler: compiler,
2077
2070
  bundler: _this1._bundler,
2078
- additionalData: typeof _this1._options.manifest === 'object' ? _this1._options.manifest.additionalData : undefined
2071
+ additionalData: _type_of(_this1._options.manifest) === 'object' ? _this1._options.manifest.additionalData : undefined
2079
2072
  });
2080
2073
  _state.label = 2;
2081
2074
  case 2:
package/dist/index.esm.js CHANGED
@@ -1,7 +1,6 @@
1
- import path from 'path';
2
- import fs from 'fs';
3
1
  import chalk from 'chalk';
4
- import { StatsFileName, ManifestFileName, simpleJoinRemoteEntry, normalizeOptions, encodeName, MFPrefetchCommon } from '@module-federation/sdk';
2
+ import path from 'path';
3
+ import { StatsFileName, ManifestFileName, simpleJoinRemoteEntry, normalizeOptions } from '@module-federation/sdk';
5
4
  import { isTSProject, retrieveTypesAssetsInfo } from '@module-federation/dts-plugin/core';
6
5
  import { RemoteManager, SharedManager, ContainerManager, PKGJsonManager, utils } from '@module-federation/managers';
7
6
 
@@ -139,6 +138,24 @@ function _templateObject$2() {
139
138
  };
140
139
  return data;
141
140
  }
141
+ function isHotFile(file) {
142
+ return file.includes(HOT_UPDATE_SUFFIX);
143
+ }
144
+ var collectAssets = function(assets, jsTargetSet, cssTargetSet) {
145
+ assets.forEach(function(file) {
146
+ if (file.endsWith('.css')) {
147
+ cssTargetSet.add(file);
148
+ } else {
149
+ if (isDev()) {
150
+ if (!isHotFile(file)) {
151
+ jsTargetSet.add(file);
152
+ }
153
+ } else {
154
+ jsTargetSet.add(file);
155
+ }
156
+ }
157
+ });
158
+ };
142
159
  function getSharedModuleName(name) {
143
160
  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];
144
161
  return sharedInfo.split('@').slice(0, -1).join('@');
@@ -159,19 +176,7 @@ function getAssetsByChunkIDs(compilation, chunkIDMap) {
159
176
  return item.id === chunkID;
160
177
  });
161
178
  if (chunk) {
162
- _to_consumable_array(chunk.files).forEach(function(asset) {
163
- if (asset.endsWith('.css')) {
164
- assetMap[key].css.add(asset);
165
- } else {
166
- if (process.env['NODE_ENV'] === 'development') {
167
- if (!asset.includes(HOT_UPDATE_SUFFIX)) {
168
- assetMap[key].js.add(asset);
169
- }
170
- } else {
171
- assetMap[key].js.add(asset);
172
- }
173
- }
174
- });
179
+ collectAssets(_to_consumable_array(chunk.files), assetMap[key].js, assetMap[key].css);
175
180
  }
176
181
  });
177
182
  });
@@ -318,24 +323,12 @@ function getAssetsByChunk(chunk) {
318
323
  };
319
324
  var collectChunkFiles = function(targetChunk, type) {
320
325
  _to_consumable_array(targetChunk.groupsIterable).forEach(function(chunkGroup) {
321
- chunkGroup.getFiles().forEach(function(file) {
322
- if (file.endsWith('.css')) {
323
- assesSet.css[type].add(file);
324
- } else {
325
- assesSet.js[type].add(file);
326
- }
327
- });
326
+ collectAssets(chunkGroup.getFiles(), assesSet.js[type], assesSet.css[type]);
328
327
  });
329
328
  };
330
329
  collectChunkFiles(chunk, 'sync');
331
330
  _to_consumable_array(chunk.getAllAsyncChunks()).forEach(function(asyncChunk) {
332
- asyncChunk.files.forEach(function(file) {
333
- if (file.endsWith('.css')) {
334
- assesSet.css.async.add(file);
335
- } else {
336
- assesSet.js.async.add(file);
337
- }
338
- });
331
+ collectAssets(_to_consumable_array(asyncChunk.files), assesSet.js['async'], assesSet.css['async']);
339
332
  collectChunkFiles(asyncChunk, 'async');
340
333
  });
341
334
  var assets = {
@@ -652,7 +645,7 @@ var ManifestManager = /*#__PURE__*/ function() {
652
645
  value: function generateManifest(options) {
653
646
  var _this = this;
654
647
  return _async_to_generator$2(function() {
655
- var compilation, publicPath, stats, compiler, bundler, additionalData, manifest, prefetchInterface, prefetchFilePath, existPrefetch, content, manifestFileName, ret;
648
+ var compilation, publicPath, stats, compiler, bundler, additionalData, manifest, manifestFileName, ret;
656
649
  return _ts_generator$2(this, function(_state) {
657
650
  switch(_state.label){
658
651
  case 0:
@@ -701,16 +694,6 @@ var ManifestManager = /*#__PURE__*/ function() {
701
694
  sum.push(remote);
702
695
  return sum;
703
696
  }, []);
704
- prefetchInterface = false;
705
- prefetchFilePath = path.resolve(compiler.options.context || process.cwd(), "node_modules/.mf/".concat(encodeName(stats.name), "/").concat(MFPrefetchCommon.fileName));
706
- existPrefetch = fs.existsSync(prefetchFilePath);
707
- if (existPrefetch) {
708
- content = fs.readFileSync(prefetchFilePath).toString();
709
- if (content) {
710
- prefetchInterface = true;
711
- }
712
- }
713
- stats.metaData.prefetchInterface = prefetchInterface;
714
697
  _this._manifest = manifest;
715
698
  manifestFileName = _this.fileName;
716
699
  if (!additionalData) return [
@@ -900,11 +883,13 @@ var ModuleHandler = /*#__PURE__*/ function() {
900
883
  }
901
884
  var sharedManagerNormalizedOptions = this._sharedManager.normalizedOptions;
902
885
  var initShared = function(pkgName, pkgVersion) {
886
+ var _sharedManagerNormalizedOptions_pkgName;
903
887
  if (sharedMap[pkgName]) {
904
888
  return;
905
889
  }
906
890
  sharedMap[pkgName] = _object_spread_props$1(_object_spread$1({}, sharedManagerNormalizedOptions[pkgName]), {
907
891
  id: "".concat(_this._options.name, ":").concat(pkgName),
892
+ requiredVersion: ((_sharedManagerNormalizedOptions_pkgName = sharedManagerNormalizedOptions[pkgName]) === null || _sharedManagerNormalizedOptions_pkgName === void 0 ? void 0 : _sharedManagerNormalizedOptions_pkgName.requiredVersion) || "^".concat(pkgVersion),
908
893
  name: pkgName,
909
894
  version: pkgVersion,
910
895
  assets: {
@@ -1301,6 +1286,10 @@ function _tagged_template_literal(strings, raw) {
1301
1286
  }
1302
1287
  }));
1303
1288
  }
1289
+ function _type_of$1(obj) {
1290
+ "@swc/helpers - typeof";
1291
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1292
+ }
1304
1293
  function _unsupported_iterable_to_array(o, minLen) {
1305
1294
  if (!o) return;
1306
1295
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -1459,6 +1448,7 @@ var StatsManager = /*#__PURE__*/ function() {
1459
1448
  key: "_getMetaData",
1460
1449
  value: function _getMetaData(compiler, compilation, extraOptions) {
1461
1450
  var _this = this;
1451
+ var _this__options_library, _this__options;
1462
1452
  var context = compiler.options.context;
1463
1453
  var _this1 = this, name = _this1._options.name, buildInfo = _this1.buildInfo;
1464
1454
  var type = this._pkgJsonManager.getExposeGarfishModuleType(context || process.cwd());
@@ -1489,7 +1479,7 @@ var StatsManager = /*#__PURE__*/ function() {
1489
1479
  name: getRemoteEntryName(),
1490
1480
  path: '',
1491
1481
  // same as the types supported by runtime, currently only global/var/script is supported
1492
- type: 'global'
1482
+ 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'
1493
1483
  },
1494
1484
  types: getTypesMetaInfo(this._options, compiler.context),
1495
1485
  globalName: globalName,
@@ -1623,7 +1613,7 @@ var StatsManager = /*#__PURE__*/ function() {
1623
1613
  remotes: [],
1624
1614
  exposes: []
1625
1615
  };
1626
- if (typeof manifestOptions === 'object' && manifestOptions.disableAssetsAnalyze) {
1616
+ if ((typeof manifestOptions === "undefined" ? "undefined" : _type_of$1(manifestOptions)) === 'object' && manifestOptions.disableAssetsAnalyze) {
1627
1617
  remotes = _this._remoteManager.statsRemoteWithEmptyUsedIn;
1628
1618
  stats.remotes = remotes;
1629
1619
  return [
@@ -1783,7 +1773,7 @@ var StatsManager = /*#__PURE__*/ function() {
1783
1773
  ];
1784
1774
  case 1:
1785
1775
  stats = _state.sent();
1786
- if (!(typeof manifestOptions === 'object' && manifestOptions.additionalData)) return [
1776
+ if (!((typeof manifestOptions === "undefined" ? "undefined" : _type_of$1(manifestOptions)) === 'object' && manifestOptions.additionalData)) return [
1787
1777
  3,
1788
1778
  3
1789
1779
  ];
@@ -1905,6 +1895,10 @@ function _instanceof(left, right) {
1905
1895
  return left instanceof right;
1906
1896
  }
1907
1897
  }
1898
+ function _type_of(obj) {
1899
+ "@swc/helpers - typeof";
1900
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1901
+ }
1908
1902
  function _ts_generator(thisArg, body) {
1909
1903
  var f, y, t, g, _ = {
1910
1904
  label: 0,
@@ -2065,7 +2059,7 @@ var StatsPlugin = /*#__PURE__*/ function() {
2065
2059
  publicPath: _this1._statsManager.getPublicPath(compiler),
2066
2060
  compiler: compiler,
2067
2061
  bundler: _this1._bundler,
2068
- additionalData: typeof _this1._options.manifest === 'object' ? _this1._options.manifest.additionalData : undefined
2062
+ additionalData: _type_of(_this1._options.manifest) === 'object' ? _this1._options.manifest.additionalData : undefined
2069
2063
  });
2070
2064
  _state.label = 2;
2071
2065
  case 2:
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/manifest",
3
- "version": "0.1.15",
3
+ "version": "0.1.19",
4
4
  "license": "MIT",
5
5
  "description": "Provide manifest/stats for webpack/rspack MF project .",
6
6
  "keywords": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/manifest",
3
- "version": "0.0.0-next-20240617071542",
3
+ "version": "0.0.0-next-20240617084909",
4
4
  "license": "MIT",
5
5
  "description": "Provide manifest/stats for webpack/rspack MF project .",
6
6
  "keywords": [
@@ -24,9 +24,9 @@
24
24
  "dependencies": {
25
25
  "find-pkg": "2.0.0",
26
26
  "chalk": "3.0.0",
27
- "@module-federation/sdk": "0.0.0-next-20240617071542",
28
- "@module-federation/dts-plugin": "0.0.0-next-20240617071542",
29
- "@module-federation/managers": "0.0.0-next-20240617071542"
27
+ "@module-federation/sdk": "0.0.0-next-20240617084909",
28
+ "@module-federation/dts-plugin": "0.0.0-next-20240617084909",
29
+ "@module-federation/managers": "0.0.0-next-20240617084909"
30
30
  },
31
31
  "exports": {
32
32
  ".": {