@module-federation/manifest 0.0.0-next-20240318085858 → 0.0.0-next-20240321102113

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,49 @@ 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
+ apiTypesName: "",
410
+ apiTypesPath: "",
411
+ zipName: "",
412
+ zipPath: ""
413
+ };
414
+ try {
415
+ var normalizedDtsOptions = sdk.normalizeOptions(true, {
416
+ disableGenerateTypes: false,
417
+ remote: defaultRemoteOptions,
418
+ host: {}
419
+ }, "mfOptions.dts")(pluginOptions.dts);
420
+ if (normalizedDtsOptions === false) {
421
+ return defaultTypesMetaInfo;
422
+ }
423
+ var normalizedRemote = sdk.normalizeOptions(true, defaultRemoteOptions, "mfOptions.dts.remote")(normalizedDtsOptions.remote);
424
+ if (normalizedRemote === false) {
425
+ return defaultTypesMetaInfo;
426
+ }
427
+ var _retrieveTypesAssetsInfo = dtsKit.retrieveTypesAssetsInfo(_object_spread_props$2(_object_spread$3({}, normalizedRemote), {
428
+ context: context,
429
+ moduleFederationConfig: pluginOptions
430
+ })), apiFileName = _retrieveTypesAssetsInfo.apiFileName, zipName = _retrieveTypesAssetsInfo.zipName;
431
+ return {
432
+ path: "",
433
+ name: "",
434
+ apiTypesName: apiFileName,
435
+ apiTypesPath: "",
436
+ zipName: zipName,
437
+ zipPath: ""
438
+ };
439
+ } catch (err) {
440
+ console.warn(chalk__default["default"](_templateObject$2(), PLUGIN_IDENTIFIER, err));
441
+ return defaultTypesMetaInfo;
442
+ }
443
+ }
327
444
 
