@module-federation/manifest 0.0.0-next-20240511031741 → 0.0.0-next-20240515062211
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 +146 -110
- package/dist/index.esm.js +146 -110
- 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.esm.js
CHANGED
|
@@ -4,8 +4,8 @@ import { StatsFileName, ManifestFileName, simpleJoinRemoteEntry, normalizeOption
|
|
|
4
4
|
import { isTSProject, retrieveTypesAssetsInfo } from '@module-federation/dts-plugin/core';
|
|
5
5
|
import { RemoteManager, SharedManager, ContainerManager, PKGJsonManager, utils } from '@module-federation/managers';
|
|
6
6
|
|
|
7
|
-
var PLUGIN_IDENTIFIER =
|
|
8
|
-
var HOT_UPDATE_SUFFIX =
|
|
7
|
+
var PLUGIN_IDENTIFIER = 'Module Federation Manifest Plugin';
|
|
8
|
+
var HOT_UPDATE_SUFFIX = '.hot-update';
|
|
9
9
|
|
|
10
10
|
function _array_like_to_array$2(arr, len) {
|
|
11
11
|
if (len == null || len > arr.length) len = arr.length;
|
|
@@ -139,8 +139,8 @@ function _templateObject$2() {
|
|
|
139
139
|
return data;
|
|
140
140
|
}
|
|
141
141
|
function getSharedModuleName(name) {
|
|
142
|
-
var _name_split = _sliced_to_array$2(name.split(
|
|
143
|
-
return sharedInfo.split(
|
|
142
|
+
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];
|
|
143
|
+
return sharedInfo.split('@').slice(0, -1).join('@');
|
|
144
144
|
}
|
|
145
145
|
function getAssetsByChunkIDs(compilation, chunkIDMap) {
|
|
146
146
|
var arrayChunks = Array.from(compilation.chunks);
|
|
@@ -159,10 +159,10 @@ function getAssetsByChunkIDs(compilation, chunkIDMap) {
|
|
|
159
159
|
});
|
|
160
160
|
if (chunk) {
|
|
161
161
|
_to_consumable_array(chunk.files).forEach(function(asset) {
|
|
162
|
-
if (asset.endsWith(
|
|
162
|
+
if (asset.endsWith('.css')) {
|
|
163
163
|
assetMap[key].css.add(asset);
|
|
164
164
|
} else {
|
|
165
|
-
if (process.env[
|
|
165
|
+
if (process.env['NODE_ENV'] === 'development') {
|
|
166
166
|
if (!asset.includes(HOT_UPDATE_SUFFIX)) {
|
|
167
167
|
assetMap[key].js.add(asset);
|
|
168
168
|
}
|
|
@@ -318,7 +318,7 @@ function getAssetsByChunk(chunk) {
|
|
|
318
318
|
var collectChunkFiles = function(targetChunk, type) {
|
|
319
319
|
_to_consumable_array(targetChunk.groupsIterable).forEach(function(chunkGroup) {
|
|
320
320
|
chunkGroup.getFiles().forEach(function(file) {
|
|
321
|
-
if (file.endsWith(
|
|
321
|
+
if (file.endsWith('.css')) {
|
|
322
322
|
assesSet.css[type].add(file);
|
|
323
323
|
} else {
|
|
324
324
|
assesSet.js[type].add(file);
|
|
@@ -326,16 +326,16 @@ function getAssetsByChunk(chunk) {
|
|
|
326
326
|
});
|
|
327
327
|
});
|
|
328
328
|
};
|
|
329
|
-
collectChunkFiles(chunk,
|
|
329
|
+
collectChunkFiles(chunk, 'sync');
|
|
330
330
|
_to_consumable_array(chunk.getAllAsyncChunks()).forEach(function(asyncChunk) {
|
|
331
331
|
asyncChunk.files.forEach(function(file) {
|
|
332
|
-
if (file.endsWith(
|
|
332
|
+
if (file.endsWith('.css')) {
|
|
333
333
|
assesSet.css.async.add(file);
|
|
334
334
|
} else {
|
|
335
335
|
assesSet.js.async.add(file);
|
|
336
336
|
}
|
|
337
337
|
});
|
|
338
|
-
collectChunkFiles(asyncChunk,
|
|
338
|
+
collectChunkFiles(asyncChunk, 'async');
|
|
339
339
|
});
|
|
340
340
|
var assets = {
|
|
341
341
|
js: {
|
|
@@ -358,10 +358,10 @@ function error(msg) {
|
|
|
358
358
|
throw new Error("[ ".concat(PLUGIN_IDENTIFIER, " ]: ").concat(msg));
|
|
359
359
|
}
|
|
360
360
|
function isDev() {
|
|
361
|
-
return process.env[
|
|
361
|
+
return process.env['NODE_ENV'] === 'development';
|
|
362
362
|
}
|
|
363
363
|
function getFileNameWithOutExt(str) {
|
|
364
|
-
return str.replace(path.extname(str),
|
|
364
|
+
return str.replace(path.extname(str), '');
|
|
365
365
|
}
|
|
366
366
|
function getFileName(manifestOptions) {
|
|
367
367
|
if (!manifestOptions) {
|
|
@@ -370,9 +370,9 @@ function getFileName(manifestOptions) {
|
|
|
370
370
|
manifestFileName: ManifestFileName
|
|
371
371
|
};
|
|
372
372
|
}
|
|
373
|
-
var filePath = typeof manifestOptions ===
|
|
374
|
-
var fileName = typeof manifestOptions ===
|
|
375
|
-
var JSON_EXT =
|
|
373
|
+
var filePath = typeof manifestOptions === 'boolean' ? '' : manifestOptions.filePath || '';
|
|
374
|
+
var fileName = typeof manifestOptions === 'boolean' ? '' : manifestOptions.fileName || '';
|
|
375
|
+
var JSON_EXT = '.json';
|
|
376
376
|
var addExt = function(name) {
|
|
377
377
|
if (name.endsWith(JSON_EXT)) {
|
|
378
378
|
return name;
|
|
@@ -383,7 +383,7 @@ function getFileName(manifestOptions) {
|
|
|
383
383
|
return name.replace(JSON_EXT, "".concat(suffix).concat(JSON_EXT));
|
|
384
384
|
};
|
|
385
385
|
var manifestFileName = fileName ? addExt(fileName) : ManifestFileName;
|
|
386
|
-
var statsFileName = fileName ? insertSuffix(manifestFileName,
|
|
386
|
+
var statsFileName = fileName ? insertSuffix(manifestFileName, '-stats') : StatsFileName;
|
|
387
387
|
return {
|
|
388
388
|
statsFileName: simpleJoinRemoteEntry(filePath, statsFileName),
|
|
389
389
|
manifestFileName: simpleJoinRemoteEntry(filePath, manifestFileName)
|
|
@@ -395,20 +395,20 @@ function getTypesMetaInfo(pluginOptions, context) {
|
|
|
395
395
|
compileInChildProcess: true
|
|
396
396
|
};
|
|
397
397
|
var defaultTypesMetaInfo = {
|
|
398
|
-
path:
|
|
399
|
-
name:
|
|
400
|
-
zip:
|
|
401
|
-
api:
|
|
398
|
+
path: '',
|
|
399
|
+
name: '',
|
|
400
|
+
zip: '',
|
|
401
|
+
api: ''
|
|
402
402
|
};
|
|
403
403
|
try {
|
|
404
404
|
var normalizedDtsOptions = normalizeOptions(isTSProject(pluginOptions.dts, context), {
|
|
405
405
|
generateTypes: defaultRemoteOptions,
|
|
406
406
|
consumeTypes: {}
|
|
407
|
-
},
|
|
407
|
+
}, 'mfOptions.dts')(pluginOptions.dts);
|
|
408
408
|
if (normalizedDtsOptions === false) {
|
|
409
409
|
return defaultTypesMetaInfo;
|
|
410
410
|
}
|
|
411
|
-
var normalizedRemote = normalizeOptions(true, defaultRemoteOptions,
|
|
411
|
+
var normalizedRemote = normalizeOptions(true, defaultRemoteOptions, 'mfOptions.dts.generateTypes')(normalizedDtsOptions.generateTypes);
|
|
412
412
|
if (normalizedRemote === false) {
|
|
413
413
|
return defaultTypesMetaInfo;
|
|
414
414
|
}
|
|
@@ -417,8 +417,8 @@ function getTypesMetaInfo(pluginOptions, context) {
|
|
|
417
417
|
moduleFederationConfig: pluginOptions
|
|
418
418
|
})), apiFileName = _retrieveTypesAssetsInfo.apiFileName, zipName = _retrieveTypesAssetsInfo.zipName;
|
|
419
419
|
return {
|
|
420
|
-
path:
|
|
421
|
-
name:
|
|
420
|
+
path: '',
|
|
421
|
+
name: '',
|
|
422
422
|
zip: zipName,
|
|
423
423
|
api: apiFileName
|
|
424
424
|
};
|
|
@@ -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];
|
|
@@ -690,10 +692,10 @@ var ManifestManager = /*#__PURE__*/ function() {
|
|
|
690
692
|
moduleName: statsRemote.moduleName,
|
|
691
693
|
alias: statsRemote.alias
|
|
692
694
|
};
|
|
693
|
-
if (
|
|
695
|
+
if ('entry' in statsRemote) {
|
|
694
696
|
// @ts-ignore
|
|
695
697
|
remote.entry = statsRemote.entry;
|
|
696
|
-
} else if (
|
|
698
|
+
} else if ('version' in statsRemote) {
|
|
697
699
|
// @ts-ignore
|
|
698
700
|
remote.entry = statsRemote.version;
|
|
699
701
|
}
|
|
@@ -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
|
-
|
|
727
|
+
if (!disableEmit) {
|
|
728
|
+
compilation.emitAsset(manifestFileName, new compiler.webpack.sources.RawSource(JSON.stringify(_this._manifest, null, 2)));
|
|
729
|
+
}
|
|
726
730
|
if (isDev()) {
|
|
727
|
-
console.log(chalk(_templateObject$1(), PLUGIN_IDENTIFIER, publicPath ===
|
|
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
|
});
|
|
@@ -860,7 +868,7 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
860
868
|
var bundler = param.bundler;
|
|
861
869
|
_class_call_check$2(this, ModuleHandler);
|
|
862
870
|
_define_property$2(this, "_options", void 0);
|
|
863
|
-
_define_property$2(this, "_bundler",
|
|
871
|
+
_define_property$2(this, "_bundler", 'webpack');
|
|
864
872
|
_define_property$2(this, "_modules", void 0);
|
|
865
873
|
_define_property$2(this, "_remoteManager", new RemoteManager());
|
|
866
874
|
_define_property$2(this, "_sharedManager", new SharedManager());
|
|
@@ -876,7 +884,7 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
876
884
|
{
|
|
877
885
|
key: "isRspack",
|
|
878
886
|
get: function get() {
|
|
879
|
-
return this._bundler ===
|
|
887
|
+
return this._bundler === 'rspack';
|
|
880
888
|
}
|
|
881
889
|
},
|
|
882
890
|
{
|
|
@@ -939,27 +947,27 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
939
947
|
}
|
|
940
948
|
};
|
|
941
949
|
var parseResolvedIdentifier = function(nameAndVersion) {
|
|
942
|
-
var name =
|
|
943
|
-
var version =
|
|
944
|
-
if (nameAndVersion.startsWith(
|
|
945
|
-
var splitInfo = nameAndVersion.split(
|
|
946
|
-
splitInfo[0] =
|
|
950
|
+
var name = '';
|
|
951
|
+
var version = '';
|
|
952
|
+
if (nameAndVersion.startsWith('@')) {
|
|
953
|
+
var splitInfo = nameAndVersion.split('@');
|
|
954
|
+
splitInfo[0] = '@';
|
|
947
955
|
name = splitInfo[0] + splitInfo[1];
|
|
948
956
|
version = splitInfo[2];
|
|
949
|
-
} else if (nameAndVersion.includes(
|
|
957
|
+
} else if (nameAndVersion.includes('@')) {
|
|
950
958
|
var ref;
|
|
951
|
-
ref = _sliced_to_array$1(nameAndVersion.split(
|
|
952
|
-
version = version.replace(/[\^~>|>=]/g,
|
|
959
|
+
ref = _sliced_to_array$1(nameAndVersion.split('@'), 2), name = ref[0], version = ref[1];
|
|
960
|
+
version = version.replace(/[\^~>|>=]/g, '');
|
|
953
961
|
}
|
|
954
962
|
return {
|
|
955
963
|
name: name,
|
|
956
964
|
version: version
|
|
957
965
|
};
|
|
958
966
|
};
|
|
959
|
-
if (moduleType ===
|
|
967
|
+
if (moduleType === 'provide-module') {
|
|
960
968
|
// identifier(rspack) = provide shared module (default) react@18.2.0 = /temp/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js
|
|
961
969
|
// identifier(webpack) = provide module (default) react@18.2.0 = /temp/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js
|
|
962
|
-
var data = identifier.split(
|
|
970
|
+
var data = identifier.split(' ');
|
|
963
971
|
var nameAndVersion = this.isRspack ? data[4] : data[3];
|
|
964
972
|
var _parseResolvedIdentifier = parseResolvedIdentifier(nameAndVersion), name = _parseResolvedIdentifier.name, version = _parseResolvedIdentifier.version;
|
|
965
973
|
if (name && version) {
|
|
@@ -967,13 +975,13 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
967
975
|
collectRelationshipMap(mod, name);
|
|
968
976
|
}
|
|
969
977
|
}
|
|
970
|
-
if (moduleType ===
|
|
978
|
+
if (moduleType === 'consume-shared-module') {
|
|
971
979
|
// identifier(rspack) = consume shared module (default) lodash/get@^4.17.21 (strict) (fallback: /temp/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/get.js)
|
|
972
980
|
// identifier(webpack) = consume-shared-module|default|react-dom|!=1.8...2...0|false|/temp/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/index.js|true|false
|
|
973
|
-
var SEPARATOR = this.isRspack ?
|
|
981
|
+
var SEPARATOR = this.isRspack ? ' ' : '|';
|
|
974
982
|
var data1 = identifier.split(SEPARATOR);
|
|
975
|
-
var pkgName =
|
|
976
|
-
var pkgVersion =
|
|
983
|
+
var pkgName = '';
|
|
984
|
+
var pkgVersion = '';
|
|
977
985
|
if (this.isRspack) {
|
|
978
986
|
var nameAndVersion1 = data1[4];
|
|
979
987
|
var res = parseResolvedIdentifier(nameAndVersion1);
|
|
@@ -982,14 +990,14 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
982
990
|
} else {
|
|
983
991
|
pkgName = data1[2];
|
|
984
992
|
var pkgVersionRange = data1[3];
|
|
985
|
-
pkgVersion =
|
|
986
|
-
if (pkgVersionRange.startsWith(
|
|
987
|
-
pkgVersion = data1[3].replace(
|
|
993
|
+
pkgVersion = '';
|
|
994
|
+
if (pkgVersionRange.startsWith('=')) {
|
|
995
|
+
pkgVersion = data1[3].replace('=', '');
|
|
988
996
|
} else {
|
|
989
997
|
if (sharedManagerNormalizedOptions[pkgName]) {
|
|
990
998
|
pkgVersion = sharedManagerNormalizedOptions[pkgName].version;
|
|
991
999
|
} else {
|
|
992
|
-
var fullPkgName = pkgName.split(
|
|
1000
|
+
var fullPkgName = pkgName.split('/').slice(0, -1).join('/');
|
|
993
1001
|
// pkgName: react-dom/
|
|
994
1002
|
if (sharedManagerNormalizedOptions["".concat(fullPkgName, "/")]) {
|
|
995
1003
|
if (sharedManagerNormalizedOptions[fullPkgName]) {
|
|
@@ -1018,14 +1026,14 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
1018
1026
|
}
|
|
1019
1027
|
var remoteManagerNormalizedOptions = this._remoteManager.normalizedOptions;
|
|
1020
1028
|
// identifier = remote (default) webpack/container/reference/app2 ./Button
|
|
1021
|
-
var data = identifier.split(
|
|
1029
|
+
var data = identifier.split(' ');
|
|
1022
1030
|
if (data.length === 4) {
|
|
1023
|
-
var moduleName = data[3].replace(
|
|
1024
|
-
var remoteAlias = data[2].replace(
|
|
1031
|
+
var moduleName = data[3].replace('./', '');
|
|
1032
|
+
var remoteAlias = data[2].replace('webpack/container/reference/', '');
|
|
1025
1033
|
var normalizedRemote = remoteManagerNormalizedOptions[remoteAlias];
|
|
1026
1034
|
var basicRemote = {
|
|
1027
1035
|
alias: normalizedRemote.alias,
|
|
1028
|
-
consumingFederationContainerName: this._options.name ||
|
|
1036
|
+
consumingFederationContainerName: this._options.name || '',
|
|
1029
1037
|
federationContainerName: remoteManagerNormalizedOptions[remoteAlias].name,
|
|
1030
1038
|
moduleName: moduleName,
|
|
1031
1039
|
// @ts-ignore to deduplicate
|
|
@@ -1035,7 +1043,7 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
1035
1043
|
return;
|
|
1036
1044
|
}
|
|
1037
1045
|
var remote;
|
|
1038
|
-
if (
|
|
1046
|
+
if ('version' in normalizedRemote) {
|
|
1039
1047
|
remote = _object_spread_props$1(_object_spread$1({}, basicRemote), {
|
|
1040
1048
|
version: normalizedRemote.version
|
|
1041
1049
|
});
|
|
@@ -1053,7 +1061,7 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
1053
1061
|
var exposeModName = _this.isRspack ? moduleName : resolvedModule;
|
|
1054
1062
|
if (userRequest && exposeModName && remotesConsumerMap[userRequest]) {
|
|
1055
1063
|
// @ts-ignore to deduplicate
|
|
1056
|
-
remotesConsumerMap[userRequest].usedIn.add(exposeModName.replace(
|
|
1064
|
+
remotesConsumerMap[userRequest].usedIn.add(exposeModName.replace('./', ''));
|
|
1057
1065
|
}
|
|
1058
1066
|
});
|
|
1059
1067
|
}
|
|
@@ -1068,10 +1076,10 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
1068
1076
|
return;
|
|
1069
1077
|
}
|
|
1070
1078
|
// identifier: container entry (default) [[".",{"import":["./src/routes/page.tsx"],"name":"__federation_expose_default_export"}]]'
|
|
1071
|
-
var data = identifier.split(
|
|
1079
|
+
var data = identifier.split(' ');
|
|
1072
1080
|
JSON.parse(data[3]).forEach(function(param) {
|
|
1073
1081
|
var _param = _sliced_to_array$1(param, 2), prefixedName = _param[0], file = _param[1];
|
|
1074
|
-
var exposeModuleName = prefixedName.replace(
|
|
1082
|
+
var exposeModuleName = prefixedName.replace('./', '');
|
|
1075
1083
|
// TODO: support multiple import
|
|
1076
1084
|
exposesMap[getFileNameWithOutExt(file.import[0])] = {
|
|
1077
1085
|
path: prefixedName,
|
|
@@ -1104,17 +1112,17 @@ var ModuleHandler = /*#__PURE__*/ function() {
|
|
|
1104
1112
|
var sharedMap = {};
|
|
1105
1113
|
var isSharedModule = function(moduleType) {
|
|
1106
1114
|
return Boolean(moduleType && [
|
|
1107
|
-
|
|
1108
|
-
|
|
1115
|
+
'provide-module',
|
|
1116
|
+
'consume-shared-module'
|
|
1109
1117
|
].includes(moduleType));
|
|
1110
1118
|
};
|
|
1111
1119
|
var isContainerModule = function(identifier) {
|
|
1112
|
-
var data = identifier.split(
|
|
1113
|
-
return Boolean(data[0] ===
|
|
1120
|
+
var data = identifier.split(' ');
|
|
1121
|
+
return Boolean(data[0] === 'container' && data[1] === 'entry');
|
|
1114
1122
|
};
|
|
1115
1123
|
var isRemoteModule = function(identifier) {
|
|
1116
|
-
var data = identifier.split(
|
|
1117
|
-
return data[0] ===
|
|
1124
|
+
var data = identifier.split(' ');
|
|
1125
|
+
return data[0] === 'remote';
|
|
1118
1126
|
};
|
|
1119
1127
|
// handle remote/expose
|
|
1120
1128
|
this._modules.forEach(function(mod) {
|
|
@@ -1421,7 +1429,7 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1421
1429
|
_define_property$1(this, "_options", {});
|
|
1422
1430
|
_define_property$1(this, "_publicPath", void 0);
|
|
1423
1431
|
_define_property$1(this, "_pluginVersion", void 0);
|
|
1424
|
-
_define_property$1(this, "_bundler",
|
|
1432
|
+
_define_property$1(this, "_bundler", 'webpack');
|
|
1425
1433
|
_define_property$1(this, "_containerManager", new ContainerManager());
|
|
1426
1434
|
_define_property$1(this, "_remoteManager", new RemoteManager());
|
|
1427
1435
|
_define_property$1(this, "_sharedManager", new SharedManager());
|
|
@@ -1434,7 +1442,7 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1434
1442
|
var pkg = this._pkgJsonManager.readPKGJson(process.cwd());
|
|
1435
1443
|
return {
|
|
1436
1444
|
buildVersion: utils.getBuildVersion(),
|
|
1437
|
-
buildName: utils.getBuildName() || pkg[
|
|
1445
|
+
buildName: utils.getBuildName() || pkg['name']
|
|
1438
1446
|
};
|
|
1439
1447
|
}
|
|
1440
1448
|
},
|
|
@@ -1453,32 +1461,32 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1453
1461
|
var type = this._pkgJsonManager.getExposeGarfishModuleType(context || process.cwd());
|
|
1454
1462
|
var getRemoteEntryName = function() {
|
|
1455
1463
|
if (!_this._containerManager.enable) {
|
|
1456
|
-
return
|
|
1464
|
+
return '';
|
|
1457
1465
|
}
|
|
1458
|
-
assert(name,
|
|
1466
|
+
assert(name, 'name is required');
|
|
1459
1467
|
var remoteEntryPoint = compilation.entrypoints.get(name);
|
|
1460
|
-
assert(remoteEntryPoint,
|
|
1468
|
+
assert(remoteEntryPoint, 'Can not get remoteEntry entryPoint!');
|
|
1461
1469
|
var remoteEntryNameChunk = compilation.namedChunks.get(name);
|
|
1462
|
-
assert(remoteEntryNameChunk,
|
|
1470
|
+
assert(remoteEntryNameChunk, 'Can not get remoteEntry chunk!');
|
|
1463
1471
|
var files = Array.from(remoteEntryNameChunk.files).filter(function(f) {
|
|
1464
|
-
return !f.includes(HOT_UPDATE_SUFFIX);
|
|
1472
|
+
return !f.includes(HOT_UPDATE_SUFFIX) && !f.endsWith('.css');
|
|
1465
1473
|
});
|
|
1466
|
-
assert(files.length === 1, "remoteEntry chunk should not have multiple files!, current files: ".concat(files.join(
|
|
1474
|
+
assert(files.length === 1, "remoteEntry chunk should not have multiple files!, current files: ".concat(files.join(',')));
|
|
1467
1475
|
var remoteEntryName = files[0];
|
|
1468
1476
|
return remoteEntryName;
|
|
1469
1477
|
};
|
|
1470
1478
|
var globalName = this._containerManager.globalEntryName;
|
|
1471
1479
|
assert(globalName, 'Can not get library.name, please ensure you have set library.name and the type is "string" !');
|
|
1472
|
-
assert(this._pluginVersion,
|
|
1480
|
+
assert(this._pluginVersion, 'Can not get pluginVersion, please ensure you have set pluginVersion !');
|
|
1473
1481
|
var metaData = {
|
|
1474
1482
|
name: name,
|
|
1475
1483
|
type: type,
|
|
1476
1484
|
buildInfo: buildInfo,
|
|
1477
1485
|
remoteEntry: {
|
|
1478
1486
|
name: getRemoteEntryName(),
|
|
1479
|
-
path:
|
|
1480
|
-
// same as the types supported by runtime, currently only global/var/script is supported
|
|
1481
|
-
type:
|
|
1487
|
+
path: '',
|
|
1488
|
+
// same as the types supported by runtime, currently only global/var/script/cjs:webpack is supported
|
|
1489
|
+
type: 'global'
|
|
1482
1490
|
},
|
|
1483
1491
|
types: getTypesMetaInfo(this._options, compiler.context),
|
|
1484
1492
|
globalName: globalName,
|
|
@@ -1497,10 +1505,10 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1497
1505
|
return false;
|
|
1498
1506
|
}
|
|
1499
1507
|
var array = [
|
|
1500
|
-
module.name.includes(
|
|
1501
|
-
module.name.includes(
|
|
1502
|
-
module.name.includes(
|
|
1503
|
-
module.name.includes(
|
|
1508
|
+
module.name.includes('container entry'),
|
|
1509
|
+
module.name.includes('remote '),
|
|
1510
|
+
module.name.includes('shared module '),
|
|
1511
|
+
module.name.includes('provide module ')
|
|
1504
1512
|
];
|
|
1505
1513
|
return array.some(function(item) {
|
|
1506
1514
|
return item;
|
|
@@ -1516,7 +1524,7 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1516
1524
|
var exposeFileNameImportMap = this._containerManager.exposeFileNameImportMap;
|
|
1517
1525
|
var assets = {};
|
|
1518
1526
|
chunks.forEach(function(chunk) {
|
|
1519
|
-
if (typeof chunk.name ===
|
|
1527
|
+
if (typeof chunk.name === 'string' && exposeFileNameImportMap[chunk.name]) {
|
|
1520
1528
|
// TODO: support multiple import
|
|
1521
1529
|
var exposeKey = exposeFileNameImportMap[chunk.name][0];
|
|
1522
1530
|
assets[getFileNameWithOutExt(exposeKey)] = getAssetsByChunk(chunk);
|
|
@@ -1533,7 +1541,7 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1533
1541
|
return false;
|
|
1534
1542
|
}
|
|
1535
1543
|
var array = [
|
|
1536
|
-
module.name.includes(
|
|
1544
|
+
module.name.includes('consume shared module ')
|
|
1537
1545
|
];
|
|
1538
1546
|
return array.some(function(item) {
|
|
1539
1547
|
return item;
|
|
@@ -1612,7 +1620,7 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1612
1620
|
remotes: [],
|
|
1613
1621
|
exposes: []
|
|
1614
1622
|
};
|
|
1615
|
-
if (typeof manifestOptions ===
|
|
1623
|
+
if (typeof manifestOptions === 'object' && manifestOptions.disableAssetsAnalyze) {
|
|
1616
1624
|
remotes = _this._remoteManager.statsRemoteWithEmptyUsedIn;
|
|
1617
1625
|
stats.remotes = remotes;
|
|
1618
1626
|
return [
|
|
@@ -1633,9 +1641,9 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1633
1641
|
chunks: false,
|
|
1634
1642
|
reasons: true
|
|
1635
1643
|
};
|
|
1636
|
-
if (_this._bundler ===
|
|
1637
|
-
statsOptions[
|
|
1638
|
-
statsOptions[
|
|
1644
|
+
if (_this._bundler === 'webpack') {
|
|
1645
|
+
statsOptions['cached'] = true;
|
|
1646
|
+
statsOptions['cachedModules'] = true;
|
|
1639
1647
|
}
|
|
1640
1648
|
webpackStats = liveStats.toJson(statsOptions);
|
|
1641
1649
|
filteredModules = _this._getFilteredModules(webpackStats);
|
|
@@ -1745,10 +1753,11 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1745
1753
|
},
|
|
1746
1754
|
{
|
|
1747
1755
|
key: "generateStats",
|
|
1748
|
-
value: function generateStats(compiler, compilation
|
|
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 [
|
|
@@ -1772,7 +1782,7 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1772
1782
|
];
|
|
1773
1783
|
case 1:
|
|
1774
1784
|
stats = _state.sent();
|
|
1775
|
-
if (!(typeof manifestOptions ===
|
|
1785
|
+
if (!(typeof manifestOptions === 'object' && manifestOptions.additionalData)) return [
|
|
1776
1786
|
3,
|
|
1777
1787
|
3
|
|
1778
1788
|
];
|
|
@@ -1791,10 +1801,15 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1791
1801
|
stats = ret || stats;
|
|
1792
1802
|
_state.label = 3;
|
|
1793
1803
|
case 3:
|
|
1794
|
-
|
|
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
|
-
|
|
1809
|
+
{
|
|
1810
|
+
stats: stats,
|
|
1811
|
+
filename: _this.fileName
|
|
1812
|
+
}
|
|
1798
1813
|
];
|
|
1799
1814
|
case 4:
|
|
1800
1815
|
err = _state.sent();
|
|
@@ -1812,10 +1827,10 @@ var StatsManager = /*#__PURE__*/ function() {
|
|
|
1812
1827
|
key: "validate",
|
|
1813
1828
|
value: function validate(compiler) {
|
|
1814
1829
|
var _compiler_options = compiler.options, publicPath = _compiler_options.output.publicPath;
|
|
1815
|
-
if (typeof publicPath !==
|
|
1830
|
+
if (typeof publicPath !== 'string') {
|
|
1816
1831
|
console.warn(chalk(_templateObject(), PLUGIN_IDENTIFIER, publicPath));
|
|
1817
1832
|
return false;
|
|
1818
|
-
} else if (publicPath ===
|
|
1833
|
+
} else if (publicPath === 'auto') {
|
|
1819
1834
|
console.warn(chalk(_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
|
|
1820
1835
|
return true;
|
|
1821
1836
|
}
|
|
@@ -1993,15 +2008,19 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
1993
2008
|
function StatsPlugin(options, param) {
|
|
1994
2009
|
var pluginVersion = param.pluginVersion, bundler = param.bundler;
|
|
1995
2010
|
_class_call_check(this, StatsPlugin);
|
|
1996
|
-
_define_property(this, "name",
|
|
2011
|
+
_define_property(this, "name", 'StatsPlugin');
|
|
1997
2012
|
_define_property(this, "_options", {});
|
|
1998
2013
|
_define_property(this, "_statsManager", new StatsManager());
|
|
1999
2014
|
_define_property(this, "_manifestManager", new ManifestManager());
|
|
2000
2015
|
_define_property(this, "_enable", true);
|
|
2001
|
-
_define_property(this, "_bundler",
|
|
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
|
|
@@ -2027,37 +2046,45 @@ var StatsPlugin = /*#__PURE__*/ function() {
|
|
|
2027
2046
|
if (!res) {
|
|
2028
2047
|
return;
|
|
2029
2048
|
}
|
|
2030
|
-
compiler.hooks.thisCompilation.tap(
|
|
2049
|
+
compiler.hooks.thisCompilation.tap('generateStats', function(compilation) {
|
|
2031
2050
|
var _this1 = _this;
|
|
2032
2051
|
compilation.hooks.processAssets.tapPromise({
|
|
2033
|
-
name:
|
|
2052
|
+
name: 'generateStats',
|
|
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
|
-
|
|
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
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
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;
|