@module-federation/manifest 0.0.0-next-20240401022607 → 0.0.0-next-20240401040901

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
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var chalk = require('chalk');
6
6
  var path = require('path');
7
7
  var sdk = require('@module-federation/sdk');
8
+ var dtsKit = require('@module-federation/dts-kit');
8
9
  var managers = require('@module-federation/managers');
9
10
 
10
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -26,6 +27,19 @@ function _array_with_holes$2(arr) {
26
27
  function _array_without_holes(arr) {
27
28
  if (Array.isArray(arr)) return _array_like_to_array$2(arr);
28
29
  }
30
+ function _define_property$4(obj, key, value) {
31
+ if (key in obj) {
32
+ Object.defineProperty(obj, key, {
33
+ value: value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true
37
+ });
38
+ } else {
39
+ obj[key] = value;
40
+ }
41
+ return obj;
42
+ }
29
43
  function _iterable_to_array(iter) {
30
44
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
31
45
  }
@@ -59,9 +73,58 @@ function _non_iterable_rest$2() {
59
73
  function _non_iterable_spread() {
60
74
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
61
75
  }
76
+ function _object_spread$3(target) {
77
+ for(var i = 1; i < arguments.length; i++){
78
+ var source = arguments[i] != null ? arguments[i] : {};
79
+ var ownKeys = Object.keys(source);
80
+ if (typeof Object.getOwnPropertySymbols === "function") {
81
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
82
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
83
+ }));
84
+ }
85
+ ownKeys.forEach(function(key) {
86
+ _define_property$4(target, key, source[key]);
87
+ });
88
+ }
89
+ return target;
90
+ }
91
+ function ownKeys$2(object, enumerableOnly) {
92
+ var keys = Object.keys(object);
93
+ if (Object.getOwnPropertySymbols) {
94
+ var symbols = Object.getOwnPropertySymbols(object);
95
+ if (enumerableOnly) {
96
+ symbols = symbols.filter(function(sym) {
97
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
98
+ });
99
+ }
100
+ keys.push.apply(keys, symbols);
101
+ }
102
+ return keys;
103
+ }
104
+ function _object_spread_props$2(target, source) {
105
+ source = source != null ? source : {};
106
+ if (Object.getOwnPropertyDescriptors) {
107
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
108
+ } else {
109
+ ownKeys$2(Object(source)).forEach(function(key) {
110
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
111
+ });
112
+ }
113
+ return target;
114
+ }
62
115
  function _sliced_to_array$2(arr, i) {
63
116
  return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
64
117
  }
118
+ function _tagged_template_literal$2(strings, raw) {
119
+ if (!raw) {
120
+ raw = strings.slice(0);
121
+ }
122
+ return Object.freeze(Object.defineProperties(strings, {
123
+ raw: {
124
+ value: Object.freeze(raw)
125
+ }
126
+ }));
127
+ }
65
128
  function _to_consumable_array(arr) {
66
129
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread();
67
130
  }
@@ -73,6 +136,17 @@ function _unsupported_iterable_to_array$2(o, minLen) {
73
136
  if (n === "Map" || n === "Set") return Array.from(n);
74
137
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
75
138
  }
139
+ function _templateObject$2() {
140
+ var data = _tagged_template_literal$2([
141
+ "{bold {yellow [ ",
142
+ " ]: getTypesMetaInfo failed, it will use the default types meta info, and the errors as belows: ",
143
+ " }}"
144
+ ]);
145
+ _templateObject$2 = function _templateObject() {
146
+ return data;
147
+ };
148
+ return data;
149
+ }
76
150
  function getSharedModuleName(name) {
77
151
  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];
78
152
  return sharedInfo.split("@").slice(0, -1).join("@");
@@ -324,6 +398,45 @@ function getFileName(manifestOptions) {
324
398
  manifestFileName: sdk.simpleJoinRemoteEntry(filePath, manifestFileName)
325
399
  };
326
400
  }