328
445
  function _class_call_check$3(instance, Constructor) {
329
446
  if (!(instance instanceof Constructor)) {
@@ -1136,7 +1253,7 @@ function _ts_generator$1(thisArg, body) {
1136
1253
  }
1137
1254
  function _templateObject() {
1138
1255
  var data = _tagged_template_literal([
1139
- "{bold {red [ ",
1256
+ "{bold {yellow [ ",
1140
1257
  " ]: Manifest will not generate, because publicPath can only be string, but got '",
1141
1258
  "' }}"
1142
1259
  ]);
@@ -1147,7 +1264,7 @@ function _templateObject() {
1147
1264
  }
1148
1265
  function _templateObject1() {
1149
1266
  var data = _tagged_template_literal([
1150
- "{bold {red [ ",
1267
+ "{bold {yellow [ ",
1151
1268
  " ]: Manifest will not generate, because publicPath can only be absolute path, but got '",
1152
1269
  "'}}"
1153
1270
  ]);
@@ -1221,10 +1338,7 @@ var StatsManager = /*#__PURE__*/ function() {
1221
1338
  // same as the types supported by runtime, currently only global/var/script is supported
1222
1339
  type: "global"
1223
1340
  },
1224
- types: {
1225
- name: "",
1226
- path: ""
1227
- },
1341
+ types: getTypesMetaInfo(this._options, compiler.context),
1228
1342
  globalName: globalName,
1229
1343
  pluginVersion: this._pluginVersion
1230
1344
  };
@@ -1381,7 +1495,7 @@ var StatsManager = /*#__PURE__*/ function() {
1381
1495
  statsOptions["cached"] = true;
1382
1496
  statsOptions["cachedModules"] = true;
1383
1497
  }
1384
- webpackStats = liveStats.toJson();
1498
+ webpackStats = liveStats.toJson(statsOptions);
1385
1499
  filteredModules = _this._getFilteredModules(webpackStats);
1386
1500
  moduleHandler = new ModuleHandler(_this._options, filteredModules, {
1387
1501
  bundler: _this._bundler
@@ -1550,10 +1664,10 @@ var StatsManager = /*#__PURE__*/ function() {
1550
1664
  value: function validate(compiler) {
1551
1665
  var _compiler_options = compiler.options, publicPath = _compiler_options.output.publicPath;
1552
1666
  if (typeof publicPath !== "string") {
1553
- console.error(chalk__default["default"](_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1667
+ console.warn(chalk__default["default"](_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1554
1668
  return false;
1555
1669
  } else if (publicPath === "auto") {
1556
- console.error(chalk__default["default"](_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1670
+ console.warn(chalk__default["default"](_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1557
1671
  return false;
1558
1672
  }
1559
1673
  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,49 @@ 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
+ apiTypesName: "",
401
+ apiTypesPath: "",
402
+ zipName: "",
403
+ zipPath: ""
404
+ };
405
+ try {
406
+ var normalizedDtsOptions = normalizeOptions(true, {
407
+ disableGenerateTypes: false,
408
+ remote: defaultRemoteOptions,
409
+ host: {}
410
+ }, "mfOptions.dts")(pluginOptions.dts);
411
+ if (normalizedDtsOptions === false) {
412
+ return defaultTypesMetaInfo;
413
+ }
414
+ var normalizedRemote = normalizeOptions(true, defaultRemoteOptions, "mfOptions.dts.remote")(normalizedDtsOptions.remote);
415
+ if (normalizedRemote === false) {
416
+ return defaultTypesMetaInfo;
417
+ }
418
+ var _retrieveTypesAssetsInfo = retrieveTypesAssetsInfo(_object_spread_props$2(_object_spread$3({}, normalizedRemote), {
419
+ context: context,
420
+ moduleFederationConfig: pluginOptions
421
+ })), apiFileName = _retrieveTypesAssetsInfo.apiFileName, zipName = _retrieveTypesAssetsInfo.zipName;
422
+ return {
423
+ path: "",
424
+ name: "",
425
+ apiTypesName: apiFileName,
426
+ apiTypesPath: "",
427
+ zipName: zipName,
428
+ zipPath: ""
429
+ };
430
+ } catch (err) {
431
+ console.warn(chalk(_templateObject$2(), PLUGIN_IDENTIFIER, err));
432
+ return defaultTypesMetaInfo;
433
+ }
434
+ }
318
435
 
319
436
  function _class_call_check$3(instance, Constructor) {
320
437
  if (!(instance instanceof Constructor)) {
@@ -1127,7 +1244,7 @@ function _ts_generator$1(thisArg, body) {
1127
1244
  }
1128
1245
  function _templateObject() {
1129
1246
  var data = _tagged_template_literal([
1130
- "{bold {red [ ",
1247
+ "{bold {yellow [ ",
1131
1248
  " ]: Manifest will not generate, because publicPath can only be string, but got '",
1132
1249
  "' }}"
1133
1250
  ]);
@@ -1138,7 +1255,7 @@ function _templateObject() {
1138
1255
  }
1139
1256
  function _templateObject1() {
1140
1257
  var data = _tagged_template_literal([
1141
- "{bold {red [ ",
1258
+ "{bold {yellow [ ",
1142
1259
  " ]: Manifest will not generate, because publicPath can only be absolute path, but got '",
1143
1260
  "'}}"
1144
1261
  ]);
@@ -1212,10 +1329,7 @@ var StatsManager = /*#__PURE__*/ function() {
1212
1329
  // same as the types supported by runtime, currently only global/var/script is supported
1213
1330
  type: "global"
1214
1331
  },
1215
- types: {
1216
- name: "",
1217
- path: ""
1218
- },
1332
+ types: getTypesMetaInfo(this._options, compiler.context),
1219
1333
  globalName: globalName,
1220
1334
  pluginVersion: this._pluginVersion
1221
1335
  };
@@ -1372,7 +1486,7 @@ var StatsManager = /*#__PURE__*/ function() {
1372
1486
  statsOptions["cached"] = true;
1373
1487
  statsOptions["cachedModules"] = true;
1374
1488
  }
1375
- webpackStats = liveStats.toJson();
1489
+ webpackStats = liveStats.toJson(statsOptions);
1376
1490
  filteredModules = _this._getFilteredModules(webpackStats);
1377
1491
  moduleHandler = new ModuleHandler(_this._options, filteredModules, {
1378
1492
  bundler: _this._bundler
@@ -1541,10 +1655,10 @@ var StatsManager = /*#__PURE__*/ function() {
1541
1655
  value: function validate(compiler) {
1542
1656
  var _compiler_options = compiler.options, publicPath = _compiler_options.output.publicPath;
1543
1657
  if (typeof publicPath !== "string") {
1544
- console.error(chalk(_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1658
+ console.warn(chalk(_templateObject(), PLUGIN_IDENTIFIER, publicPath));
1545
1659
  return false;
1546
1660
  } else if (publicPath === "auto") {
1547
- console.error(chalk(_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1661
+ console.warn(chalk(_templateObject1(), PLUGIN_IDENTIFIER, publicPath));
1548
1662
  return false;
1549
1663
  }
1550
1664
  return true;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/manifest",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "license": "MIT",
5
5
  "description": "Provide manifest/stats for webpack/rspack MF project .",
6
6
  "keywords": [
@@ -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-20240318085858",
3
+ "version": "0.0.0-next-20240321102113",
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-20240318085858",
28
- "@module-federation/managers": "0.0.0-next-20240318085858"
27
+ "@module-federation/sdk": "0.0.0-next-20240321102113",
28
+ "@module-federation/dts-kit": "0.0.0-next-20240321102113",
29
+ "@module-federation/managers": "0.0.0-next-20240321102113"
29
30
  },
30
31
  "exports": {
31
32
  ".": {