@module-federation/manifest 0.0.0-next-20240605063149 → 0.0.0-next-20240605083609
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 +84 -51
- package/dist/index.esm.js +84 -51
- package/dist/package.json +1 -1
- package/dist/src/ManifestManager.d.ts +4 -1
- package/dist/src/StatsManager.d.ts +5 -2
- package/dist/src/StatsPlugin.d.ts +5 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/types.d.ts +13 -0
- package/package.json +4 -4
package/dist/index.cjs.js
CHANGED
|
@@ -658,53 +658,52 @@ 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
|
-
manifest.exposes =
|
|
670
|
-
var statsExpose = manifest.exposes[cur];
|
|
671
|
+
manifest.exposes = stats.exposes.reduce(function(sum, cur) {
|
|
671
672
|
var expose = {
|
|
672
|
-
id:
|
|
673
|
-
name:
|
|
674
|
-
assets:
|
|
675
|
-
path:
|
|
673
|
+
id: cur.id,
|
|
674
|
+
name: cur.name,
|
|
675
|
+
assets: cur.assets,
|
|
676
|
+
path: cur.path
|
|
676
677
|
};
|
|
677
678
|
sum.push(expose);
|
|
678
679
|
return sum;
|
|
679
680
|
}, []);
|
|
680
|
-
manifest.shared =
|
|
681
|
-
var statsShared = manifest.shared[cur];
|
|
681
|
+
manifest.shared = stats.shared.reduce(function(sum, cur) {
|
|
682
682
|
var shared = {
|
|
683
|
-
id:
|
|
684
|
-
name:
|
|
685
|
-
version:
|
|
686
|
-
singleton:
|
|
687
|
-
requiredVersion:
|
|
688
|
-
hash:
|
|
689
|
-
assets:
|
|
683
|
+
id: cur.id,
|
|
684
|
+
name: cur.name,
|
|
685
|
+
version: cur.version,
|
|
686
|
+
singleton: cur.singleton,
|
|
687
|
+
requiredVersion: cur.requiredVersion,
|
|
688
|
+
hash: cur.hash,
|
|
689
|
+
assets: cur.assets
|
|
690
690
|
};
|
|
691
691
|
sum.push(shared);
|
|
692
692
|
return sum;
|
|
693
693
|
}, []);
|
|
694
|
-
manifest.remotes =
|
|
695
|
-
var statsRemote = manifest.remotes[cur];
|
|
694
|
+
manifest.remotes = stats.remotes.reduce(function(sum, cur) {
|
|
696
695
|
// @ts-ignore version/entry will be added as follow
|
|
697
696
|
var remote = {
|
|
698
|
-
federationContainerName:
|
|
699
|
-
moduleName:
|
|
700
|
-
alias:
|
|
697
|
+
federationContainerName: cur.federationContainerName,
|
|
698
|
+
moduleName: cur.moduleName,
|
|
699
|
+
alias: cur.alias
|
|
701
700
|
};
|
|
702
|
-
if ('entry' in
|
|
701
|
+
if ('entry' in cur) {
|
|
703
702
|
// @ts-ignore
|
|
704
|
-
remote.entry =
|
|
705
|
-
} else if ('version' in
|
|
703
|
+
remote.entry = cur.entry;
|
|
704
|
+
} else if ('version' in cur) {
|
|
706
705
|
// @ts-ignore
|
|
707
|
-
remote.entry =
|
|
706
|
+
remote.entry = cur.version;
|
|
708
707
|
}
|
|
709
708
|
sum.push(remote);
|
|
710
709
|
return sum;
|
|
@@ -731,12 +730,18 @@ var ManifestManager = /*#__PURE__*/ function() {
|
|
|
731
730
|
_this._manifest = ret || _this._manifest;
|
|
732
731
|
_state.label = 2;
|
|
733
732
|
case 2:
|
|
734
|
-
|
|
733
|
+
if (!disableEmit) {
|
|
734
|
+
compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
|
|
735
|
+
}
|
|
735
736
|
if (isDev()) {
|
|
736
737
|
console.log(chalk__default["default"](_templateObject$1(), PLUGIN_IDENTIFIER, publicPath === 'auto' ? '{auto}/' : publicPath, manifestFileName));
|
|
737
738
|
}
|
|
738
739
|
return [
|
|
739
|
-
2
|
|
740
|
+
2,
|
|
741
|
+
{
|
|
742
|
+
manifest: _this._manifest,
|
|
743
|
+
filename: manifestFileName
|
|
744
|
+
}
|
|
740
745
|
];
|
|
741
746
|
}
|
|
742
747
|
});
|
|
@@ -898,13 +903,11 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
898
903
|
}
|
|
899
904
|
var sharedManagerNormalizedOptions = this._sharedManager.normalizedOptions;
|
|
900
905
|
var initShared = function(pkgName, pkgVersion) {
|
|
901
|
-
var _sharedManagerNormalizedOptions_pkgName;
|
|
902
906
|
if (sharedMap[pkgName]) {
|
|
903
907
|
return;
|
|
904
908
|
}
|
|
905
909
|
sharedMap[pkgName] = _object_spread_props$1(_object_spread$1({}, sharedManagerNormalizedOptions[pkgName]), {
|
|
906
910
|
id: "".concat(_this._options.name, ":").concat(pkgName),
|
|
907
|
-
requiredVersion: ((_sharedManagerNormalizedOptions_pkgName = sharedManagerNormalizedOptions[pkgName]) === null || _sharedManagerNormalizedOptions_pkgName === void 0 ? void 0 : _sharedManagerNormalizedOptions_pkgName.requiredVersion) || "^".concat(pkgVersion),
|
|
908
911
|
name: pkgName,
|
|
909
912
|
version: pkgVersion,
|
|
910
913
|
assets: {
|
|
@@ -1459,7 +1462,6 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1459
1462
|
key: "_getMetaData",
|
|
1460
1463
|
value: function _getMetaData(compiler, compilation, extraOptions) {
|
|
1461
1464
|
var _this = this;
|
|
1462
|
-
var _this__options_library, _this__options;
|
|
1463
1465
|
var context = compiler.options.context;
|
|
1464
1466
|
var _this1 = this, name = _this1._options.name, buildInfo = _this1.buildInfo;
|
|
1465
1467
|
var type = this._pkgJsonManager.getExposeGarfishModuleType(context || process.cwd());
|
|
@@ -1489,8 +1491,8 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1489
1491
|
remoteEntry: {
|
|
1490
1492
|
name: getRemoteEntryName(),
|
|
1491
1493
|
path: '',
|
|
1492
|
-
// same as the types supported by runtime, currently only global/var/script is supported
|
|
1493
|
-
type:
|
|
1494
|
+
// same as the types supported by runtime, currently only global/var/script/cjs:webpack is supported
|
|
1495
|
+
type: 'global'
|
|
1494
1496
|
},
|
|
1495
1497
|
types: getTypesMetaInfo(this._options, compiler.context),
|
|
1496
1498
|
globalName: globalName,
|
|
@@ -1757,10 +1759,11 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1757
1759
|
},
|
|
1758
1760
|
{
|
|
1759
1761
|
key: "generateStats",
|
|
1760
|
-
value: function generateStats(compiler, compilation
|
|
1762
|
+
value: function generateStats(compiler, compilation) {
|
|
1763
|
+
var extraOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1761
1764
|
var _this = this;
|
|
1762
1765
|
return _async_to_generator$1(function() {
|
|
1763
|
-
var existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
|
|
1766
|
+
var disableEmit, existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
|
|
1764
1767
|
return _ts_generator$1(this, function(_state) {
|
|
1765
1768
|
switch(_state.label){
|
|
1766
1769
|
case 0:
|
|
@@ -1770,11 +1773,15 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1770
1773
|
,
|
|
1771
1774
|
5
|
|
1772
1775
|
]);
|
|
1776
|
+
disableEmit = extraOptions.disableEmit;
|
|
1773
1777
|
existedStats = compilation.getAsset(_this.fileName);
|
|
1774
|
-
if (existedStats) {
|
|
1778
|
+
if (existedStats && !isDev()) {
|
|
1775
1779
|
return [
|
|
1776
1780
|
2,
|
|
1777
|
-
|
|
1781
|
+
{
|
|
1782
|
+
stats: JSON.parse(existedStats.source.source().toString()),
|
|
1783
|
+
filename: _this.fileName
|
|
1784
|
+
}
|
|
1778
1785
|
];
|
|
1779
1786
|
}
|
|
1780
1787
|
_this__options = _this._options, tmp = _this__options.manifest, manifestOptions = tmp === void 0 ? {} : tmp;
|
|
@@ -1803,10 +1810,15 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1803
1810
|
stats = ret || stats;
|
|
1804
1811
|
_state.label = 3;
|
|
1805
1812
|
case 3:
|
|
1806
|
-
|
|
1813
|
+
if (!disableEmit) {
|
|
1814
|
+
compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
|
|
1815
|
+
}
|
|
1807
1816
|
return [
|
|
1808
1817
|
2,
|
|
1809
|
-
|
|
1818
|
+
{
|
|
1819
|
+
stats: stats,
|
|
1820
|
+
filename: _this.fileName
|
|
1821
|
+
}
|
|
1810
1822
|
];
|
|
1811
1823
|
case 4:
|
|
1812
1824
|
err = _state.sent();
|
|
@@ -2011,9 +2023,13 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2011
2023
|
_define_property(this, "_manifestManager", new ManifestManager());
|
|
2012
2024
|
_define_property(this, "_enable", true);
|
|
2013
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);
|
|
2014
2029
|
try {
|
|
2015
2030
|
this._options = options;
|
|
2016
2031
|
this._bundler = bundler;
|
|
2032
|
+
this.disableEmit = Boolean(process.env['MF_DISABLE_EMIT_STATS']);
|
|
2017
2033
|
this._statsManager.init(this._options, {
|
|
2018
2034
|
pluginVersion: pluginVersion,
|
|
2019
2035
|
bundler: bundler
|
|
@@ -2046,30 +2062,38 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2046
2062
|
// @ts-ignore use runtime variable in case peer dep not installed
|
|
2047
2063
|
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
2048
2064
|
}, /*#__PURE__*/ _async_to_generator(function() {
|
|
2049
|
-
var stats;
|
|
2050
2065
|
return _ts_generator(this, function(_state) {
|
|
2051
2066
|
switch(_state.label){
|
|
2052
2067
|
case 0:
|
|
2053
2068
|
if (!(_this1._options.manifest !== false)) return [
|
|
2054
2069
|
3,
|
|
2055
|
-
|
|
2070
|
+
3
|
|
2056
2071
|
];
|
|
2057
2072
|
return [
|
|
2058
2073
|
4,
|
|
2059
|
-
_this1._statsManager.generateStats(compiler, compilation
|
|
2074
|
+
_this1._statsManager.generateStats(compiler, compilation, {
|
|
2075
|
+
disableEmit: _this1.disableEmit
|
|
2076
|
+
})
|
|
2060
2077
|
];
|
|
2061
2078
|
case 1:
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
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
|
+
];
|
|
2072
2093
|
case 2:
|
|
2094
|
+
_this1.manifestInfo = _state.sent();
|
|
2095
|
+
_state.label = 3;
|
|
2096
|
+
case 3:
|
|
2073
2097
|
return [
|
|
2074
2098
|
2
|
|
2075
2099
|
];
|
|
@@ -2078,6 +2102,15 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2078
2102
|
}));
|
|
2079
2103
|
});
|
|
2080
2104
|
}
|
|
2105
|
+
},
|
|
2106
|
+
{
|
|
2107
|
+
key: "resourceInfo",
|
|
2108
|
+
get: function get() {
|
|
2109
|
+
return {
|
|
2110
|
+
stats: this.statsInfo,
|
|
2111
|
+
manifest: this.manifestInfo
|
|
2112
|
+
};
|
|
2113
|
+
}
|
|
2081
2114
|
}
|
|
2082
2115
|
]);
|
|
2083
2116
|
return StatsPlugin;
|
package/dist/index.esm.js
CHANGED
|
@@ -649,53 +649,52 @@ 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
|
-
manifest.exposes =
|
|
661
|
-
var statsExpose = manifest.exposes[cur];
|
|
662
|
+
manifest.exposes = stats.exposes.reduce(function(sum, cur) {
|
|
662
663
|
var expose = {
|
|
663
|
-
id:
|
|
664
|
-
name:
|
|
665
|
-
assets:
|
|
666
|
-
path:
|
|
664
|
+
id: cur.id,
|
|
665
|
+
name: cur.name,
|
|
666
|
+
assets: cur.assets,
|
|
667
|
+
path: cur.path
|
|
667
668
|
};
|
|
668
669
|
sum.push(expose);
|
|
669
670
|
return sum;
|
|
670
671
|
}, []);
|
|
671
|
-
manifest.shared =
|
|
672
|
-
var statsShared = manifest.shared[cur];
|
|
672
|
+
manifest.shared = stats.shared.reduce(function(sum, cur) {
|
|
673
673
|
var shared = {
|
|
674
|
-
id:
|
|
675
|
-
name:
|
|
676
|
-
version:
|
|
677
|
-
singleton:
|
|
678
|
-
requiredVersion:
|
|
679
|
-
hash:
|
|
680
|
-
assets:
|
|
674
|
+
id: cur.id,
|
|
675
|
+
name: cur.name,
|
|
676
|
+
version: cur.version,
|
|
677
|
+
singleton: cur.singleton,
|
|
678
|
+
requiredVersion: cur.requiredVersion,
|
|
679
|
+
hash: cur.hash,
|
|
680
|
+
assets: cur.assets
|
|
681
681
|
};
|
|
682
682
|
sum.push(shared);
|
|
683
683
|
return sum;
|
|
684
684
|
}, []);
|
|
685
|
-
manifest.remotes =
|
|
686
|
-
var statsRemote = manifest.remotes[cur];
|
|
685
|
+
manifest.remotes = stats.remotes.reduce(function(sum, cur) {
|
|
687
686
|
// @ts-ignore version/entry will be added as follow
|
|
688
687
|
var remote = {
|
|
689
|
-
federationContainerName:
|
|
690
|
-
moduleName:
|
|
691
|
-
alias:
|
|
688
|
+
federationContainerName: cur.federationContainerName,
|
|
689
|
+
moduleName: cur.moduleName,
|
|
690
|
+
alias: cur.alias
|
|
692
691
|
};
|
|
693
|
-
if ('entry' in
|
|
692
|
+
if ('entry' in cur) {
|
|
694
693
|
// @ts-ignore
|
|
695
|
-
remote.entry =
|
|
696
|
-
} else if ('version' in
|
|
694
|
+
remote.entry = cur.entry;
|
|
695
|
+
} else if ('version' in cur) {
|
|
697
696
|
// @ts-ignore
|
|
698
|
-
remote.entry =
|
|
697
|
+
remote.entry = cur.version;
|
|
699
698
|
}
|
|
700
699
|
sum.push(remote);
|
|
701
700
|
return sum;
|
|
@@ -722,12 +721,18 @@ var ManifestManager = /*#__PURE__*/ function() {
|
|
|
722
721
|
_this._manifest = ret || _this._manifest;
|
|
723
722
|
_state.label = 2;
|
|
724
723
|
case 2:
|
|
725
|
-
|
|
724
|
+
if (!disableEmit) {
|
|
725
|
+
compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
|
|
726
|
+
}
|
|
726
727
|
if (isDev()) {
|
|
727
728
|
console.log(chalk(_templateObject$1(), PLUGIN_IDENTIFIER, publicPath === 'auto' ? '{auto}/' : publicPath, manifestFileName));
|
|
728
729
|
}
|
|
729
730
|
return [
|
|
730
|
-
2
|
|
731
|
+
2,
|
|
732
|
+
{
|
|
733
|
+
manifest: _this._manifest,
|
|
734
|
+
filename: manifestFileName
|
|
735
|
+
}
|
|
731
736
|
];
|
|
732
737
|
}
|
|
733
738
|
});
|
|
@@ -889,13 +894,11 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
889
894
|
}
|
|
890
895
|
var sharedManagerNormalizedOptions = this._sharedManager.normalizedOptions;
|
|
891
896
|
var initShared = function(pkgName, pkgVersion) {
|
|
892
|
-
var _sharedManagerNormalizedOptions_pkgName;
|
|
893
897
|
if (sharedMap[pkgName]) {
|
|
894
898
|
return;
|
|
895
899
|
}
|
|
896
900
|
sharedMap[pkgName] = _object_spread_props$1(_object_spread$1({}, sharedManagerNormalizedOptions[pkgName]), {
|
|
897
901
|
id: "".concat(_this._options.name, ":").concat(pkgName),
|
|
898
|
-
requiredVersion: ((_sharedManagerNormalizedOptions_pkgName = sharedManagerNormalizedOptions[pkgName]) === null || _sharedManagerNormalizedOptions_pkgName === void 0 ? void 0 : _sharedManagerNormalizedOptions_pkgName.requiredVersion) || "^".concat(pkgVersion),
|
|
899
902
|
name: pkgName,
|
|
900
903
|
version: pkgVersion,
|
|
901
904
|
assets: {
|
|
@@ -1450,7 +1453,6 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1450
1453
|
key: "_getMetaData",
|
|
1451
1454
|
value: function _getMetaData(compiler, compilation, extraOptions) {
|
|
1452
1455
|
var _this = this;
|
|
1453
|
-
var _this__options_library, _this__options;
|
|
1454
1456
|
var context = compiler.options.context;
|
|
1455
1457
|
var _this1 = this, name = _this1._options.name, buildInfo = _this1.buildInfo;
|
|
1456
1458
|
var type = this._pkgJsonManager.getExposeGarfishModuleType(context || process.cwd());
|
|
@@ -1480,8 +1482,8 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1480
1482
|
remoteEntry: {
|
|
1481
1483
|
name: getRemoteEntryName(),
|
|
1482
1484
|
path: '',
|
|
1483
|
-
// same as the types supported by runtime, currently only global/var/script is supported
|
|
1484
|
-
type:
|
|
1485
|
+
// same as the types supported by runtime, currently only global/var/script/cjs:webpack is supported
|
|
1486
|
+
type: 'global'
|
|
1485
1487
|
},
|
|
1486
1488
|
types: getTypesMetaInfo(this._options, compiler.context),
|
|
1487
1489
|
globalName: globalName,
|
|
@@ -1748,10 +1750,11 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1748
1750
|
},
|
|
1749
1751
|
{
|
|
1750
1752
|
key: "generateStats",
|
|
1751
|
-
value: function generateStats(compiler, compilation
|
|
1753
|
+
value: function generateStats(compiler, compilation) {
|
|
1754
|
+
var extraOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1752
1755
|
var _this = this;
|
|
1753
1756
|
return _async_to_generator$1(function() {
|
|
1754
|
-
var existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
|
|
1757
|
+
var disableEmit, existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
|
|
1755
1758
|
return _ts_generator$1(this, function(_state) {
|
|
1756
1759
|
switch(_state.label){
|
|
1757
1760
|
case 0:
|
|
@@ -1761,11 +1764,15 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1761
1764
|
,
|
|
1762
1765
|
5
|
|
1763
1766
|
]);
|
|
1767
|
+
disableEmit = extraOptions.disableEmit;
|
|
1764
1768
|
existedStats = compilation.getAsset(_this.fileName);
|
|
1765
|
-
if (existedStats) {
|
|
1769
|
+
if (existedStats && !isDev()) {
|
|
1766
1770
|
return [
|
|
1767
1771
|
2,
|
|
1768
|
-
|
|
1772
|
+
{
|
|
1773
|
+
stats: JSON.parse(existedStats.source.source().toString()),
|
|
1774
|
+
filename: _this.fileName
|
|
1775
|
+
}
|
|
1769
1776
|
];
|
|
1770
1777
|
}
|
|
1771
1778
|
_this__options = _this._options, tmp = _this__options.manifest, manifestOptions = tmp === void 0 ? {} : tmp;
|
|
@@ -1794,10 +1801,15 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1794
1801
|
stats = ret || stats;
|
|
1795
1802
|
_state.label = 3;
|
|
1796
1803
|
case 3:
|
|
1797
|
-
|
|
1804
|
+
if (!disableEmit) {
|
|
1805
|
+
compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
|
|
1806
|
+
}
|
|
1798
1807
|
return [
|
|
1799
1808
|
2,
|
|
1800
|
-
|
|
1809
|
+
{
|
|
1810
|
+
stats: stats,
|
|
1811
|
+
filename: _this.fileName
|
|
1812
|
+
}
|
|
1801
1813
|
];
|
|
1802
1814
|
case 4:
|
|
1803
1815
|
err = _state.sent();
|
|
@@ -2002,9 +2014,13 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2002
2014
|
_define_property(this, "_manifestManager", new ManifestManager());
|
|
2003
2015
|
_define_property(this, "_enable", true);
|
|
2004
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);
|
|
2005
2020
|
try {
|
|
2006
2021
|
this._options = options;
|
|
2007
2022
|
this._bundler = bundler;
|
|
2023
|
+
this.disableEmit = Boolean(process.env['MF_DISABLE_EMIT_STATS']);
|
|
2008
2024
|
this._statsManager.init(this._options, {
|
|
2009
2025
|
pluginVersion: pluginVersion,
|
|
2010
2026
|
bundler: bundler
|
|
@@ -2037,30 +2053,38 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2037
2053
|
// @ts-ignore use runtime variable in case peer dep not installed
|
|
2038
2054
|
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
2039
2055
|
}, /*#__PURE__*/ _async_to_generator(function() {
|
|
2040
|
-
var stats;
|
|
2041
2056
|
return _ts_generator(this, function(_state) {
|
|
2042
2057
|
switch(_state.label){
|
|
2043
2058
|
case 0:
|
|
2044
2059
|
if (!(_this1._options.manifest !== false)) return [
|
|
2045
2060
|
3,
|
|
2046
|
-
|
|
2061
|
+
3
|
|
2047
2062
|
];
|
|
2048
2063
|
return [
|
|
2049
2064
|
4,
|
|
2050
|
-
_this1._statsManager.generateStats(compiler, compilation
|
|
2065
|
+
_this1._statsManager.generateStats(compiler, compilation, {
|
|
2066
|
+
disableEmit: _this1.disableEmit
|
|
2067
|
+
})
|
|
2051
2068
|
];
|
|
2052
2069
|
case 1:
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
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
|
+
];
|
|
2063
2084
|
case 2:
|
|
2085
|
+
_this1.manifestInfo = _state.sent();
|
|
2086
|
+
_state.label = 3;
|
|
2087
|
+
case 3:
|
|
2064
2088
|
return [
|
|
2065
2089
|
2
|
|
2066
2090
|
];
|
|
@@ -2069,6 +2093,15 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2069
2093
|
}));
|
|
2070
2094
|
});
|
|
2071
2095
|
}
|
|
2096
|
+
},
|
|
2097
|
+
{
|
|
2098
|
+
key: "resourceInfo",
|
|
2099
|
+
get: function get() {
|
|
2100
|
+
return {
|
|
2101
|
+
stats: this.statsInfo,
|
|
2102
|
+
manifest: this.manifestInfo
|
|
2103
|
+
};
|
|
2104
|
+
}
|
|
2072
2105
|
}
|
|
2073
2106
|
]);
|
|
2074
2107
|
return StatsPlugin;
|
package/dist/package.json
CHANGED
|
@@ -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
|
|
18
|
+
generateManifest(options: GenerateManifestOptions, extraOptions?: {
|
|
19
|
+
disableEmit?: boolean;
|
|
20
|
+
}): Promise<ManifestInfo>;
|
|
18
21
|
}
|
|
19
22
|
export { ManifestManager };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { StatsBuildInfo,
|
|
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?: {
|
|
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
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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-
|
|
3
|
+
"version": "0.0.0-next-20240605083609",
|
|
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-
|
|
28
|
-
"@module-federation/dts-plugin": "0.0.0-next-
|
|
29
|
-
"@module-federation/managers": "0.0.0-next-
|
|
27
|
+
"@module-federation/sdk": "0.0.0-next-20240605083609",
|
|
28
|
+
"@module-federation/dts-plugin": "0.0.0-next-20240605083609",
|
|
29
|
+
"@module-federation/managers": "0.0.0-next-20240605083609"
|
|
30
30
|
},
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|