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

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