401
+ function getTypesMetaInfo(pluginOptions, context) {
402
+ var defaultRemoteOptions = {
403
+ generateAPITypes: true,
404
+ compileInChildProcess: true
405
+ };
406
+ var defaultTypesMetaInfo = {
407
+ path: "",
408
+ name: "",
409
+ zip: "",
410
+ api: ""
411
+ };
412
+ try {
413
+ var normalizedDtsOptions = sdk.normalizeOptions(true, {
414
+ disableGenerateTypes: false,
415
+ remote: defaultRemoteOptions,
416
+ host: {}
417
+ }, "mfOptions.dts")(pluginOptions.dts);
418
+ if (normalizedDtsOptions === false) {
419
+ return defaultTypesMetaInfo;
420
+ }
421
+ var normalizedRemote = sdk.normalizeOptions(true, defaultRemoteOptions, "mfOptions.dts.remote")(normalizedDtsOptions.remote);
422
+ if (normalizedRemote === false) {
423
+ return defaultTypesMetaInfo;
424
+ }
425
+ var _retrieveTypesAssetsInfo = dtsKit.retrieveTypesAssetsInfo(_object_spread_props$2(_object_spread$3({}, normalizedRemote), {
426
+ context: context,
427
+ moduleFederationConfig: pluginOptions
428
+ })), apiFileName = _retrieveTypesAssetsInfo.apiFileName, zipName = _retrieveTypesAssetsInfo.zipName;
429
+ return {
430
+ path: "",
431
+ name: "",
432
+ zip: zipName,
433
+ api: apiFileName
434
+ };
435
+ } catch (err) {
436
+ console.warn(chalk__default["default"](_templateObject$2(), PLUGIN_IDENTIFIER, err));
437
+ return defaultTypesMetaInfo;
438
+ }
439
+ }
327
440
 
