@module-federation/manifest 0.0.0-next-20240402000503 → 0.0.0-next-20240402071000

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 helpers = require('@module-federation/native-federation-typescript/helpers');
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,44 @@ 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
+ generateTypes: defaultRemoteOptions,
415
+ consumeTypes: {}
416
+ }, "mfOptions.dts")(pluginOptions.dts);
417
+ if (normalizedDtsOptions === false) {
418
+ return defaultTypesMetaInfo;
419
+ }
420
+ var normalizedRemote = sdk.normalizeOptions(true, defaultRemoteOptions, "mfOptions.dts.generateTypes")(normalizedDtsOptions.generateTypes);
421
+ if (normalizedRemote === false) {
422
+ return defaultTypesMetaInfo;
423
+ }
424
+ var _retrieveTypesAssetsInfo = helpers.retrieveTypesAssetsInfo(_object_spread_props$2(_object_spread$3({}, normalizedRemote), {
425
+ context: context,
426
+ moduleFederationConfig: pluginOptions
427
+ })), apiFileName = _retrieveTypesAssetsInfo.apiFileName, zipName = _retrieveTypesAssetsInfo.zipName;
428
+ return {
429
+ path: "",
430
+ name: "",
431
+ zip: zipName,
432
+ api: apiFileName
433
+ };
434
+ } catch (err) {
435
+ console.warn(chalk__default["default"](_templateObject$2(), PLUGIN_IDENTIFIER, err));
436
+ return defaultTypesMetaInfo;
437
+ }
438
+ }
327
439
 
