@module-federation/dts-plugin 0.9.0 → 0.9.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @module-federation/dts-plugin
2
2
 
3
+ ## 0.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 35d925b: feat(dts-plugin): support remoteTypeUrls option which allow user to specify the remote types url
8
+ - 35d925b: fix(dts-plugin): support parse @scope@manifest-url.json entry
9
+ - 7a37360: fix(dts-plugin): consume api types if adding new one
10
+ - Updated dependencies [35d925b]
11
+ - Updated dependencies [35d925b]
12
+ - Updated dependencies [8acd217]
13
+ - @module-federation/sdk@0.9.1
14
+ - @module-federation/managers@0.9.1
15
+ - @module-federation/third-party-dts-extractor@0.9.1
16
+ - @module-federation/error-codes@0.9.1
17
+
3
18
  ## 0.9.0
4
19
 
5
20
  ### Minor Changes
@@ -41,7 +41,7 @@ declare class DTSManager {
41
41
  generateTypes(): Promise<void>;
42
42
  requestRemoteManifest(remoteInfo: RemoteInfo): Promise<Required<RemoteInfo>>;
43
43
  consumeTargetRemotes(hostOptions: Required<HostOptions>, remoteInfo: Required<RemoteInfo>): Promise<[string, string]>;
44
- downloadAPITypes(remoteInfo: Required<RemoteInfo>, destinationPath: string): Promise<void>;
44
+ downloadAPITypes(remoteInfo: Required<RemoteInfo>, destinationPath: string): Promise<boolean>;
45
45
  consumeAPITypes(hostOptions: Required<HostOptions>): void;
46
46
  consumeArchiveTypes(options: HostOptions): Promise<{
47
47
  hostOptions: Required<HostOptions>;
package/dist/core.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DTSManager, T as TsConfigJson, R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-484d9f4a.js';
2
- export { j as DtsWorker, r as retrieveRemoteConfig } from './DtsWorker-484d9f4a.js';
1
+ import { D as DTSManager, T as TsConfigJson, R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-edc3f145.js';
2
+ export { j as DtsWorker, r as retrieveRemoteConfig } from './DtsWorker-edc3f145.js';
3
3
  import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
4
4
  import { moduleFederationPlugin } from '@module-federation/sdk';
5
5
  import { ChildProcess } from 'child_process';
package/dist/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DTSManager, T as TsConfigJson, R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-484d9f4a.js';
2
- export { j as DtsWorker, r as retrieveRemoteConfig } from './DtsWorker-484d9f4a.js';
1
+ import { D as DTSManager, T as TsConfigJson, R as RpcRemoteMethod, a as RpcCallMessage, b as RpcGMCallTypes, c as RpcMessage, d as RpcMethod, e as RpcRejectMessage, f as RpcResolveMessage, g as RpcWorker, h as createRpcWorker, i as getRpcWorkerData } from './DtsWorker-edc3f145.js';
2
+ export { j as DtsWorker, r as retrieveRemoteConfig } from './DtsWorker-edc3f145.js';
3
3
  import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
4
4
  import { moduleFederationPlugin } from '@module-federation/sdk';
5
5
  import { ChildProcess } from 'child_process';
package/dist/core.js CHANGED
@@ -123,6 +123,7 @@ var import_ansi_colors = __toESM(require("ansi-colors"));
123
123
  var import_path3 = __toESM(require("path"));
124
124
  var import_promises3 = require("fs/promises");
125
125
  var import_fs = __toESM(require("fs"));
126
+ var import_fs_extra3 = __toESM(require("fs-extra"));
126
127
  var import_sdk5 = require("@module-federation/sdk");
127
128
  var import_third_party_dts_extractor2 = require("@module-federation/third-party-dts-extractor");
128
129
 
@@ -1203,7 +1204,8 @@ var defaultOptions = {
1203
1204
  context: process.cwd(),
1204
1205
  abortOnError: true,
1205
1206
  consumeAPITypes: false,
1206
- runtimePkgs: []
1207
+ runtimePkgs: [],
1208
+ remoteTypeUrls: {}
1207
1209
  };
1208
1210
  var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
1209
1211
  const remoteUrl = new URL(url, "file:");
@@ -1219,18 +1221,31 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
1219
1221
  }, "buildApiTypeUrl");
1220
1222
  var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
1221
1223
  const { hostOptions, remoteAlias, remote } = options;
1224
+ const { remoteTypeUrls } = hostOptions;
1222
1225
  let decodedRemote = remote;
1223
1226
  if (decodedRemote.startsWith(import_sdk4.ENCODE_NAME_PREFIX)) {
1224
1227
  decodedRemote = (0, import_sdk4.decodeName)(decodedRemote, import_sdk4.ENCODE_NAME_PREFIX);
1225
1228
  }
1226
1229
  const parsedInfo = (0, import_sdk4.parseEntry)(decodedRemote, void 0, "@");
1227
1230
  const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
1228
- const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
1231
+ let zipUrl = "";
1232
+ let apiTypeUrl = "";
1233
+ const name = parsedInfo.name || remoteAlias;
1234
+ if (typeof remoteTypeUrls === "object" && remoteTypeUrls[name]) {
1235
+ zipUrl = remoteTypeUrls[name].zip;
1236
+ apiTypeUrl = remoteTypeUrls[name].api;
1237
+ }
1238
+ if (!zipUrl && url) {
1239
+ zipUrl = buildZipUrl(hostOptions, url);
1240
+ }
1241
+ if (!apiTypeUrl && zipUrl) {
1242
+ apiTypeUrl = buildApiTypeUrl(zipUrl);
1243
+ }
1229
1244
  return {
1230
- name: parsedInfo.name || remoteAlias,
1245
+ name,
1231
1246
  url,
1232
1247
  zipUrl,
1233
- apiTypeUrl: buildApiTypeUrl(zipUrl),
1248
+ apiTypeUrl,
1234
1249
  alias: remoteAlias
1235
1250
  };
1236
1251
  }, "retrieveRemoteInfo");