328
441
  function _class_call_check$3(instance, Constructor) {
329
442
  if (!(instance instanceof Constructor)) {
@@ -1136,7 +1249,7 @@ function _ts_generator$1(thisArg, body) {
1136
1249
  }
1137
1250
  function _templateObject() {
1138
1251
  var data = _tagged_template_literal([
1139
- "{bold {red [ ",
1252
+ "{bold {yellow [ ",
1140
1253
  " ]: Manifest will not generate, because publicPath can only be string, but got '",
1141
1254
  "' }}"
1142
1255
  ]);
@@ -1147,7 +1260,7 @@ function _templateObject() {
1147
1260
  }
1148
1261
  function _templateObject1() {
1149
1262
  var data = _tagged_template_literal([
1150
- "{bold {red [ ",
1263
+ "{bold {yellow [ ",
1151
1264
  " ]: Manifest will not generate, because publicPath can only be absolute path, but got '",
1152
1265
  "'}}"
1153
1266
  ]);
@@ -1221,10 +1334,7 @@ var StatsManager = /*#__PURE__*/ function() {
1221
1334
  // same as the types supported by runtime, currently only global/var/script is supported
1222
1335
  type: "global"
1223
1336
  },
1224
- types: {
1225
- name: "",
1226
- path: ""
1227
- },
1337
+ types: getTypesMetaInfo(this._options, compiler.context),
1228
1338
  globalName: globalName,
1229
1339
  pluginVersion: this._pluginVersion
1230
1340
  };
@@ -1492,7 +1602,7 @@ var StatsManager = /*#__PURE__*/ function() {
1492
1602
  value: function generateStats(compiler, compilation, extraOptions) {
1493
1603
  var _this = this;
1494
1604
  return _async_to_generator$1(function() {
1495
- var _this__options, tmp, manifestOptions, stats, ret, err;
1605
+ var existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
1496
1606
  return _ts_generator$1(this, function(_state) {
1497
1607
  switch(_state.label){
1498
1608
  case 0:
@@ -1502,6 +1612,13 @@ var StatsManager = /*#__PURE__*/ function() {
1502
1612
  ,
1503
1613
  5
1504
1614
  ]);
1615
+ existedStats = compilation.getAsset(_this.fileName);
1616
+ if (existedStats) {
1617
+ return [
1618
+ 2,
1619
+ JSON.parse(existedStats.source.source().toString())
1620
+ ];
1621
+ }
1505
1622
  _this__options = _this._options, tmp = _this__options.manifest, manifestOptions = tmp === void 0 ? {} : tmp;
1506
1623
  return [
1507
1624
  4,
@@ -1550,10 +1667,10 @@ var StatsManager = /*#__PURE__*/ function() {
1550
1667
  value: function validate(compiler) {
1551
1668
  var _compiler_options = compiler.options, publicPath = _compiler_options.output.publicPath;
1552
1669
  if (typeof publicPath !== "string") {
1553
- console.error(chalk__default["default"](_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1670
+ console.warn(chalk__default["default"](_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1554
1671
  return false;
1555
1672
  } else if (publicPath === "auto") {
1556
- console.error(chalk__default["default"](_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1673
+ console.warn(chalk__default["default"](_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1557
1674
  return false;
1558
1675
  }
1559
1676
  return true;
package/dist/index.esm.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import chalk from 'chalk';
2
2
  import path from 'path';
3
- import { StatsFileName, ManifestFileName, simpleJoinRemoteEntry } from '@module-federation/sdk';
3
+ import { StatsFileName, ManifestFileName, simpleJoinRemoteEntry, normalizeOptions } from '@module-federation/sdk';
4
+ import { retrieveTypesAssetsInfo } from '@module-federation/dts-kit';
4
5
  import { RemoteManager, SharedManager, ContainerManager, PKGJsonManager, utils } from '@module-federation/managers';
5
6
 
6
7
  var PLUGIN_IDENTIFIER = "Module Federation Manifest Plugin";
@@ -17,6 +18,19 @@ function _array_with_holes$2(arr) {
17
18
  function _array_without_holes(arr) {
18
19
  if (Array.isArray(arr)) return _array_like_to_array$2(arr);
19
20
  }
21
+ function _define_property$4(obj, key, value) {
22
+ if (key in obj) {
23
+ Object.defineProperty(obj, key, {
24
+ value: value,
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true
28
+ });
29
+ } else {
30
+ obj[key] = value;
31
+ }
32
+ return obj;
33
+ }
20
34
  function _iterable_to_array(iter) {
21
35
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
22
36
  }
@@ -50,9 +64,58 @@ function _non_iterable_rest$2() {
50
64
  function _non_iterable_spread() {
51
65
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
52
66
  }
67
+ function _object_spread$3(target) {
68
+ for(var i = 1; i < arguments.length; i++){
69
+ var source = arguments[i] != null ? arguments[i] : {};
70
+ var ownKeys = Object.keys(source);
71
+ if (typeof Object.getOwnPropertySymbols === "function") {
72
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
73
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
74
+ }));
75
+ }
76
+ ownKeys.forEach(function(key) {
77
+ _define_property$4(target, key, source[key]);
78
+ });
79
+ }
80
+ return target;
81
+ }
82
+ function ownKeys$2(object, enumerableOnly) {
83
+ var keys = Object.keys(object);
84
+ if (Object.getOwnPropertySymbols) {
85
+ var symbols = Object.getOwnPropertySymbols(object);
86
+ if (enumerableOnly) {
87
+ symbols = symbols.filter(function(sym) {
88
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
89
+ });
90
+ }
91
+ keys.push.apply(keys, symbols);
92
+ }
93
+ return keys;
94
+ }
95
+ function _object_spread_props$2(target, source) {
96
+ source = source != null ? source : {};
97
+ if (Object.getOwnPropertyDescriptors) {
98
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
99
+ } else {
100
+ ownKeys$2(Object(source)).forEach(function(key) {
101
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
102
+ });
103
+ }
104
+ return target;
105
+ }
53
106
  function _sliced_to_array$2(arr, i) {
54
107
  return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
55
108
  }
109
+ function _tagged_template_literal$2(strings, raw) {
110
+ if (!raw) {
111
+ raw = strings.slice(0);
112
+ }
113
+ return Object.freeze(Object.defineProperties(strings, {
114
+ raw: {
115
+ value: Object.freeze(raw)
116
+ }
117
+ }));
118
+ }
56
119
  function _to_consumable_array(arr) {
57
120
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread();
58
121
  }
@@ -64,6 +127,17 @@ function _unsupported_iterable_to_array$2(o, minLen) {
64
127
  if (n === "Map" || n === "Set") return Array.from(n);
65
128
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
66
129
  }
130
+ function _templateObject$2() {
131
+ var data = _tagged_template_literal$2([
132
+ "{bold {yellow [ ",
133
+ " ]: getTypesMetaInfo failed, it will use the default types meta info, and the errors as belows: ",
134
+ " }}"
135
+ ]);
136
+ _templateObject$2 = function _templateObject() {
137
+ return data;
138
+ };
139
+ return data;
140
+ }
67
141
  function getSharedModuleName(name) {
68
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];
69
143
  return sharedInfo.split("@").slice(0, -1).join("@");
@@ -315,6 +389,45 @@ function getFileName(manifestOptions) {
315
389
  manifestFileName: simpleJoinRemoteEntry(filePath, manifestFileName)
316
390
  };
317
391
  }
392
+ function getTypesMetaInfo(pluginOptions, context) {
393
+ var defaultRemoteOptions = {
394
+ generateAPITypes: true,
395
+ compileInChildProcess: true
396
+ };
397
+ var defaultTypesMetaInfo = {
398
+ path: "",
399
+ name: "",
400
+ zip: "",
401
+ api: ""
402
+ };
403
+ try {
404
+ var normalizedDtsOptions = normalizeOptions(true, {
405
+ disableGenerateTypes: false,
406
+ remote: defaultRemoteOptions,
407
+ host: {}
408
+ }, "mfOptions.dts")(pluginOptions.dts);
409
+ if (normalizedDtsOptions === false) {
410
+ return defaultTypesMetaInfo;
411
+ }
412
+ var normalizedRemote = normalizeOptions(true, defaultRemoteOptions, "mfOptions.dts.remote")(normalizedDtsOptions.remote);
413
+ if (normalizedRemote === false) {
414
+ return defaultTypesMetaInfo;
415
+ }
416
+ var _retrieveTypesAssetsInfo = retrieveTypesAssetsInfo(_object_spread_props$2(_object_spread$3({}, normalizedRemote), {
417
+ context: context,
418
+ moduleFederationConfig: pluginOptions
419
+ })), apiFileName = _retrieveTypesAssetsInfo.apiFileName, zipName = _retrieveTypesAssetsInfo.zipName;
420
+ return {
421
+ path: "",
422
+ name: "",
423
+ zip: zipName,
424
+ api: apiFileName
425
+ };
426
+ } catch (err) {
427
+ console.warn(chalk(_templateObject$2(), PLUGIN_IDENTIFIER, err));
428
+ return defaultTypesMetaInfo;
429
+ }
430
+ }
318
431
 
319
432
  function _class_call_check$3(instance, Constructor) {
320
433
  if (!(instance instanceof Constructor)) {
@@ -1127,7 +1240,7 @@ function _ts_generator$1(thisArg, body) {
1127
1240
  }
1128
1241
  function _templateObject() {
1129
1242
  var data = _tagged_template_literal([
1130
- "{bold {red [ ",
1243
+ "{bold {yellow [ ",
1131
1244
  " ]: Manifest will not generate, because publicPath can only be string, but got '",
1132
1245
  "' }}"
1133
1246
  ]);
@@ -1138,7 +1251,7 @@ function _templateObject() {
1138
1251
  }
1139
1252
  function _templateObject1() {
1140
1253
  var data = _tagged_template_literal([
1141
- "{bold {red [ ",
1254
+ "{bold {yellow [ ",
1142
1255
  " ]: Manifest will not generate, because publicPath can only be absolute path, but got '",
1143
1256
  "'}}"
1144
1257
  ]);
@@ -1212,10 +1325,7 @@ var StatsManager = /*#__PURE__*/ function() {
1212
1325
  // same as the types supported by runtime, currently only global/var/script is supported
1213
1326
  type: "global"
1214
1327
  },
1215
- types: {
1216
- name: "",
1217
- path: ""
1218
- },
1328
+ types: getTypesMetaInfo(this._options, compiler.context),
1219
1329
  globalName: globalName,
1220
1330
  pluginVersion: this._pluginVersion
1221
1331
  };
@@ -1483,7 +1593,7 @@ var StatsManager = /*#__PURE__*/ function() {
1483
1593
  value: function generateStats(compiler, compilation, extraOptions) {
1484
1594
  var _this = this;
1485
1595
  return _async_to_generator$1(function() {
1486
- var _this__options, tmp, manifestOptions, stats, ret, err;
1596
+ var existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
1487
1597
  return _ts_generator$1(this, function(_state) {
1488
1598
  switch(_state.label){
1489
1599
  case 0:
@@ -1493,6 +1603,13 @@ var StatsManager = /*#__PURE__*/ function() {
1493
1603
  ,
1494
1604
  5
1495
1605
  ]);
1606
+ existedStats = compilation.getAsset(_this.fileName);
1607
+ if (existedStats) {
1608
+ return [
1609
+ 2,
1610
+ JSON.parse(existedStats.source.source().toString())
1611
+ ];
1612
+ }
1496
1613
  _this__options = _this._options, tmp = _this__options.manifest, manifestOptions = tmp === void 0 ? {} : tmp;
1497
1614
  return [
1498
1615
  4,
@@ -1541,10 +1658,10 @@ var StatsManager = /*#__PURE__*/ function() {
1541
1658
  value: function validate(compiler) {
1542
1659
  var _compiler_options = compiler.options, publicPath = _compiler_options.output.publicPath;
1543
1660
  if (typeof publicPath !== "string") {
1544
- console.error(chalk(_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1661
+ console.warn(chalk(_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1545
1662
  return false;
1546
1663
  } else if (publicPath === "auto") {
1547
- console.error(chalk(_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1664
+ console.warn(chalk(_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1548
1665
  return false;
1549
1666
  }
1550
1667
  return true;
package/dist/package.json CHANGED
@@ -23,6 +23,7 @@
23
23
  "types": "./dist/index.cjs.d.ts",
24
24
  "dependencies": {
25
25
  "@module-federation/sdk": "workspace:*",
26
+ "@module-federation/dts-kit": "workspace:*",
26
27
  "@module-federation/managers": "workspace:*",
27
28
  "find-pkg": "2.0.0",
28
29
  "chalk": "3.0.0"
@@ -1,5 +1,5 @@
1
1
  import { Chunk, Compilation, StatsCompilation, StatsModule } from 'webpack';
2
- import { StatsAssets, moduleFederationPlugin } from '@module-federation/sdk';
2
+ import { StatsAssets, moduleFederationPlugin, MetaDataTypes } from '@module-federation/sdk';
3
3
  export declare function getAssetsByChunkIDs(compilation: Compilation, chunkIDMap: Record<string, Set<string | number>>): Record<string, {
4
4
  js: string[];
5
5
  css: string[];
@@ -15,3 +15,4 @@ export declare function getFileName(manifestOptions?: moduleFederationPlugin.Mod
15
15
  statsFileName: string;
16
16
  manifestFileName: string;
17
17
  };
18
+ export declare function getTypesMetaInfo(pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions, context: string): MetaDataTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/manifest",
3
- "version": "0.0.0-next-20240401022607",
3
+ "version": "0.0.0-next-20240401040901",
4
4
  "license": "MIT",
5
5
  "description": "Provide manifest/stats for webpack/rspack MF project .",
6
6
  "keywords": [
@@ -24,8 +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-20240401022607",
28
- "@module-federation/managers": "0.0.0-next-20240401022607"
27
+ "@module-federation/sdk": "0.0.0-next-20240401040901",
28
+ "@module-federation/dts-kit": "0.0.0-next-20240401040901",
29
+ "@module-federation/managers": "0.0.0-next-20240401040901"
29
30
  },
30
31
  "exports": {
31
32
  ".": {