@module-federation/manifest 0.0.0-next-20240701075157 → 0.0.0-next-20240702090143
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 +60 -84
- package/dist/index.esm.js +59 -84
- package/dist/src/ManifestManager.d.ts +1 -4
- package/dist/src/StatsManager.d.ts +2 -5
- package/dist/src/StatsPlugin.d.ts +0 -5
- package/dist/src/index.d.ts +0 -1
- package/package.json +4 -4
- package/dist/src/types.d.ts +0 -13
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';
|
|
@@ -654,56 +656,67 @@ var ManifestManager = /*#__PURE__*/ function() {
|
|
|
654
656
|
{
|
|
655
657
|
key: "generateManifest",
|
|
656
658
|
value: function generateManifest(options) {
|
|
657
|
-
var extraOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
658
659
|
var _this = this;
|
|
659
660
|
return _async_to_generator$2(function() {
|
|
660
|
-
var compilation, publicPath, stats, compiler, bundler, additionalData,
|
|
661
|
+
var compilation, publicPath, stats, compiler, bundler, additionalData, manifest, prefetchInterface, prefetchFilePath, existPrefetch, content, manifestFileName, ret;
|
|
661
662
|
return _ts_generator$2(this, function(_state) {
|
|
662
663
|
switch(_state.label){
|
|
663
664
|
case 0:
|
|
664
665
|
compilation = options.compilation, publicPath = options.publicPath, stats = options.stats, compiler = options.compiler, bundler = options.bundler, additionalData = options.additionalData;
|
|
665
|
-
disableEmit = extraOptions.disableEmit;
|
|
666
666
|
manifest = _object_spread$2({}, stats);
|
|
667
|
-
manifest.exposes = stats.exposes.reduce(function(sum, cur) {
|
|
667
|
+
manifest.exposes = Object.keys(stats.exposes).reduce(function(sum, cur) {
|
|
668
|
+
var statsExpose = manifest.exposes[cur];
|
|
668
669
|
var expose = {
|
|
669
|
-
id:
|
|
670
|
-
name:
|
|
671
|
-
assets:
|
|
672
|
-
path:
|
|
670
|
+
id: statsExpose.id,
|
|
671
|
+
name: statsExpose.name,
|
|
672
|
+
assets: statsExpose.assets,
|
|
673
|
+
path: statsExpose.path
|
|
673
674
|
};
|
|
674
675
|
sum.push(expose);
|
|
675
676
|
return sum;
|
|
676
677
|
}, []);
|
|
677
|
-
manifest.shared = stats.shared.reduce(function(sum, cur) {
|
|
678
|
+
manifest.shared = Object.keys(stats.shared).reduce(function(sum, cur) {
|
|
679
|
+
var statsShared = manifest.shared[cur];
|
|
678
680
|
var shared = {
|
|
679
|
-
id:
|
|
680
|
-
name:
|
|
681
|
-
version:
|
|
682
|
-
singleton:
|
|
683
|
-
requiredVersion:
|
|
684
|
-
hash:
|
|
685
|
-
assets:
|
|
681
|
+
id: statsShared.id,
|
|
682
|
+
name: statsShared.name,
|
|
683
|
+
version: statsShared.version,
|
|
684
|
+
singleton: statsShared.singleton,
|
|
685
|
+
requiredVersion: statsShared.requiredVersion,
|
|
686
|
+
hash: statsShared.hash,
|
|
687
|
+
assets: statsShared.assets
|
|
686
688
|
};
|
|
687
689
|
sum.push(shared);
|
|
688
690
|
return sum;
|
|
689
691
|
}, []);
|
|
690
|
-
manifest.remotes = stats.remotes.reduce(function(sum, cur) {
|
|
692
|
+
manifest.remotes = Object.keys(stats.remotes).reduce(function(sum, cur) {
|
|
693
|
+
var statsRemote = manifest.remotes[cur];
|
|
691
694
|
// @ts-ignore version/entry will be added as follow
|
|
692
695
|
var remote = {
|
|
693
|
-
federationContainerName:
|
|
694
|
-
moduleName:
|
|
695
|
-
alias:
|
|
696
|
+
federationContainerName: statsRemote.federationContainerName,
|
|
697
|
+
moduleName: statsRemote.moduleName,
|
|
698
|
+
alias: statsRemote.alias
|
|
696
699
|
};
|
|
697
|
-
if ('entry' in
|
|
700
|
+
if ('entry' in statsRemote) {
|
|
698
701
|
// @ts-ignore
|
|
699
|
-
remote.entry =
|
|
700
|
-
} else if ('version' in
|
|
702
|
+
remote.entry = statsRemote.entry;
|
|
703
|
+
} else if ('version' in statsRemote) {
|
|
701
704
|
// @ts-ignore
|
|
702
|
-
remote.entry =
|
|
705
|
+
remote.entry = statsRemote.version;
|
|
703
706
|
}
|
|
704
707
|
sum.push(remote);
|
|
705
708
|
return sum;
|
|
706
709
|
}, []);
|
|
710
|
+
prefetchInterface = false;
|
|
711
|
+
prefetchFilePath = path__default["default"].resolve(compiler.options.context || process.cwd(), "node_modules/.mf/".concat(sdk.encodeName(stats.name), "/").concat(sdk.MFPrefetchCommon.fileName));
|
|
712
|
+
existPrefetch = fs__default["default"].existsSync(prefetchFilePath);
|
|
713
|
+
if (existPrefetch) {
|
|
714
|
+
content = fs__default["default"].readFileSync(prefetchFilePath).toString();
|
|
715
|
+
if (content) {
|
|
716
|
+
prefetchInterface = true;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
stats.metaData.prefetchInterface = prefetchInterface;
|
|
707
720
|
_this._manifest = manifest;
|
|
708
721
|
manifestFileName = _this.fileName;
|
|
709
722
|
if (!additionalData) return [
|
|
@@ -726,18 +739,12 @@ var ManifestManager = /*#__PURE__*/ function() {
|
|
|
726
739
|
_this._manifest = ret || _this._manifest;
|
|
727
740
|
_state.label = 2;
|
|
728
741
|
case 2:
|
|
729
|
-
|
|
730
|
-
compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
|
|
731
|
-
}
|
|
742
|
+
compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
|
|
732
743
|
if (isDev()) {
|
|
733
744
|
console.log(chalk__default["default"](_templateObject$1(), PLUGIN_IDENTIFIER, publicPath === 'auto' ? '{auto}/' : publicPath, manifestFileName));
|
|
734
745
|
}
|
|
735
746
|
return [
|
|
736
|
-
2
|
|
737
|
-
{
|
|
738
|
-
manifest: _this._manifest,
|
|
739
|
-
filename: manifestFileName
|
|
740
|
-
}
|
|
747
|
+
2
|
|
741
748
|
];
|
|
742
749
|
}
|
|
743
750
|
});
|
|
@@ -1787,11 +1794,10 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1787
1794
|
},
|
|
1788
1795
|
{
|
|
1789
1796
|
key: "generateStats",
|
|
1790
|
-
value: function generateStats(compiler, compilation) {
|
|
1791
|
-
var extraOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1797
|
+
value: function generateStats(compiler, compilation, extraOptions) {
|
|
1792
1798
|
var _this = this;
|
|
1793
1799
|
return _async_to_generator$1(function() {
|
|
1794
|
-
var
|
|
1800
|
+
var existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
|
|
1795
1801
|
return _ts_generator$1(this, function(_state) {
|
|
1796
1802
|
switch(_state.label){
|
|
1797
1803
|
case 0:
|
|
@@ -1801,15 +1807,11 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1801
1807
|
,
|
|
1802
1808
|
5
|
|
1803
1809
|
]);
|
|
1804
|
-
disableEmit = extraOptions.disableEmit;
|
|
1805
1810
|
existedStats = compilation.getAsset(_this.fileName);
|
|
1806
|
-
if (existedStats
|
|
1811
|
+
if (existedStats) {
|
|
1807
1812
|
return [
|
|
1808
1813
|
2,
|
|
1809
|
-
|
|
1810
|
-
stats: JSON.parse(existedStats.source.source().toString()),
|
|
1811
|
-
filename: _this.fileName
|
|
1812
|
-
}
|
|
1814
|
+
JSON.parse(existedStats.source.source().toString())
|
|
1813
1815
|
];
|
|
1814
1816
|
}
|
|
1815
1817
|
_this__options = _this._options, tmp = _this__options.manifest, manifestOptions = tmp === void 0 ? {} : tmp;
|
|
@@ -1838,15 +1840,10 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1838
1840
|
stats = ret || stats;
|
|
1839
1841
|
_state.label = 3;
|
|
1840
1842
|
case 3:
|
|
1841
|
-
|
|
1842
|
-
compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
|
|
1843
|
-
}
|
|
1843
|
+
compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
|
|
1844
1844
|
return [
|
|
1845
1845
|
2,
|
|
1846
|
-
|
|
1847
|
-
stats: stats,
|
|
1848
|
-
filename: _this.fileName
|
|
1849
|
-
}
|
|
1846
|
+
stats
|
|
1850
1847
|
];
|
|
1851
1848
|
case 4:
|
|
1852
1849
|
err = _state.sent();
|
|
@@ -2055,13 +2052,9 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2055
2052
|
_define_property(this, "_manifestManager", new ManifestManager());
|
|
2056
2053
|
_define_property(this, "_enable", true);
|
|
2057
2054
|
_define_property(this, "_bundler", 'webpack');
|
|
2058
|
-
_define_property(this, "statsInfo", void 0);
|
|
2059
|
-
_define_property(this, "manifestInfo", void 0);
|
|
2060
|
-
_define_property(this, "disableEmit", void 0);
|
|
2061
2055
|
try {
|
|
2062
2056
|
this._options = options;
|
|
2063
2057
|
this._bundler = bundler;
|
|
2064
|
-
this.disableEmit = Boolean(process.env['MF_DISABLE_EMIT_STATS']);
|
|
2065
2058
|
this._statsManager.init(this._options, {
|
|
2066
2059
|
pluginVersion: pluginVersion,
|
|
2067
2060
|
bundler: bundler
|
|
@@ -2094,38 +2087,30 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2094
2087
|
// @ts-ignore use runtime variable in case peer dep not installed
|
|
2095
2088
|
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
2096
2089
|
}, /*#__PURE__*/ _async_to_generator(function() {
|
|
2090
|
+
var stats;
|
|
2097
2091
|
return _ts_generator(this, function(_state) {
|
|
2098
2092
|
switch(_state.label){
|
|
2099
2093
|
case 0:
|
|
2100
2094
|
if (!(_this1._options.manifest !== false)) return [
|
|
2101
2095
|
3,
|
|
2102
|
-
|
|
2096
|
+
2
|
|
2103
2097
|
];
|
|
2104
2098
|
return [
|
|
2105
2099
|
4,
|
|
2106
|
-
_this1._statsManager.generateStats(compiler, compilation
|
|
2107
|
-
disableEmit: _this1.disableEmit
|
|
2108
|
-
})
|
|
2100
|
+
_this1._statsManager.generateStats(compiler, compilation)
|
|
2109
2101
|
];
|
|
2110
2102
|
case 1:
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
}, {
|
|
2122
|
-
disableEmit: _this1.disableEmit
|
|
2123
|
-
})
|
|
2124
|
-
];
|
|
2103
|
+
stats = _state.sent();
|
|
2104
|
+
_this1._manifestManager.generateManifest({
|
|
2105
|
+
compilation: compilation,
|
|
2106
|
+
stats: stats,
|
|
2107
|
+
publicPath: _this1._statsManager.getPublicPath(compiler),
|
|
2108
|
+
compiler: compiler,
|
|
2109
|
+
bundler: _this1._bundler,
|
|
2110
|
+
additionalData: _type_of(_this1._options.manifest) === 'object' ? _this1._options.manifest.additionalData : undefined
|
|
2111
|
+
});
|
|
2112
|
+
_state.label = 2;
|
|
2125
2113
|
case 2:
|
|
2126
|
-
_this1.manifestInfo = _state.sent();
|
|
2127
|
-
_state.label = 3;
|
|
2128
|
-
case 3:
|
|
2129
2114
|
return [
|
|
2130
2115
|
2
|
|
2131
2116
|
];
|
|
@@ -2134,15 +2119,6 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2134
2119
|
}));
|
|
2135
2120
|
});
|
|
2136
2121
|
}
|
|
2137
|
-
},
|
|
2138
|
-
{
|
|
2139
|
-
key: "resourceInfo",
|
|
2140
|
-
get: function get() {
|
|
2141
|
-
return {
|
|
2142
|
-
stats: this.statsInfo,
|
|
2143
|
-
manifest: this.manifestInfo
|
|
2144
|
-
};
|
|
2145
|
-
}
|
|
2146
2122
|
}
|
|
2147
2123
|
]);
|
|
2148
2124
|
return StatsPlugin;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
1
|
import path from 'path';
|
|
3
|
-
import
|
|
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
|
|
|
@@ -645,56 +646,67 @@ var ManifestManager = /*#__PURE__*/ function() {
|
|
|
645
646
|
{
|
|
646
647
|
key: "generateManifest",
|
|
647
648
|
value: function generateManifest(options) {
|
|
648
|
-
var extraOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
649
649
|
var _this = this;
|
|
650
650
|
return _async_to_generator$2(function() {
|
|
651
|
-
var compilation, publicPath, stats, compiler, bundler, additionalData,
|
|
651
|
+
var compilation, publicPath, stats, compiler, bundler, additionalData, manifest, prefetchInterface, prefetchFilePath, existPrefetch, content, manifestFileName, ret;
|
|
652
652
|
return _ts_generator$2(this, function(_state) {
|
|
653
653
|
switch(_state.label){
|
|
654
654
|
case 0:
|
|
655
655
|
compilation = options.compilation, publicPath = options.publicPath, stats = options.stats, compiler = options.compiler, bundler = options.bundler, additionalData = options.additionalData;
|
|
656
|
-
disableEmit = extraOptions.disableEmit;
|
|
657
656
|
manifest = _object_spread$2({}, stats);
|
|
658
|
-
manifest.exposes = stats.exposes.reduce(function(sum, cur) {
|
|
657
|
+
manifest.exposes = Object.keys(stats.exposes).reduce(function(sum, cur) {
|
|
658
|
+
var statsExpose = manifest.exposes[cur];
|
|
659
659
|
var expose = {
|
|
660
|
-
id:
|
|
661
|
-
name:
|
|
662
|
-
assets:
|
|
663
|
-
path:
|
|
660
|
+
id: statsExpose.id,
|
|
661
|
+
name: statsExpose.name,
|
|
662
|
+
assets: statsExpose.assets,
|
|
663
|
+
path: statsExpose.path
|
|
664
664
|
};
|
|
665
665
|
sum.push(expose);
|
|
666
666
|
return sum;
|
|
667
667
|
}, []);
|
|
668
|
-
manifest.shared = stats.shared.reduce(function(sum, cur) {
|
|
668
|
+
manifest.shared = Object.keys(stats.shared).reduce(function(sum, cur) {
|
|
669
|
+
var statsShared = manifest.shared[cur];
|
|
669
670
|
var shared = {
|
|
670
|
-
id:
|
|
671
|
-
name:
|
|
672
|
-
version:
|
|
673
|
-
singleton:
|
|
674
|
-
requiredVersion:
|
|
675
|
-
hash:
|
|
676
|
-
assets:
|
|
671
|
+
id: statsShared.id,
|
|
672
|
+
name: statsShared.name,
|
|
673
|
+
version: statsShared.version,
|
|
674
|
+
singleton: statsShared.singleton,
|
|
675
|
+
requiredVersion: statsShared.requiredVersion,
|
|
676
|
+
hash: statsShared.hash,
|
|
677
|
+
assets: statsShared.assets
|
|
677
678
|
};
|
|
678
679
|
sum.push(shared);
|
|
679
680
|
return sum;
|
|
680
681
|
}, []);
|
|
681
|
-
manifest.remotes = stats.remotes.reduce(function(sum, cur) {
|
|
682
|
+
manifest.remotes = Object.keys(stats.remotes).reduce(function(sum, cur) {
|
|
683
|
+
var statsRemote = manifest.remotes[cur];
|
|
682
684
|
// @ts-ignore version/entry will be added as follow
|
|
683
685
|
var remote = {
|
|
684
|
-
federationContainerName:
|
|
685
|
-
moduleName:
|
|
686
|
-
alias:
|
|
686
|
+
federationContainerName: statsRemote.federationContainerName,
|
|
687
|
+
moduleName: statsRemote.moduleName,
|
|
688
|
+
alias: statsRemote.alias
|
|
687
689
|
};
|
|
688
|
-
if ('entry' in
|
|
690
|
+
if ('entry' in statsRemote) {
|
|
689
691
|
// @ts-ignore
|
|
690
|
-
remote.entry =
|
|
691
|
-
} else if ('version' in
|
|
692
|
+
remote.entry = statsRemote.entry;
|
|
693
|
+
} else if ('version' in statsRemote) {
|
|
692
694
|
// @ts-ignore
|
|
693
|
-
remote.entry =
|
|
695
|
+
remote.entry = statsRemote.version;
|
|
694
696
|
}
|
|
695
697
|
sum.push(remote);
|
|
696
698
|
return sum;
|
|
697
699
|
}, []);
|
|
700
|
+
prefetchInterface = false;
|
|
701
|
+
prefetchFilePath = path.resolve(compiler.options.context || process.cwd(), "node_modules/.mf/".concat(encodeName(stats.name), "/").concat(MFPrefetchCommon.fileName));
|
|
702
|
+
existPrefetch = fs.existsSync(prefetchFilePath);
|
|
703
|
+
if (existPrefetch) {
|
|
704
|
+
content = fs.readFileSync(prefetchFilePath).toString();
|
|
705
|
+
if (content) {
|
|
706
|
+
prefetchInterface = true;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
stats.metaData.prefetchInterface = prefetchInterface;
|
|
698
710
|
_this._manifest = manifest;
|
|
699
711
|
manifestFileName = _this.fileName;
|
|
700
712
|
if (!additionalData) return [
|
|
@@ -717,18 +729,12 @@ var ManifestManager = /*#__PURE__*/ function() {
|
|
|
717
729
|
_this._manifest = ret || _this._manifest;
|
|
718
730
|
_state.label = 2;
|
|
719
731
|
case 2:
|
|
720
|
-
|
|
721
|
-
compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
|
|
722
|
-
}
|
|
732
|
+
compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
|
|
723
733
|
if (isDev()) {
|
|
724
734
|
console.log(chalk(_templateObject$1(), PLUGIN_IDENTIFIER, publicPath === 'auto' ? '{auto}/' : publicPath, manifestFileName));
|
|
725
735
|
}
|
|
726
736
|
return [
|
|
727
|
-
2
|
|
728
|
-
{
|
|
729
|
-
manifest: _this._manifest,
|
|
730
|
-
filename: manifestFileName
|
|
731
|
-
}
|
|
737
|
+
2
|
|
732
738
|
];
|
|
733
739
|
}
|
|
734
740
|
});
|
|
@@ -1778,11 +1784,10 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1778
1784
|
},
|
|
1779
1785
|
{
|
|
1780
1786
|
key: "generateStats",
|
|
1781
|
-
value: function generateStats(compiler, compilation) {
|
|
1782
|
-
var extraOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
1787
|
+
value: function generateStats(compiler, compilation, extraOptions) {
|
|
1783
1788
|
var _this = this;
|
|
1784
1789
|
return _async_to_generator$1(function() {
|
|
1785
|
-
var
|
|
1790
|
+
var existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
|
|
1786
1791
|
return _ts_generator$1(this, function(_state) {
|
|
1787
1792
|
switch(_state.label){
|
|
1788
1793
|
case 0:
|
|
@@ -1792,15 +1797,11 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1792
1797
|
,
|
|
1793
1798
|
5
|
|
1794
1799
|
]);
|
|
1795
|
-
disableEmit = extraOptions.disableEmit;
|
|
1796
1800
|
existedStats = compilation.getAsset(_this.fileName);
|
|
1797
|
-
if (existedStats
|
|
1801
|
+
if (existedStats) {
|
|
1798
1802
|
return [
|
|
1799
1803
|
2,
|
|
1800
|
-
|
|
1801
|
-
stats: JSON.parse(existedStats.source.source().toString()),
|
|
1802
|
-
filename: _this.fileName
|
|
1803
|
-
}
|
|
1804
|
+
JSON.parse(existedStats.source.source().toString())
|
|
1804
1805
|
];
|
|
1805
1806
|
}
|
|
1806
1807
|
_this__options = _this._options, tmp = _this__options.manifest, manifestOptions = tmp === void 0 ? {} : tmp;
|
|
@@ -1829,15 +1830,10 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1829
1830
|
stats = ret || stats;
|
|
1830
1831
|
_state.label = 3;
|
|
1831
1832
|
case 3:
|
|
1832
|
-
|
|
1833
|
-
compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
|
|
1834
|
-
}
|
|
1833
|
+
compilation.emitAsset(_this.fileName, new compiler.webpack.sources.RawSource(JSON.stringify(stats, null, 2)));
|
|
1835
1834
|
return [
|
|
1836
1835
|
2,
|
|
1837
|
-
|
|
1838
|
-
stats: stats,
|
|
1839
|
-
filename: _this.fileName
|
|
1840
|
-
}
|
|
1836
|
+
stats
|
|
1841
1837
|
];
|
|
1842
1838
|
case 4:
|
|
1843
1839
|
err = _state.sent();
|
|
@@ -2046,13 +2042,9 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2046
2042
|
_define_property(this, "_manifestManager", new ManifestManager());
|
|
2047
2043
|
_define_property(this, "_enable", true);
|
|
2048
2044
|
_define_property(this, "_bundler", 'webpack');
|
|
2049
|
-
_define_property(this, "statsInfo", void 0);
|
|
2050
|
-
_define_property(this, "manifestInfo", void 0);
|
|
2051
|
-
_define_property(this, "disableEmit", void 0);
|
|
2052
2045
|
try {
|
|
2053
2046
|
this._options = options;
|
|
2054
2047
|
this._bundler = bundler;
|
|
2055
|
-
this.disableEmit = Boolean(process.env['MF_DISABLE_EMIT_STATS']);
|
|
2056
2048
|
this._statsManager.init(this._options, {
|
|
2057
2049
|
pluginVersion: pluginVersion,
|
|
2058
2050
|
bundler: bundler
|
|
@@ -2085,38 +2077,30 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2085
2077
|
// @ts-ignore use runtime variable in case peer dep not installed
|
|
2086
2078
|
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
2087
2079
|
}, /*#__PURE__*/ _async_to_generator(function() {
|
|
2080
|
+
var stats;
|
|
2088
2081
|
return _ts_generator(this, function(_state) {
|
|
2089
2082
|
switch(_state.label){
|
|
2090
2083
|
case 0:
|
|
2091
2084
|
if (!(_this1._options.manifest !== false)) return [
|
|
2092
2085
|
3,
|
|
2093
|
-
|
|
2086
|
+
2
|
|
2094
2087
|
];
|
|
2095
2088
|
return [
|
|
2096
2089
|
4,
|
|
2097
|
-
_this1._statsManager.generateStats(compiler, compilation
|
|
2098
|
-
disableEmit: _this1.disableEmit
|
|
2099
|
-
})
|
|
2090
|
+
_this1._statsManager.generateStats(compiler, compilation)
|
|
2100
2091
|
];
|
|
2101
2092
|
case 1:
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
}, {
|
|
2113
|
-
disableEmit: _this1.disableEmit
|
|
2114
|
-
})
|
|
2115
|
-
];
|
|
2093
|
+
stats = _state.sent();
|
|
2094
|
+
_this1._manifestManager.generateManifest({
|
|
2095
|
+
compilation: compilation,
|
|
2096
|
+
stats: stats,
|
|
2097
|
+
publicPath: _this1._statsManager.getPublicPath(compiler),
|
|
2098
|
+
compiler: compiler,
|
|
2099
|
+
bundler: _this1._bundler,
|
|
2100
|
+
additionalData: _type_of(_this1._options.manifest) === 'object' ? _this1._options.manifest.additionalData : undefined
|
|
2101
|
+
});
|
|
2102
|
+
_state.label = 2;
|
|
2116
2103
|
case 2:
|
|
2117
|
-
_this1.manifestInfo = _state.sent();
|
|
2118
|
-
_state.label = 3;
|
|
2119
|
-
case 3:
|
|
2120
2104
|
return [
|
|
2121
2105
|
2
|
|
2122
2106
|
];
|
|
@@ -2125,15 +2109,6 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2125
2109
|
}));
|
|
2126
2110
|
});
|
|
2127
2111
|
}
|
|
2128
|
-
},
|
|
2129
|
-
{
|
|
2130
|
-
key: "resourceInfo",
|
|
2131
|
-
get: function get() {
|
|
2132
|
-
return {
|
|
2133
|
-
stats: this.statsInfo,
|
|
2134
|
-
manifest: this.manifestInfo
|
|
2135
|
-
};
|
|
2136
|
-
}
|
|
2137
2112
|
}
|
|
2138
2113
|
]);
|
|
2139
2114
|
return StatsPlugin;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Stats, Manifest, moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
2
|
import type { Compilation, Compiler } from 'webpack';
|
|
3
|
-
import { ManifestInfo } from './types';
|
|
4
3
|
interface GenerateManifestOptions {
|
|
5
4
|
compilation: Compilation;
|
|
6
5
|
stats: Stats;
|
|
@@ -15,8 +14,6 @@ declare class ManifestManager {
|
|
|
15
14
|
get manifest(): Manifest | undefined;
|
|
16
15
|
init(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
|
|
17
16
|
get fileName(): string;
|
|
18
|
-
generateManifest(options: GenerateManifestOptions
|
|
19
|
-
disableEmit?: boolean;
|
|
20
|
-
}): Promise<ManifestInfo>;
|
|
17
|
+
generateManifest(options: GenerateManifestOptions): Promise<void>;
|
|
21
18
|
}
|
|
22
19
|
export { ManifestManager };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { StatsBuildInfo, moduleFederationPlugin } from '@module-federation/sdk';
|
|
1
|
+
import { StatsBuildInfo, Stats, moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
2
|
import { Compilation, Compiler } from 'webpack';
|
|
3
|
-
import { StatsInfo } from './types';
|
|
4
3
|
declare class StatsManager {
|
|
5
4
|
private _options;
|
|
6
5
|
private _publicPath?;
|
|
@@ -22,9 +21,7 @@ declare class StatsManager {
|
|
|
22
21
|
pluginVersion: string;
|
|
23
22
|
bundler: 'webpack' | 'rspack';
|
|
24
23
|
}): void;
|
|
25
|
-
generateStats(compiler: Compiler, compilation: Compilation, extraOptions?: {
|
|
26
|
-
disableEmit?: boolean;
|
|
27
|
-
}): Promise<StatsInfo>;
|
|
24
|
+
generateStats(compiler: Compiler, compilation: Compilation, extraOptions?: {}): Promise<Stats>;
|
|
28
25
|
validate(compiler: Compiler): boolean;
|
|
29
26
|
}
|
|
30
27
|
export { StatsManager };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Compiler, WebpackPluginInstance } from 'webpack';
|
|
2
2
|
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
-
import { StatsInfo, ManifestInfo, ResourceInfo } from './types';
|
|
4
3
|
export declare class StatsPlugin implements WebpackPluginInstance {
|
|
5
4
|
readonly name = "StatsPlugin";
|
|
6
5
|
private _options;
|
|
@@ -8,13 +7,9 @@ export declare class StatsPlugin implements WebpackPluginInstance {
|
|
|
8
7
|
private _manifestManager;
|
|
9
8
|
private _enable;
|
|
10
9
|
private _bundler;
|
|
11
|
-
statsInfo?: StatsInfo;
|
|
12
|
-
manifestInfo?: ManifestInfo;
|
|
13
|
-
disableEmit?: boolean;
|
|
14
10
|
constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions, { pluginVersion, bundler, }: {
|
|
15
11
|
pluginVersion: string;
|
|
16
12
|
bundler: 'webpack' | 'rspack';
|
|
17
13
|
});
|
|
18
14
|
apply(compiler: Compiler): void;
|
|
19
|
-
get resourceInfo(): Partial<ResourceInfo>;
|
|
20
15
|
}
|
package/dist/src/index.d.ts
CHANGED
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-20240702090143",
|
|
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-20240702090143",
|
|
28
|
+
"@module-federation/dts-plugin": "0.0.0-next-20240702090143",
|
|
29
|
+
"@module-federation/managers": "0.0.0-next-20240702090143"
|
|
30
30
|
},
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|
package/dist/src/types.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
};
|