@module-federation/manifest 0.0.0-next-20240514062402 → 0.0.0-next-20240515091026

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
@@ -658,13 +658,15 @@ var ManifestManager = /*#__PURE__*/ function() {
658
658
  {
659
659
  key: "generateManifest",
660
660
  value: function generateManifest(options) {
661
+ var extraOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
661
662
  var _this = this;
662
663
  return _async_to_generator$2(function() {
663
- var compilation, publicPath, stats, compiler, bundler, additionalData, manifest, manifestFileName, ret;
664
+ var compilation, publicPath, stats, compiler, bundler, additionalData, disableEmit, manifest, manifestFileName, ret;
664
665
  return _ts_generator$2(this, function(_state) {
665
666
  switch(_state.label){
666
667
  case 0:
667
668
  compilation = options.compilation, publicPath = options.publicPath, stats = options.stats, compiler = options.compiler, bundler = options.bundler, additionalData = options.additionalData;
669
+ disableEmit = extraOptions.disableEmit;
668
670
  manifest = _object_spread$2({}, stats);
669
671
  manifest.exposes = Object.keys(stats.exposes).reduce(function(sum, cur) {
670
672
  var statsExpose = manifest.exposes[cur];
@@ -731,12 +733,18 @@ var ManifestManager = /*#__PURE__*/ function() {
731
733
  _this._manifest = ret || _this._manifest;
732
734
  _state.label = 2;
733
735
  case 2:
734
- compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
736
+ if (!disableEmit) {
737
+ compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
738
+ }
735
739
  if (isDev()) {
736
740
  console.log(chalk__default["default"](_templateObject$1(), PLUGIN_IDENTIFIER, publicPath === 'auto' ? '{auto}/' : publicPath, manifestFileName));
737
741
  }
738
742
  return [
739
- 2
743
+ 2,
744
+ {
745
+ manifest: _this._manifest,
746
+ filename: manifestFileName
747
+ }
740
748
  ];
741
749
  }
742
750
  });
@@ -1486,7 +1494,7 @@ var StatsManager = /*#__PURE__*/ function() {
1486
1494
  remoteEntry: {
1487
1495
  name: getRemoteEntryName(),
1488
1496
  path: '',
1489
- // same as the types supported by runtime, currently only global/var/script is supported
1497
+ // same as the types supported by runtime, currently only global/var/script/cjs:webpack is supported
1490
1498
  type: 'global'
1491
1499
  },
1492
1500
  types: getTypesMetaInfo(this._options, compiler.context),
@@ -1754,10 +1762,11 @@ var StatsManager = /*#__PURE__*/ function() {
1754
1762
  },
1755
1763
  {
1756
1764
  key: "generateStats",
1757
- value: function generateStats(compiler, compilation, extraOptions) {
1765
+ value: function generateStats(compiler, compilation) {
1766
+ var extraOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1758
1767
  var _this = this;
1759
1768
  return _async_to_generator$1(function() {
1760
- var existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
1769
+ var disableEmit, existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
1761
1770
  return _ts_generator$1(this, function(_state) {
1762
1771
  switch(_state.label){
1763
1772
  case 0:
@@ -1767,6 +1776,7 @@ var StatsManager = /*#__PURE__*/ function() {
1767
1776
  ,
1768
1777
  5
1769
1778
  ]);
1779
+ disableEmit = extraOptions.disableEmit;
1770
1780
  existedStats = compilation.getAsset(_this.fileName);
1771
1781
  if (existedStats) {
1772
1782
  return [
@@ -1800,10 +1810,15 @@ var StatsManager = /*#__PURE__*/ function() {
1800
1810
  stats = ret || stats;
1801
1811
  _state.label = 3;
1802
1812
  case 3:
1803
- compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
1813
+ if (!disableEmit) {
1814
+ compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
1815
+ }
1804
1816
  return [
1805
1817
  2,
1806
- stats
1818
+ {
1819
+ stats: stats,
1820
+ filename: _this.fileName
1821
+ }
1807
1822
  ];
1808
1823
  case 4:
1809
1824
  err = _state.sent();
@@ -2008,9 +2023,13 @@ var StatsPlugin = /*#__PURE__*/ function() {
2008
2023
  _define_property(this, "_manifestManager", new ManifestManager());
2009
2024
  _define_property(this, "_enable", true);
2010
2025
  _define_property(this, "_bundler", 'webpack');
2026
+ _define_property(this, "statsInfo", void 0);
2027
+ _define_property(this, "manifestInfo", void 0);
2028
+ _define_property(this, "disableEmit", void 0);
2011
2029
  try {
2012
2030
  this._options = options;
2013
2031
  this._bundler = bundler;
2032
+ this.disableEmit = Boolean(process.env['MF_DISABLE_EMIT_STATS']);
2014
2033
  this._statsManager.init(this._options, {
2015
2034
  pluginVersion: pluginVersion,
2016
2035
  bundler: bundler
@@ -2043,30 +2062,38 @@ var StatsPlugin = /*#__PURE__*/ function() {
2043
2062
  // @ts-ignore use runtime variable in case peer dep not installed
2044
2063
  stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
2045
2064
  }, /*#__PURE__*/ _async_to_generator(function() {
2046
- var stats;
2047
2065
  return _ts_generator(this, function(_state) {
2048
2066
  switch(_state.label){
2049
2067
  case 0:
2050
2068
  if (!(_this1._options.manifest !== false)) return [
2051
2069
  3,
2052
- 2
2070
+ 3
2053
2071
  ];
2054
2072
  return [
2055
2073
  4,
2056
- _this1._statsManager.generateStats(compiler, compilation)
2074
+ _this1._statsManager.generateStats(compiler, compilation, {
2075
+ disableEmit: _this1.disableEmit
2076
+ })
2057
2077
  ];
2058
2078
  case 1:
2059
- stats = _state.sent();
2060
- _this1._manifestManager.generateManifest({
2061
- compilation: compilation,
2062
- stats: stats,
2063
- publicPath: _this1._statsManager.getPublicPath(compiler),
2064
- compiler: compiler,
2065
- bundler: _this1._bundler,
2066
- additionalData: typeof _this1._options.manifest === 'object' ? _this1._options.manifest.additionalData : undefined
2067
- });
2068
- _state.label = 2;
2079
+ _this1.statsInfo = _state.sent();
2080
+ return [
2081
+ 4,
2082
+ _this1._manifestManager.generateManifest({
2083
+ compilation: compilation,
2084
+ stats: _this1.statsInfo.stats,
2085
+ publicPath: _this1._statsManager.getPublicPath(compiler),
2086
+ compiler: compiler,
2087
+ bundler: _this1._bundler,
2088
+ additionalData: typeof _this1._options.manifest === 'object' ? _this1._options.manifest.additionalData : undefined
2089
+ }, {
2090
+ disableEmit: _this1.disableEmit
2091
+ })
2092
+ ];
2069
2093
  case 2:
2094
+ _this1.manifestInfo = _state.sent();
2095
+ _state.label = 3;
2096
+ case 3:
2070
2097
  return [
2071
2098
  2
2072
2099
  ];
@@ -2075,6 +2102,15 @@ var StatsPlugin = /*#__PURE__*/ function() {
2075
2102
  }));
2076
2103
  });
2077
2104
  }
2105
+ },
2106
+ {
2107
+ key: "resourceInfo",
2108
+ get: function get() {
2109
+ return {
2110
+ stats: this.statsInfo,
2111
+ manifest: this.manifestInfo
2112
+ };
2113
+ }
2078
2114
  }
2079
2115
  ]);
2080
2116
  return StatsPlugin;
package/dist/index.esm.js CHANGED
@@ -649,13 +649,15 @@ var ManifestManager = /*#__PURE__*/ function() {
649
649
  {
650
650
  key: "generateManifest",
651
651
  value: function generateManifest(options) {
652
+ var extraOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
652
653
  var _this = this;
653
654
  return _async_to_generator$2(function() {
654
- var compilation, publicPath, stats, compiler, bundler, additionalData, manifest, manifestFileName, ret;
655
+ var compilation, publicPath, stats, compiler, bundler, additionalData, disableEmit, manifest, manifestFileName, ret;
655
656
  return _ts_generator$2(this, function(_state) {
656
657
  switch(_state.label){
657
658
  case 0:
658
659
  compilation = options.compilation, publicPath = options.publicPath, stats = options.stats, compiler = options.compiler, bundler = options.bundler, additionalData = options.additionalData;
660
+ disableEmit = extraOptions.disableEmit;
659
661
  manifest = _object_spread$2({}, stats);
660
662
  manifest.exposes = Object.keys(stats.exposes).reduce(function(sum, cur) {
661
663
  var statsExpose = manifest.exposes[cur];
@@ -722,12 +724,18 @@ var ManifestManager = /*#__PURE__*/ function() {
722
724
  _this._manifest = ret || _this._manifest;
723
725
  _state.label = 2;
724
726
  case 2:
725
- compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
727
+ if (!disableEmit) {
728
+ compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
729
+ }
726
730
  if (isDev()) {
727
731
  console.log(chalk(_templateObject$1(), PLUGIN_IDENTIFIER, publicPath === 'auto' ? '{auto}/' : publicPath, manifestFileName));
728
732
  }
729
733
  return [
730
- 2
734
+ 2,
735
+ {
736
+ manifest: _this._manifest,
737
+ filename: manifestFileName
738
+ }
731
739
  ];
732
740
  }
733
741
  });
@@ -1477,7 +1485,7 @@ var StatsManager = /*#__PURE__*/ function() {
1477
1485
  remoteEntry: {
1478
1486
  name: getRemoteEntryName(),
1479
1487
  path: '',
1480
- // same as the types supported by runtime, currently only global/var/script is supported
1488
+ // same as the types supported by runtime, currently only global/var/script/cjs:webpack is supported
1481
1489
  type: 'global'
1482
1490
  },
1483
1491
  types: getTypesMetaInfo(this._options, compiler.context),
@@ -1745,10 +1753,11 @@ var StatsManager = /*#__PURE__*/ function() {
1745
1753
  },
1746
1754
  {
1747
1755
  key: "generateStats",
1748
- value: function generateStats(compiler, compilation, extraOptions) {
1756
+ value: function generateStats(compiler, compilation) {
1757
+ var extraOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1749
1758
  var _this = this;
1750
1759
  return _async_to_generator$1(function() {
1751
- var existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
1760
+ var disableEmit, existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
1752
1761
  return _ts_generator$1(this, function(_state) {
1753
1762
  switch(_state.label){
1754
1763
  case 0:
@@ -1758,6 +1767,7 @@ var StatsManager = /*#__PURE__*/ function() {
1758
1767
  ,
1759
1768
  5
1760
1769
  ]);
1770
+ disableEmit = extraOptions.disableEmit;
1761
1771
  existedStats = compilation.getAsset(_this.fileName);
1762
1772
  if (existedStats) {
1763
1773
  return [
@@ -1791,10 +1801,15 @@ var StatsManager = /*#__PURE__*/ function() {
1791
1801
  stats = ret || stats;
1792
1802
  _state.label = 3;
1793
1803
  case 3:
1794
- compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
1804
+ if (!disableEmit) {
1805
+ compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
1806
+ }
1795
1807
  return [
1796
1808
  2,
1797
- stats
1809
+ {
1810
+ stats: stats,
1811
+ filename: _this.fileName
1812
+ }
1798
1813
  ];
1799
1814
  case 4:
1800
1815
  err = _state.sent();
@@ -1999,9 +2014,13 @@ var StatsPlugin = /*#__PURE__*/ function() {
1999
2014
  _define_property(this, "_manifestManager", new ManifestManager());
2000
2015
  _define_property(this, "_enable", true);
2001
2016
  _define_property(this, "_bundler", 'webpack');
2017
+ _define_property(this, "statsInfo", void 0);
2018
+ _define_property(this, "manifestInfo", void 0);
2019
+ _define_property(this, "disableEmit", void 0);
2002
2020
  try {
2003
2021
  this._options = options;
2004
2022
  this._bundler = bundler;
2023
+ this.disableEmit = Boolean(process.env['MF_DISABLE_EMIT_STATS']);
2005
2024
  this._statsManager.init(this._options, {
2006
2025
  pluginVersion: pluginVersion,
2007
2026
  bundler: bundler
@@ -2034,30 +2053,38 @@ var StatsPlugin = /*#__PURE__*/ function() {
2034
2053
  // @ts-ignore use runtime variable in case peer dep not installed
2035
2054
  stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
2036
2055
  }, /*#__PURE__*/ _async_to_generator(function() {
2037
- var stats;
2038
2056
  return _ts_generator(this, function(_state) {
2039
2057
  switch(_state.label){
2040
2058
  case 0:
2041
2059
  if (!(_this1._options.manifest !== false)) return [
2042
2060
  3,
2043
- 2
2061
+ 3
2044
2062
  ];
2045
2063
  return [
2046
2064
  4,
2047
- _this1._statsManager.generateStats(compiler, compilation)
2065
+ _this1._statsManager.generateStats(compiler, compilation, {
2066
+ disableEmit: _this1.disableEmit
2067
+ })
2048
2068
  ];
2049
2069
  case 1:
2050
- stats = _state.sent();
2051
- _this1._manifestManager.generateManifest({
2052
- compilation: compilation,
2053
- stats: stats,
2054
- publicPath: _this1._statsManager.getPublicPath(compiler),
2055
- compiler: compiler,
2056
- bundler: _this1._bundler,
2057
- additionalData: typeof _this1._options.manifest === 'object' ? _this1._options.manifest.additionalData : undefined
2058
- });
2059
- _state.label = 2;
2070
+ _this1.statsInfo = _state.sent();
2071
+ return [
2072
+ 4,
2073
+ _this1._manifestManager.generateManifest({
2074
+ compilation: compilation,
2075
+ stats: _this1.statsInfo.stats,
2076
+ publicPath: _this1._statsManager.getPublicPath(compiler),
2077
+ compiler: compiler,
2078
+ bundler: _this1._bundler,
2079
+ additionalData: typeof _this1._options.manifest === 'object' ? _this1._options.manifest.additionalData : undefined
2080
+ }, {
2081
+ disableEmit: _this1.disableEmit
2082
+ })
2083
+ ];
2060
2084
  case 2:
2085
+ _this1.manifestInfo = _state.sent();
2086
+ _state.label = 3;
2087
+ case 3:
2061
2088
  return [
2062
2089
  2
2063
2090
  ];
@@ -2066,6 +2093,15 @@ var StatsPlugin = /*#__PURE__*/ function() {
2066
2093
  }));
2067
2094
  });
2068
2095
  }
2096
+ },
2097
+ {
2098
+ key: "resourceInfo",
2099
+ get: function get() {
2100
+ return {
2101
+ stats: this.statsInfo,
2102
+ manifest: this.manifestInfo
2103
+ };
2104
+ }
2069
2105
  }
2070
2106
  ]);
2071
2107
  return StatsPlugin;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/manifest",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "license": "MIT",
5
5
  "description": "Provide manifest/stats for webpack/rspack MF project .",
6
6
  "keywords": [
@@ -1,5 +1,6 @@
1
1
  import { Stats, Manifest, moduleFederationPlugin } from '@module-federation/sdk';
2
2
  import type { Compilation, Compiler } from 'webpack';
3
+ import { ManifestInfo } from './types';
3
4
  interface GenerateManifestOptions {
4
5
  compilation: Compilation;
5
6
  stats: Stats;
@@ -14,6 +15,8 @@ declare class ManifestManager {
14
15
  get manifest(): Manifest | undefined;
15
16
  init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
16
17
  get fileName(): string;
17
- generateManifest(options: GenerateManifestOptions): Promise<void>;
18
+ generateManifest(options: GenerateManifestOptions, extraOptions?: {
19
+ disableEmit?: boolean;
20
+ }): Promise<ManifestInfo>;
18
21
  }
19
22
  export { ManifestManager };
@@ -1,5 +1,6 @@
1
- import { StatsBuildInfo, Stats, moduleFederationPlugin } from '@module-federation/sdk';
1
+ import { StatsBuildInfo, moduleFederationPlugin } from '@module-federation/sdk';
2
2
  import { Compilation, Compiler } from 'webpack';
3
+ import { StatsInfo } from './types';
3
4
  declare class StatsManager {
4
5
  private _options;
5
6
  private _publicPath?;
@@ -21,7 +22,9 @@ declare class StatsManager {
21
22
  pluginVersion: string;
22
23
  bundler: 'webpack' | 'rspack';
23
24
  }): void;
24
- generateStats(compiler: Compiler, compilation: Compilation, extraOptions?: {}): Promise<Stats>;
25
+ generateStats(compiler: Compiler, compilation: Compilation, extraOptions?: {
26
+ disableEmit?: boolean;
27
+ }): Promise<StatsInfo>;
25
28
  validate(compiler: Compiler): boolean;
26
29
  }
27
30
  export { StatsManager };
@@ -1,5 +1,6 @@
1
1
  import { Compiler, WebpackPluginInstance } from 'webpack';
2
2
  import { moduleFederationPlugin } from '@module-federation/sdk';
3
+ import { StatsInfo, ManifestInfo, ResourceInfo } from './types';
3
4
  export declare class StatsPlugin implements WebpackPluginInstance {
4
5
  readonly name = "StatsPlugin";
5
6
  private _options;
@@ -7,9 +8,13 @@ export declare class StatsPlugin implements WebpackPluginInstance {
7
8
  private _manifestManager;
8
9
  private _enable;
9
10
  private _bundler;
11
+ statsInfo?: StatsInfo;
12
+ manifestInfo?: ManifestInfo;
13
+ disableEmit?: boolean;
10
14
  constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions, { pluginVersion, bundler, }: {
11
15
  pluginVersion: string;
12
16
  bundler: 'webpack' | 'rspack';
13
17
  });
14
18
  apply(compiler: Compiler): void;
19
+ get resourceInfo(): Partial<ResourceInfo>;
15
20
  }
@@ -1,3 +1,4 @@
1
1
  export { StatsPlugin } from './StatsPlugin';
2
2
  export { ManifestManager } from './ManifestManager';
3
3
  export { StatsManager } from './StatsManager';
4
+ export * from './types';
@@ -0,0 +1,13 @@
1
+ import { Manifest, Stats } from '@module-federation/sdk';
2
+ export type StatsInfo = {
3
+ stats: Stats;
4
+ filename: string;
5
+ };
6
+ export type ManifestInfo = {
7
+ manifest: Manifest;
8
+ filename: string;
9
+ };
10
+ export type ResourceInfo = {
11
+ stats: StatsInfo;
12
+ manifest: ManifestInfo;
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/manifest",
3
- "version": "0.0.0-next-20240514062402",
3
+ "version": "0.0.0-next-20240515091026",
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-20240514062402",
28
- "@module-federation/dts-plugin": "0.0.0-next-20240514062402",
29
- "@module-federation/managers": "0.0.0-next-20240514062402"
27
+ "@module-federation/sdk": "0.0.0-next-20240515091026",
28
+ "@module-federation/dts-plugin": "0.0.0-next-20240515091026",
29
+ "@module-federation/managers": "0.0.0-next-20240515091026"
30
30
  },
31
31
  "exports": {
32
32
  ".": {