@@ -1306,6 +1321,7 @@ var DTSManager = (_a = class {
1306
1321
  }
1307
1322
  extractRemoteTypes(options) {
1308
1323
  return __async(this, null, function* () {
1324
+ var _a3;
1309
1325
  const { remoteOptions, tsConfig } = options;
1310
1326
  if (!remoteOptions.extractRemoteTypes) {
1311
1327
  return;
@@ -1320,20 +1336,29 @@ var DTSManager = (_a = class {
1320
1336
  }
1321
1337
  }
1322
1338
  const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
1323
- if (hasRemotes) {
1324
- const tempHostOptions = {
1325
- moduleFederationConfig: remoteOptions.moduleFederationConfig,
1326
- typesFolder: import_path3.default.join(mfTypesPath, "node_modules"),
1327
- remoteTypesFolder: (remoteOptions == null ? void 0 : remoteOptions.hostRemoteTypesFolder) || remoteOptions.typesFolder,
1328
- deleteTypesFolder: true,
1329
- context: remoteOptions.context,
1330
- implementation: remoteOptions.implementation,
1331
- abortOnError: false
1332
- };
1333
- yield this.consumeArchiveTypes(tempHostOptions);
1339
+ if (hasRemotes && this.options.host) {
1340
+ try {
1341
+ const { hostOptions } = retrieveHostConfig(this.options.host);
1342
+ const remoteTypesFolder = import_path3.default.resolve(hostOptions.context, hostOptions.typesFolder);
1343
+ const targetDir = import_path3.default.join(mfTypesPath, "node_modules");
1344
+ if (import_fs.default.existsSync(remoteTypesFolder)) {
1345
+ const targetFolder = import_path3.default.resolve(remoteOptions.context, targetDir);
1346
+ yield import_fs_extra3.default.ensureDir(targetFolder);
1347
+ yield import_fs_extra3.default.copy(remoteTypesFolder, targetFolder, {
1348
+ overwrite: true
1349
+ });
1350
+ }
1351
+ } catch (err) {
1352
+ if (((_a3 = this.options.host) == null ? void 0 : _a3.abortOnError) === false) {
1353
+ fileLog(`Unable to copy remote types, ${err}`, "extractRemoteTypes", "error");
1354
+ } else {
1355
+ throw err;
1356
+ }
1357
+ }
1334
1358
  }
1335
1359
  });
1336
1360
  }
1361
+ // it must execute after consumeTypes
1337
1362
  generateTypes() {
1338
1363
  return __async(this, null, function* () {
1339
1364
  var _a3;
@@ -1346,6 +1371,18 @@ var DTSManager = (_a = class {
1346
1371
  if (!Object.keys(mapComponentsToExpose).length) {
1347
1372
  return;
1348
1373
  }
1374
+ if (tsConfig.compilerOptions.tsBuildInfoFile) {
1375
+ try {
1376
+ const tsBuildInfoFile = import_path3.default.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
1377
+ const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
1378
+ if (!import_fs.default.existsSync(mfTypesPath)) {
1379
+ import_fs.default.rmSync(tsBuildInfoFile, {
1380
+ force: true
1381
+ });
1382
+ }
1383
+ } catch (e) {
1384
+ }
1385
+ }
1349
1386
  yield this.extractRemoteTypes({
1350
1387
  remoteOptions,
1351
1388
  tsConfig,
@@ -1375,7 +1412,7 @@ var DTSManager = (_a = class {
1375
1412
  } catch (error2) {
1376
1413
  if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
1377
1414
  if (this.options.displayErrorInTerminal) {
1378
- logger.error(`Unable to compile federated types${error2}`);
1415
+ logger.error(`Unable to compile federated types ${error2}`);
1379
1416
  }
1380
1417
  } else {
1381
1418
  throw error2;
@@ -1389,6 +1426,9 @@ var DTSManager = (_a = class {
1389
1426
  if (!remoteInfo.url.includes(import_sdk5.MANIFEST_EXT)) {
1390
1427
  return remoteInfo;
1391
1428
  }
1429
+ if (remoteInfo.zipUrl) {
1430
+ return remoteInfo;
1431
+ }
1392
1432
  const url = remoteInfo.url;
1393
1433
  const res = yield axiosGet(url);
1394
1434
  const manifestJson = res.data;
@@ -1454,8 +1494,10 @@ var DTSManager = (_a = class {
1454
1494
  apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
1455
1495
  const filePath = import_path3.default.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
1456
1496
  import_fs.default.writeFileSync(filePath, apiTypeFile);
1497
+ const existed = this.loadedRemoteAPIAlias.has(remoteInfo.alias);
1457
1498
  this.loadedRemoteAPIAlias.add(remoteInfo.alias);
1458
1499
  fileLog(`success`, "downloadAPITypes", "info");
1500
+ return existed;
1459
1501
  } catch (err) {
1460
1502
  fileLog(`Unable to download "${remoteInfo.name}" api types, ${err}`, "downloadAPITypes", "error");
1461
1503
  }
@@ -1597,7 +1639,10 @@ hostName: ${hostName}`, "updateTypes", "info");
1597
1639
  // use remoteTarPath first
1598
1640
  zipUrl: remoteTarPath || requiredRemoteInfo.zipUrl
1599
1641
  }));
1600
- yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
1642
+ const addNew = yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
1643
+ if (addNew) {
1644
+ this.consumeAPITypes(hostOptions);
1645
+ }
1601
1646
  fileLog(`consumeTypes end`, "updateTypes", "info");
1602
1647
  }), "consumeTypes");
1603
1648
  fileLog(`loadedRemoteInfo: ${JSON.stringify(loadedRemoteInfo, null, 2)}`, "updateTypes", "info");
@@ -1615,7 +1660,6 @@ hostName: ${hostName}`, "updateTypes", "info");
1615
1660
  } else if (updatedRemoteInfo) {
1616
1661
  const consumeDynamicRemoteTypes = /* @__PURE__ */ __name(() => __async(this, null, function* () {
1617
1662
  yield consumeTypes2(this.updatedRemoteInfos[updatedRemoteInfo.name]);
1618
- this.consumeAPITypes(hostOptions);
1619
1663
  }), "consumeDynamicRemoteTypes");
1620
1664
  if (!this.updatedRemoteInfos[updatedRemoteInfo.name]) {
1621
1665
  const parsedRemoteInfo = retrieveRemoteInfo({
@@ -1733,10 +1777,13 @@ function cloneDeepOptions(options) {
1733
1777
  "manifest",
1734
1778
  "async"
1735
1779
  ];
1736
- return (0, import_lodash.default)(options, (_value, key) => {
1780
+ return (0, import_lodash.default)(options, (value, key) => {
1737
1781
  if (typeof key === "string" && excludeKeys.includes(key)) {
1738
1782
  return false;
1739
1783
  }
1784
+ if (typeof value === "function") {
1785
+ return false;
1786
+ }
1740
1787
  });
1741
1788
  }
1742
1789
  __name(cloneDeepOptions, "cloneDeepOptions");
@@ -4,7 +4,7 @@ import {
4
4
  exposeRpc,
5
5
  getDTSManagerConstructor,
6
6
  isDebugMode
7
- } from "./chunk-XXMD5NAZ.js";
7
+ } from "./chunk-ZU4UW7EP.js";
8
8
  import {
9
9
  __async,
10
10
  __export,
@@ -706,6 +706,7 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
706
706
  import path2 from "path";
707
707
  import { rm as rm2 } from "fs/promises";
708
708
  import fs2 from "fs";
709
+ import fse from "fs-extra";
709
710
  import { MANIFEST_EXT, inferAutoPublicPath } from "@module-federation/sdk";
710
711
  import { ThirdPartyExtractor as ThirdPartyExtractor2 } from "@module-federation/third-party-dts-extractor";
711
712
 
@@ -721,7 +722,8 @@ var defaultOptions2 = {
721
722
  context: process.cwd(),
722
723
  abortOnError: true,
723
724
  consumeAPITypes: false,
724
- runtimePkgs: []
725
+ runtimePkgs: [],
726
+ remoteTypeUrls: {}
725
727
  };
726
728
  var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
727
729
  const remoteUrl = new URL(url, "file:");
@@ -737,18 +739,31 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
737
739
  }, "buildApiTypeUrl");
738
740
  var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
739
741
  const { hostOptions, remoteAlias, remote } = options;
742
+ const { remoteTypeUrls } = hostOptions;
740
743
  let decodedRemote = remote;
741
744
  if (decodedRemote.startsWith(ENCODE_NAME_PREFIX)) {
742
745
  decodedRemote = decodeName(decodedRemote, ENCODE_NAME_PREFIX);
743
746
  }
744
747
  const parsedInfo = parseEntry(decodedRemote, void 0, "@");
745
748
  const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
746
- const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
749
+ let zipUrl = "";
750
+ let apiTypeUrl = "";
751
+ const name = parsedInfo.name || remoteAlias;
752
+ if (typeof remoteTypeUrls === "object" && remoteTypeUrls[name]) {
753
+ zipUrl = remoteTypeUrls[name].zip;
754
+ apiTypeUrl = remoteTypeUrls[name].api;
755
+ }
756
+ if (!zipUrl && url) {
757
+ zipUrl = buildZipUrl(hostOptions, url);
758
+ }
759
+ if (!apiTypeUrl && zipUrl) {
760
+ apiTypeUrl = buildApiTypeUrl(zipUrl);
761
+ }
747
762
  return {
748
- name: parsedInfo.name || remoteAlias,
763
+ name,
749
764
  url,
750
765
  zipUrl,
751
- apiTypeUrl: buildApiTypeUrl(zipUrl),
766
+ apiTypeUrl,
752
767
  alias: remoteAlias
753
768
  };
754
769
  }, "retrieveRemoteInfo");
@@ -824,6 +839,7 @@ var DTSManager = (_a = class {
824
839
  }
825
840
  extractRemoteTypes(options) {
826
841
  return __async(this, null, function* () {
842
+ var _a2;
827
843
  const { remoteOptions, tsConfig } = options;
828
844
  if (!remoteOptions.extractRemoteTypes) {
829
845
  return;
@@ -838,20 +854,29 @@ var DTSManager = (_a = class {
838
854
  }
839
855
  }
840
856
  const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
841
- if (hasRemotes) {
842
- const tempHostOptions = {
843
- moduleFederationConfig: remoteOptions.moduleFederationConfig,
844
- typesFolder: path2.join(mfTypesPath, "node_modules"),
845
- remoteTypesFolder: (remoteOptions == null ? void 0 : remoteOptions.hostRemoteTypesFolder) || remoteOptions.typesFolder,
846
- deleteTypesFolder: true,
847
- context: remoteOptions.context,
848
- implementation: remoteOptions.implementation,
849
- abortOnError: false
850
- };
851
- yield this.consumeArchiveTypes(tempHostOptions);
857
+ if (hasRemotes && this.options.host) {
858
+ try {
859
+ const { hostOptions } = retrieveHostConfig(this.options.host);
860
+ const remoteTypesFolder = path2.resolve(hostOptions.context, hostOptions.typesFolder);
861
+ const targetDir = path2.join(mfTypesPath, "node_modules");
862
+ if (fs2.existsSync(remoteTypesFolder)) {
863
+ const targetFolder = path2.resolve(remoteOptions.context, targetDir);
864
+ yield fse.ensureDir(targetFolder);
865
+ yield fse.copy(remoteTypesFolder, targetFolder, {
866
+ overwrite: true
867
+ });
868
+ }
869
+ } catch (err) {
870
+ if (((_a2 = this.options.host) == null ? void 0 : _a2.abortOnError) === false) {
871
+ fileLog(`Unable to copy remote types, ${err}`, "extractRemoteTypes", "error");
872
+ } else {
873
+ throw err;
874
+ }
875
+ }
852
876
  }
853
877
  });
854
878
  }
879
+ // it must execute after consumeTypes
855
880
  generateTypes() {
856
881
  return __async(this, null, function* () {
857
882
  var _a2;
@@ -864,6 +889,18 @@ var DTSManager = (_a = class {
864
889
  if (!Object.keys(mapComponentsToExpose).length) {
865
890
  return;
866
891
  }
892
+ if (tsConfig.compilerOptions.tsBuildInfoFile) {
893
+ try {
894
+ const tsBuildInfoFile = path2.resolve(remoteOptions.context, tsConfig.compilerOptions.tsBuildInfoFile);
895
+ const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
896
+ if (!fs2.existsSync(mfTypesPath)) {
897
+ fs2.rmSync(tsBuildInfoFile, {
898
+ force: true
899
+ });
900
+ }
901
+ } catch (e) {
902
+ }
903
+ }
867
904
  yield this.extractRemoteTypes({
868
905
  remoteOptions,
869
906
  tsConfig,
@@ -893,7 +930,7 @@ var DTSManager = (_a = class {
893
930
  } catch (error) {
894
931
  if (((_a2 = this.options.remote) == null ? void 0 : _a2.abortOnError) === false) {
895
932
  if (this.options.displayErrorInTerminal) {
896
- logger.error(`Unable to compile federated types${error}`);
933
+ logger.error(`Unable to compile federated types ${error}`);
897
934
  }
898
935
  } else {
899
936
  throw error;
@@ -907,6 +944,9 @@ var DTSManager = (_a = class {
907
944
  if (!remoteInfo.url.includes(MANIFEST_EXT)) {
908
945
  return remoteInfo;
909
946
  }
947
+ if (remoteInfo.zipUrl) {
948
+ return remoteInfo;
949
+ }
910
950
  const url = remoteInfo.url;
911
951
  const res = yield axiosGet(url);
912
952
  const manifestJson = res.data;
@@ -972,8 +1012,10 @@ var DTSManager = (_a = class {
972
1012
  apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
973
1013
  const filePath = path2.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
974
1014
  fs2.writeFileSync(filePath, apiTypeFile);
1015
+ const existed = this.loadedRemoteAPIAlias.has(remoteInfo.alias);
975
1016
  this.loadedRemoteAPIAlias.add(remoteInfo.alias);
976
1017
  fileLog(`success`, "downloadAPITypes", "info");
1018
+ return existed;
977
1019
  } catch (err) {
978
1020
  fileLog(`Unable to download "${remoteInfo.name}" api types, ${err}`, "downloadAPITypes", "error");
979
1021
  }
@@ -1115,7 +1157,10 @@ hostName: ${hostName}`, "updateTypes", "info");
1115
1157
  // use remoteTarPath first
1116
1158
  zipUrl: remoteTarPath || requiredRemoteInfo.zipUrl
1117
1159
  }));
1118
- yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
1160
+ const addNew = yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
1161
+ if (addNew) {
1162
+ this.consumeAPITypes(hostOptions);
1163
+ }
1119
1164
  fileLog(`consumeTypes end`, "updateTypes", "info");
1120
1165
  }), "consumeTypes");
1121
1166
  fileLog(`loadedRemoteInfo: ${JSON.stringify(loadedRemoteInfo, null, 2)}`, "updateTypes", "info");
@@ -1133,7 +1178,6 @@ hostName: ${hostName}`, "updateTypes", "info");
1133
1178
  } else if (updatedRemoteInfo) {
1134
1179
  const consumeDynamicRemoteTypes = /* @__PURE__ */ __name(() => __async(this, null, function* () {
1135
1180
  yield consumeTypes(this.updatedRemoteInfos[updatedRemoteInfo.name]);
1136
- this.consumeAPITypes(hostOptions);
1137
1181
  }), "consumeDynamicRemoteTypes");
1138
1182
  if (!this.updatedRemoteInfos[updatedRemoteInfo.name]) {
1139
1183
  const parsedRemoteInfo = retrieveRemoteInfo({
@@ -1251,10 +1295,13 @@ function cloneDeepOptions(options) {
1251
1295
  "manifest",
1252
1296
  "async"
1253
1297
  ];
1254
- return cloneDeepWith(options, (_value, key) => {
1298
+ return cloneDeepWith(options, (value, key) => {
1255
1299
  if (typeof key === "string" && excludeKeys.includes(key)) {
1256
1300
  return false;
1257
1301
  }
1302
+ if (typeof value === "function") {
1303
+ return false;
1304
+ }
1258
1305
  });
1259
1306
  }
1260
1307
  __name(cloneDeepOptions, "cloneDeepOptions");
package/dist/esm/core.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  consumeTypes,
4
4
  generateTypesInChildProcess,
5
5
  rpc_exports
6
- } from "./chunk-UK7YFESF.js";
6
+ } from "./chunk-LHN7ASHT.js";
7
7
  import {
8
8
  DTSManager,
9
9
  HOST_API_TYPES_FILE_NAME,
@@ -19,7 +19,7 @@ import {
19
19
  retrieveTypesAssetsInfo,
20
20
  retrieveTypesZipPath,
21
21
  validateOptions
22
- } from "./chunk-XXMD5NAZ.js";
22
+ } from "./chunk-ZU4UW7EP.js";
23
23
  import "./chunk-KCWHOFI6.js";
24
24
  import "./chunk-4CSLH7II.js";
25
25
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  rpc_exports
3
- } from "./chunk-UK7YFESF.js";
3
+ } from "./chunk-LHN7ASHT.js";
4
4
  import {
5
5
  ModuleFederationDevServer,
6
6
  createKoaServer,
@@ -9,7 +9,7 @@ import {
9
9
  retrieveMfTypesPath,
10
10
  retrieveRemoteConfig,
11
11
  retrieveTypesZipPath
12
- } from "./chunk-XXMD5NAZ.js";
12
+ } from "./chunk-ZU4UW7EP.js";
13
13
  import {
14
14
  fileLog,
15
15
  getIPV4
@@ -2,7 +2,7 @@ import {
2
2
  RpcGMCallTypes,
3
3
  exposeRpc,
4
4
  generateTypes
5
- } from "./chunk-XXMD5NAZ.js";
5
+ } from "./chunk-ZU4UW7EP.js";
6
6
  import "./chunk-KCWHOFI6.js";
7
7
  import {
8
8
  __async,
package/dist/esm/index.js CHANGED
@@ -2,14 +2,14 @@ import {
2
2
  consumeTypes,
3
3
  generateTypesInChildProcess,
4
4
  rpc_exports
5
- } from "./chunk-UK7YFESF.js";
5
+ } from "./chunk-LHN7ASHT.js";
6
6
  import {
7
7
  cloneDeepOptions,
8
8
  generateTypes,
9
9
  isTSProject,
10
10
  retrieveTypesAssetsInfo,
11
11
  validateOptions
12
- } from "./chunk-XXMD5NAZ.js";
12
+ } from "./chunk-ZU4UW7EP.js";
13
13
  import {
14
14
  getIPV4,
15
15
  logger
@@ -126,15 +126,17 @@ function ensureTempDir(filePath) {
126
126
  }
127
127
  __name(ensureTempDir, "ensureTempDir");
128
128
  var _DevPlugin = class _DevPlugin {
129
- constructor(options, dtsOptions, fetchTypesPromise) {
129
+ constructor(options, dtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise) {
130
130
  __publicField(this, "name", "MFDevPlugin");
131
131
  __publicField(this, "_options");
132
132
  __publicField(this, "_devWorker");
133
133
  __publicField(this, "dtsOptions");
134
- __publicField(this, "fetchTypesPromise");
134
+ __publicField(this, "generateTypesPromise");
135
+ __publicField(this, "fetchRemoteTypeUrlsPromise");
135
136
  this._options = options;
136
- this.fetchTypesPromise = fetchTypesPromise;
137
+ this.generateTypesPromise = generateTypesPromise;
137
138
  this.dtsOptions = dtsOptions;
139
+ this.fetchRemoteTypeUrlsPromise = fetchRemoteTypeUrlsPromise;
138
140
  }
139
141
  static ensureLiveReloadEntry(options, filePath) {
140
142
  ensureTempDir(filePath);
@@ -252,11 +254,16 @@ var _DevPlugin = class _DevPlugin {
252
254
  if (remote && !(remote == null ? void 0 : remote.tsConfigPath) && typeof normalizedDtsOptions === "object" && normalizedDtsOptions.tsConfigPath) {
253
255
  remote.tsConfigPath = normalizedDtsOptions.tsConfigPath;
254
256
  }
255
- this.fetchTypesPromise.then(() => {
257
+ Promise.all([
258
+ this.generateTypesPromise,
259
+ this.fetchRemoteTypeUrlsPromise
260
+ ]).then(([_, remoteTypeUrls]) => {
256
261
  this._devWorker = createDevWorker({
257
262
  name,
258
263
  remote,
259
- host,
264
+ host: __spreadProps(__spreadValues({}, host), {
265
+ remoteTypeUrls
266
+ }),
260
267
  extraOptions,
261
268
  disableLiveReload: normalizedDev.disableHotTypesReload,
262
269
  disableHotTypesReload: normalizedDev.disableHotTypesReload
@@ -276,25 +283,26 @@ import { normalizeOptions as normalizeOptions4 } from "@module-federation/sdk";
276
283
  // packages/dts-plugin/src/plugins/ConsumeTypesPlugin.ts
277
284
  import { normalizeOptions as normalizeOptions2 } from "@module-federation/sdk";
278
285
  var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
279
- constructor(pluginOptions, dtsOptions, defaultOptions, callback) {
286
+ constructor(pluginOptions, dtsOptions, defaultOptions, fetchRemoteTypeUrlsResolve) {
280
287
  __publicField(this, "pluginOptions");
281
288
  __publicField(this, "dtsOptions");
282
289
  __publicField(this, "defaultOptions");
283
290
  __publicField(this, "callback");
291
+ __publicField(this, "fetchRemoteTypeUrlsResolve");
284
292
  this.pluginOptions = pluginOptions;
285
293
  this.dtsOptions = dtsOptions;
286
294
  this.defaultOptions = defaultOptions;
287
- this.callback = callback;
295
+ this.fetchRemoteTypeUrlsResolve = fetchRemoteTypeUrlsResolve;
288
296
  }
289
297
  apply(compiler) {
290
- const { dtsOptions, defaultOptions, pluginOptions, callback } = this;
298
+ const { dtsOptions, defaultOptions, pluginOptions, fetchRemoteTypeUrlsResolve } = this;
291
299
  if (isPrd()) {
292
- callback();
300
+ fetchRemoteTypeUrlsResolve(void 0);
293
301
  return;
294
302
  }
295
303
  const normalizedConsumeTypes = normalizeOptions2(true, defaultOptions, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
296
304
  if (!normalizedConsumeTypes) {
297
- callback();
305
+ fetchRemoteTypeUrlsResolve(void 0);
298
306
  return;
299
307
  }
300
308
  const finalOptions = {
@@ -307,10 +315,17 @@ var _ConsumeTypesPlugin = class _ConsumeTypesPlugin {
307
315
  displayErrorInTerminal: dtsOptions.displayErrorInTerminal
308
316
  };
309
317
  validateOptions(finalOptions.host);
310
- const promise = consumeTypes(finalOptions).then(() => {
311
- callback();
312
- }).catch(() => {
313
- callback();
318
+ const fetchRemoteTypeUrlsPromise = typeof normalizedConsumeTypes.remoteTypeUrls === "function" ? normalizedConsumeTypes.remoteTypeUrls() : Promise.resolve(normalizedConsumeTypes.remoteTypeUrls);
319
+ const promise = fetchRemoteTypeUrlsPromise.then((remoteTypeUrls) => {
320
+ consumeTypes(__spreadProps(__spreadValues({}, finalOptions), {
321
+ host: __spreadProps(__spreadValues({}, finalOptions.host), {
322
+ remoteTypeUrls
323
+ })
324
+ })).then(() => {
325
+ fetchRemoteTypeUrlsResolve(remoteTypeUrls);
326
+ }).catch(() => {
327
+ fetchRemoteTypeUrlsResolve(remoteTypeUrls);
328
+ });
314
329
  });
315
330
  compiler.hooks.thisCompilation.tap("mf:generateTypes", (compilation) => {
316
331
  compilation.hooks.processAssets.tapPromise({
@@ -333,25 +348,26 @@ import fs2 from "fs";
333
348
  import path5 from "path";
334
349
  import { normalizeOptions as normalizeOptions3 } from "@module-federation/sdk";
335
350
  var _GenerateTypesPlugin = class _GenerateTypesPlugin {
336
- constructor(pluginOptions, dtsOptions, defaultOptions, consumeTypesPromise, callback) {
351
+ constructor(pluginOptions, dtsOptions, defaultOptions, fetchRemoteTypeUrlsPromise, callback) {
337
352
  __publicField(this, "pluginOptions");
338
353
  __publicField(this, "dtsOptions");
339
354
  __publicField(this, "defaultOptions");
340
- __publicField(this, "consumeTypesPromise");
355
+ __publicField(this, "fetchRemoteTypeUrlsPromise");
341
356
  __publicField(this, "callback");
342
357
  this.pluginOptions = pluginOptions;
343
358
  this.dtsOptions = dtsOptions;
344
359
  this.defaultOptions = defaultOptions;
345
- this.consumeTypesPromise = consumeTypesPromise;
360
+ this.fetchRemoteTypeUrlsPromise = fetchRemoteTypeUrlsPromise;
346
361
  this.callback = callback;
347
362
  }
348
363
  apply(compiler) {
349
- const { dtsOptions, defaultOptions, pluginOptions, consumeTypesPromise, callback } = this;
364
+ const { dtsOptions, defaultOptions, pluginOptions, fetchRemoteTypeUrlsPromise, callback } = this;
350
365
  const normalizedGenerateTypes = normalizeOptions3(true, defaultOptions, "mfOptions.dts.generateTypes")(dtsOptions.generateTypes);
351
366
  if (!normalizedGenerateTypes) {
352
367
  callback();
353
368
  return;
354
369
  }
370
+ const normalizedConsumeTypes = normalizeOptions3(true, defaultOptions, "mfOptions.dts.consumeTypes")(dtsOptions.consumeTypes);
355
371
  const finalOptions = {
356
372
  remote: __spreadValues({
357
373
  implementation: dtsOptions.implementation,
@@ -359,6 +375,10 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
359
375
  outputDir: getCompilerOutputDir(compiler),
360
376
  moduleFederationConfig: pluginOptions
361
377
  }, normalizedGenerateTypes),
378
+ host: normalizedConsumeTypes === false ? void 0 : __spreadValues({
379
+ context: compiler.context,
380
+ moduleFederationConfig: pluginOptions
381
+ }, normalizedGenerateTypes),
362
382
  extraOptions: dtsOptions.extraOptions || {},
363
383
  displayErrorInTerminal: dtsOptions.displayErrorInTerminal
364
384
  };
@@ -466,7 +486,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
466
486
  compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
467
487
  )
468
488
  }, () => __async(this, null, function* () {
469
- yield consumeTypesPromise;
489
+ yield fetchRemoteTypeUrlsPromise;
470
490
  const emitTypesFilesPromise = emitTypesFiles(compilation);
471
491
  if (isProd) {
472
492
  yield emitTypesFilesPromise;
@@ -490,8 +510,8 @@ var _DtsPlugin = class _DtsPlugin {
490
510
  generateAPITypes: true,
491
511
  compileInChildProcess: true,
492
512
  abortOnError: false,
493
- extractThirdParty: true,
494
- extractRemoteTypes: true
513
+ extractThirdParty: false,
514
+ extractRemoteTypes: false
495
515
  };
496
516
  const defaultConsumeTypes = {
497
517
  abortOnError: false,
@@ -506,17 +526,17 @@ var _DtsPlugin = class _DtsPlugin {
506
526
  if (typeof normalizedDtsOptions !== "object") {
507
527
  return;
508
528
  }
509
- let consumeTypesPromiseResolve;
510
- const consumeTypesPromise = new Promise((resolve2) => {
511
- consumeTypesPromiseResolve = resolve2;
529
+ let fetchRemoteTypeUrlsResolve;
530
+ const fetchRemoteTypeUrlsPromise = new Promise((resolve2) => {
531
+ fetchRemoteTypeUrlsResolve = resolve2;
512
532
  });
513
533
  let generateTypesPromiseResolve;
514
534
  const generateTypesPromise = new Promise((resolve2) => {
515
535
  generateTypesPromiseResolve = resolve2;
516
536
  });
517
- new DevPlugin(options, normalizedDtsOptions, generateTypesPromise).apply(compiler);
518
- new GenerateTypesPlugin(options, normalizedDtsOptions, defaultGenerateTypes, consumeTypesPromise, generateTypesPromiseResolve).apply(compiler);
519
- new ConsumeTypesPlugin(options, normalizedDtsOptions, defaultConsumeTypes, consumeTypesPromiseResolve).apply(compiler);
537
+ new DevPlugin(options, normalizedDtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise).apply(compiler);
538
+ new GenerateTypesPlugin(options, normalizedDtsOptions, defaultGenerateTypes, fetchRemoteTypeUrlsPromise, generateTypesPromiseResolve).apply(compiler);
539
+ new ConsumeTypesPlugin(options, normalizedDtsOptions, defaultConsumeTypes, fetchRemoteTypeUrlsResolve).apply(compiler);
520
540
  }
521
541
  };
522
542
  __name(_DtsPlugin, "DtsPlugin");