328
440
  function _class_call_check$3(instance, Constructor) {
329
441
  if (!(instance instanceof Constructor)) {
@@ -1136,7 +1248,7 @@ function _ts_generator$1(thisArg, body) {
1136
1248
  }
1137
1249
  function _templateObject() {
1138
1250
  var data = _tagged_template_literal([
1139
- "{bold {red [ ",
1251
+ "{bold {yellow [ ",
1140
1252
  " ]: Manifest will not generate, because publicPath can only be string, but got '",
1141
1253
  "' }}"
1142
1254
  ]);
@@ -1147,7 +1259,7 @@ function _templateObject() {
1147
1259
  }
1148
1260
  function _templateObject1() {
1149
1261
  var data = _tagged_template_literal([
1150
- "{bold {red [ ",
1262
+ "{bold {yellow [ ",
1151
1263
  " ]: Manifest will not generate, because publicPath can only be absolute path, but got '",
1152
1264
  "'}}"
1153
1265
  ]);
@@ -1221,10 +1333,7 @@ var StatsManager = /*#__PURE__*/ function() {
1221
1333
  // same as the types supported by runtime, currently only global/var/script is supported
1222
1334
  type: "global"
1223
1335
  },
1224
- types: {
1225
- name: "",
1226
- path: ""
1227
- },
1336
+ types: getTypesMetaInfo(this._options, compiler.context),
1228
1337
  globalName: globalName,
1229
1338
  pluginVersion: this._pluginVersion
1230
1339
  };
@@ -1492,7 +1601,7 @@ var StatsManager = /*#__PURE__*/ function() {
1492
1601
  value: function generateStats(compiler, compilation, extraOptions) {
1493
1602
  var _this = this;
1494
1603
  return _async_to_generator$1(function() {
1495
- var _this__options, tmp, manifestOptions, stats, ret, err;
1604
+ var existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
1496
1605
  return _ts_generator$1(this, function(_state) {
1497
1606
  switch(_state.label){
1498
1607
  case 0:
@@ -1502,6 +1611,13 @@ var StatsManager = /*#__PURE__*/ function() {
1502
1611
  ,
1503
1612
  5
1504
1613
  ]);
1614
+ existedStats = compilation.getAsset(_this.fileName);
1615
+ if (existedStats) {
1616
+ return [
1617
+ 2,
1618
+ JSON.parse(existedStats.source.source().toString())
1619
+ ];
1620
+ }
1505
1621
  _this__options = _this._options, tmp = _this__options.manifest, manifestOptions = tmp === void 0 ? {} : tmp;
1506
1622
  return [
1507
1623
  4,
@@ -1550,10 +1666,10 @@ var StatsManager = /*#__PURE__*/ function() {
1550
1666
  value: function validate(compiler) {
1551
1667
  var _compiler_options = compiler.options, publicPath = _compiler_options.output.publicPath;
1552
1668
  if (typeof publicPath !== "string") {
1553
- console.error(chalk__default["default"](_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1669
+ console.warn(chalk__default["default"](_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1554
1670
  return false;
1555
1671
  } else if (publicPath === "auto") {
1556
- console.error(chalk__default["default"](_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1672
+ console.warn(chalk__default["default"](_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1557
1673
  return false;
1558
1674
  }
1559
1675
  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/native-federation-typescript/helpers';
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,44 @@ 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
+ generateTypes: defaultRemoteOptions,
406
+ consumeTypes: {}
407
+ }, "mfOptions.dts")(pluginOptions.dts);
408
+ if (normalizedDtsOptions === false) {
409
+ return defaultTypesMetaInfo;
410
+ }
411
+ var normalizedRemote = normalizeOptions(true, defaultRemoteOptions, "mfOptions.dts.generateTypes")(normalizedDtsOptions.generateTypes);
412
+ if (normalizedRemote === false) {
413
+ return defaultTypesMetaInfo;
414
+ }
415
+ var _retrieveTypesAssetsInfo = retrieveTypesAssetsInfo(_object_spread_props$2(_object_spread$3({}, normalizedRemote), {
416
+ context: context,
417
+ moduleFederationConfig: pluginOptions
418
+ })), apiFileName = _retrieveTypesAssetsInfo.apiFileName, zipName = _retrieveTypesAssetsInfo.zipName;
419
+ return {
420
+ path: "",
421
+ name: "",
422
+ zip: zipName,
423
+ api: apiFileName
424
+ };
425
+ } catch (err) {
426
+ console.warn(chalk(_templateObject$2(), PLUGIN_IDENTIFIER, err));
427
+ return defaultTypesMetaInfo;
428
+ }
429
+ }
318
430
 
319
431
  function _class_call_check$3(instance, Constructor) {
320
432
  if (!(instance instanceof Constructor)) {
@@ -1127,7 +1239,7 @@ function _ts_generator$1(thisArg, body) {
1127
1239
  }
1128
1240
  function _templateObject() {
1129
1241
  var data = _tagged_template_literal([
1130
- "{bold {red [ ",
1242
+ "{bold {yellow [ ",
1131
1243
  " ]: Manifest will not generate, because publicPath can only be string, but got '",
1132
1244
  "' }}"
1133
1245
  ]);
@@ -1138,7 +1250,7 @@ function _templateObject() {
1138
1250
  }
1139
1251
  function _templateObject1() {
1140
1252
  var data = _tagged_template_literal([
1141
- "{bold {red [ ",
1253
+ "{bold {yellow [ ",
1142
1254
  " ]: Manifest will not generate, because publicPath can only be absolute path, but got '",
1143
1255
  "'}}"
1144
1256
  ]);
@@ -1212,10 +1324,7 @@ var StatsManager = /*#__PURE__*/ function() {
1212
1324
  // same as the types supported by runtime, currently only global/var/script is supported
1213
1325
  type: "global"
1214
1326
  },
1215
- types: {
1216
- name: "",
1217
- path: ""
1218
- },
1327
+ types: getTypesMetaInfo(this._options, compiler.context),
1219
1328
  globalName: globalName,
1220
1329
  pluginVersion: this._pluginVersion
1221
1330
  };
@@ -1483,7 +1592,7 @@ var StatsManager = /*#__PURE__*/ function() {
1483
1592
  value: function generateStats(compiler, compilation, extraOptions) {
1484
1593
  var _this = this;
1485
1594
  return _async_to_generator$1(function() {
1486
- var _this__options, tmp, manifestOptions, stats, ret, err;
1595
+ var existedStats, _this__options, tmp, manifestOptions, stats, ret, err;
1487
1596
  return _ts_generator$1(this, function(_state) {
1488
1597
  switch(_state.label){
1489
1598
  case 0:
@@ -1493,6 +1602,13 @@ var StatsManager = /*#__PURE__*/ function() {
1493
1602
  ,
1494
1603
  5
1495
1604
  ]);
1605
+ existedStats = compilation.getAsset(_this.fileName);
1606
+ if (existedStats) {
1607
+ return [
1608
+ 2,
1609
+ JSON.parse(existedStats.source.source().toString())
1610
+ ];
1611
+ }
1496
1612
  _this__options = _this._options, tmp = _this__options.manifest, manifestOptions = tmp === void 0 ? {} : tmp;
1497
1613
  return [
1498
1614
  4,
@@ -1541,10 +1657,10 @@ var StatsManager = /*#__PURE__*/ function() {
1541
1657
  value: function validate(compiler) {
1542
1658
  var _compiler_options = compiler.options, publicPath = _compiler_options.output.publicPath;
1543
1659
  if (typeof publicPath !== "string") {
1544
- console.error(chalk(_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1660
+ console.warn(chalk(_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1545
1661
  return false;
1546
1662
  } else if (publicPath === "auto") {
1547
- console.error(chalk(_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1663
+ console.warn(chalk(_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1548
1664
  return false;
1549
1665
  }
1550
1666
  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/native-federation-typescript": "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-20240402000503",
3
+ "version": "0.0.0-next-20240402071000",
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-20240402000503",
28
- "@module-federation/managers": "0.0.0-next-20240402000503"
27
+ "@module-federation/sdk": "0.0.0-next-20240402071000",
28
+ "@module-federation/native-federation-typescript": "0.0.0-next-20240402071000",
29
+ "@module-federation/managers": "0.0.0-next-20240402071000"
29
30
  },
30
31
  "exports": {
31
32
  ".": {