@module-federation/dts-plugin 0.1.20 → 0.1.21

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,19 @@
1
1
  # @module-federation/dts-plugin
2
2
 
3
+ ## 0.1.21
4
+
5
+ ### Patch Changes
6
+
7
+ - a50c459: fix: use ipv4 first while load local remote
8
+ - 88900ad: fix: support decode encode remote name
9
+ - 4cddb8a: fix: no delete exist types if fetch new types failed
10
+ - 6ee10aa: fix: replace sourceEntry with index if the value is '.'
11
+ - 1e93c5e: fix: use userOptions.typesFolder first
12
+ - Updated dependencies [88900ad]
13
+ - @module-federation/sdk@0.1.21
14
+ - @module-federation/managers@0.1.21
15
+ - @module-federation/third-party-dts-extractor@0.1.21
16
+
3
17
  ## 0.1.20
4
18
 
5
19
  ### Patch Changes
package/dist/core.js CHANGED
@@ -100,12 +100,17 @@ var import_managers2 = require("@module-federation/managers");
100
100
  var import_typescript2 = __toESM(require("typescript"));
101
101
 
102
102
  // packages/dts-plugin/src/core/lib/utils.ts
103
+ var import_fs2 = __toESM(require("fs"));
103
104
  var import_path4 = __toESM(require("path"));
105
+ var import_axios = __toESM(require("axios"));
106
+ var import_http2 = __toESM(require("http"));
107
+ var import_https = __toESM(require("https"));
108
+ var import_ansi_colors3 = __toESM(require("ansi-colors"));
104
109
 
105
110
  // packages/dts-plugin/src/core/lib/DTSManager.ts
106
111
  var import_ansi_colors2 = __toESM(require("ansi-colors"));
107
112
  var import_path3 = __toESM(require("path"));
108
- var import_promises = require("fs/promises");
113
+ var import_promises2 = require("fs/promises");
109
114
  var import_fs = __toESM(require("fs"));
110
115
  var import_sdk4 = require("@module-federation/sdk");
111
116
  var import_lodash = __toESM(require("lodash.clonedeepwith"));
@@ -113,8 +118,8 @@ var import_third_party_dts_extractor2 = require("@module-federation/third-party-
113
118
 
114
119
  // packages/dts-plugin/src/core/lib/archiveHandler.ts
115
120
  var import_adm_zip = __toESM(require("adm-zip"));
116
- var import_axios = __toESM(require("axios"));
117
121
  var import_path2 = require("path");
122
+ var import_promises = require("fs/promises");
118
123
 
119
124
  // packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
120
125
  var import_ansi_colors = __toESM(require("ansi-colors"));
@@ -142,7 +147,10 @@ var createHost = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remote
142
147
  host.writeFile = (filepath, text, writeOrderByteMark, onError, sourceFiles, data) => {
143
148
  originalWriteFile(filepath, text, writeOrderByteMark, onError, sourceFiles, data);
144
149
  for (const sourceFile of sourceFiles || []) {
145
- const sourceEntry = mapExposeToEntry[(0, import_path.normalize)(sourceFile.fileName)];
150
+ let sourceEntry = mapExposeToEntry[(0, import_path.normalize)(sourceFile.fileName)];
151
+ if (sourceEntry === ".") {
152
+ sourceEntry = "index";
153
+ }
146
154
  if (sourceEntry) {
147
155
  const mfeTypeEntry = (0, import_path.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
148
156
  const mfeTypeEntryDirectory = (0, import_path.dirname)(mfeTypeEntry);
@@ -1093,9 +1101,19 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
1093
1101
  while (retries++ < hostOptions.maxRetries) {
1094
1102
  try {
1095
1103
  const url = fileToDownload;
1096
- const response = yield import_axios.default.get(url, {
1104
+ const response = yield axiosGet(url, {
1097
1105
  responseType: "arraybuffer"
1098
1106
  }).catch(downloadErrorLogger(destinationFolder, url));
1107
+ try {
1108
+ if (hostOptions.deleteTypesFolder) {
1109
+ yield (0, import_promises.rm)(destinationPath, {
1110
+ recursive: true,
1111
+ force: true
1112
+ });
1113
+ }
1114
+ } catch (error2) {
1115
+ fileLog(`Unable to remove types folder, ${error2}`, "downloadTypesArchive", "error");
1116
+ }
1099
1117
  const zip = new import_adm_zip.default(Buffer.from(response.data));
1100
1118
  zip.extractAllTo(destinationPath, true);
1101
1119
  return [
@@ -1142,8 +1160,12 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
1142
1160
  }, "buildApiTypeUrl");
1143
1161
  var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
1144
1162
  const { hostOptions, remoteAlias, remote } = options;
1145
- const parsedInfo = (0, import_sdk3.parseEntry)(remote, void 0, "@");
1146
- const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === remote ? remote : "";
1163
+ let decodedRemote = remote;
1164
+ if (decodedRemote.startsWith(import_sdk3.ENCODE_NAME_PREFIX)) {
1165
+ decodedRemote = (0, import_sdk3.decodeName)(decodedRemote, import_sdk3.ENCODE_NAME_PREFIX);
1166
+ }
1167
+ const parsedInfo = (0, import_sdk3.parseEntry)(decodedRemote, void 0, "@");
1168
+ const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
1147
1169
  const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
1148
1170
  return {
1149
1171
  name: parsedInfo.name || remoteAlias,
@@ -1182,7 +1204,6 @@ var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
1182
1204
  }, "retrieveHostConfig");
1183
1205
 
1184
1206
  // packages/dts-plugin/src/core/lib/DTSManager.ts
1185
- var import_axios2 = __toESM(require("axios"));
1186
1207
  var _a;
1187
1208
  var DTSManager = (_a = class {
1188
1209
  constructor(options) {
@@ -1278,11 +1299,17 @@ var DTSManager = (_a = class {
1278
1299
  apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
1279
1300
  import_fs.default.writeFileSync(apiTypesPath, apiTypes);
1280
1301
  }
1281
- if (remoteOptions.deleteTypesFolder) {
1282
- yield (0, import_promises.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
1283
- recursive: true,
1284
- force: true
1285
- });
1302
+ try {
1303
+ if (remoteOptions.deleteTypesFolder) {
1304
+ yield (0, import_promises2.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
1305
+ recursive: true,
1306
+ force: true
1307
+ });
1308
+ }
1309
+ } catch (err) {
1310
+ if (isDebugMode()) {
1311
+ console.error(err);
1312
+ }
1286
1313
  }
1287
1314
  console.log(import_ansi_colors2.default.green("Federated types created correctly"));
1288
1315
  } catch (error2) {
@@ -1301,10 +1328,7 @@ var DTSManager = (_a = class {
1301
1328
  return remoteInfo;
1302
1329
  }
1303
1330
  const url = remoteInfo.url;
1304
- const res = yield (0, import_axios2.default)({
1305
- method: "get",
1306
- url
1307
- });
1331
+ const res = yield axiosGet(url);
1308
1332
  const manifestJson = res.data;
1309
1333
  if (!manifestJson.metaData.types.zip) {
1310
1334
  throw new Error(`Can not get ${remoteInfo.name}'s types archive url!`);
@@ -1353,7 +1377,7 @@ var DTSManager = (_a = class {
1353
1377
  }
1354
1378
  try {
1355
1379
  const url = apiTypeUrl;
1356
- const res = yield import_axios2.default.get(url);
1380
+ const res = yield axiosGet(url);
1357
1381
  let apiTypeFile = res.data;
1358
1382
  apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
1359
1383
  const filePath = import_path3.default.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
@@ -1410,12 +1434,6 @@ var DTSManager = (_a = class {
1410
1434
  consumeArchiveTypes(options) {
1411
1435
  return __async(this, null, function* () {
1412
1436
  const { hostOptions, mapRemotesToDownload } = retrieveHostConfig(options);
1413
- if (hostOptions.deleteTypesFolder) {
1414
- yield (0, import_promises.rm)(hostOptions.typesFolder, {
1415
- recursive: true,
1416
- force: true
1417
- }).catch((error2) => fileLog(`Unable to remove types folder, ${error2}`, "consumeArchiveTypes", "error"));
1418
- }
1419
1437
  const downloadPromises = Object.entries(mapRemotesToDownload).map((item) => __async(this, null, function* () {
1420
1438
  const remoteInfo = item[1];
1421
1439
  if (!this.remoteAliasMap[remoteInfo.alias]) {
@@ -1530,8 +1548,6 @@ var DTSManager = (_a = class {
1530
1548
  }, __name(_a, "DTSManager"), _a);
1531
1549
 
1532
1550
  // packages/dts-plugin/src/core/lib/utils.ts
1533
- var import_fs2 = __toESM(require("fs"));
1534
- var import_ansi_colors3 = __toESM(require("ansi-colors"));
1535
1551
  function getDTSManagerConstructor(implementation) {
1536
1552
  if (implementation) {
1537
1553
  const NewConstructor = require(implementation);
@@ -1580,6 +1596,10 @@ function retrieveTypesAssetsInfo(options) {
1580
1596
  }
1581
1597
  }
1582
1598
  __name(retrieveTypesAssetsInfo, "retrieveTypesAssetsInfo");
1599
+ function isDebugMode() {
1600
+ return Boolean(process.env["FEDERATION_DEBUG"]);
1601
+ }
1602
+ __name(isDebugMode, "isDebugMode");
1583
1603
  var isTSProject = /* @__PURE__ */ __name((dtsOptions, context = process.cwd()) => {
1584
1604
  if (dtsOptions === false) {
1585
1605
  return false;
@@ -1599,6 +1619,21 @@ var isTSProject = /* @__PURE__ */ __name((dtsOptions, context = process.cwd()) =
1599
1619
  return false;
1600
1620
  }
1601
1621
  }, "isTSProject");
1622
+ function axiosGet(url, config) {
1623
+ return __async(this, null, function* () {
1624
+ const httpAgent = new import_http2.default.Agent({
1625
+ family: 4
1626
+ });
1627
+ const httpsAgent = new import_https.default.Agent({
1628
+ family: 4
1629
+ });
1630
+ return import_axios.default.get(url, __spreadValues({
1631
+ httpAgent,
1632
+ httpsAgent
1633
+ }, config));
1634
+ });
1635
+ }
1636
+ __name(axiosGet, "axiosGet");
1602
1637
 
1603
1638
  // packages/dts-plugin/src/core/configurations/remotePlugin.ts
1604
1639
  var defaultOptions2 = {
@@ -32,12 +32,17 @@ import { utils as utils2 } from "@module-federation/managers";
32
32
  import typescript2 from "typescript";
33
33
 
34
34
  // packages/dts-plugin/src/core/lib/utils.ts
35
+ import fs3 from "fs";
35
36
  import path3 from "path";
37
+ import axios from "axios";
38
+ import http from "http";
39
+ import https from "https";
40
+ import ansiColors3 from "ansi-colors";
36
41
 
37
42
  // packages/dts-plugin/src/core/lib/DTSManager.ts
38
43
  import ansiColors2 from "ansi-colors";
39
44
  import path2 from "path";
40
- import { rm } from "fs/promises";
45
+ import { rm as rm2 } from "fs/promises";
41
46
  import fs2 from "fs";
42
47
  import { MANIFEST_EXT, inferAutoPublicPath } from "@module-federation/sdk";
43
48
  import cloneDeepWith from "lodash.clonedeepwith";
@@ -45,8 +50,8 @@ import { ThirdPartyExtractor as ThirdPartyExtractor2 } from "@module-federation/
45
50
 
46
51
  // packages/dts-plugin/src/core/lib/archiveHandler.ts
47
52
  import AdmZip from "adm-zip";
48
- import axios from "axios";
49
53
  import { resolve as resolve2, join as join2 } from "path";
54
+ import { rm } from "fs/promises";
50
55
 
51
56
  // packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
52
57
  import ansiColors from "ansi-colors";
@@ -74,7 +79,10 @@ var createHost = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remote
74
79
  host.writeFile = (filepath, text, writeOrderByteMark, onError, sourceFiles, data) => {
75
80
  originalWriteFile(filepath, text, writeOrderByteMark, onError, sourceFiles, data);
76
81
  for (const sourceFile of sourceFiles || []) {
77
- const sourceEntry = mapExposeToEntry[normalize(sourceFile.fileName)];
82
+ let sourceEntry = mapExposeToEntry[normalize(sourceFile.fileName)];
83
+ if (sourceEntry === ".") {
84
+ sourceEntry = "index";
85
+ }
78
86
  if (sourceEntry) {
79
87
  const mfeTypeEntry = join(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
80
88
  const mfeTypeEntryDirectory = dirname(mfeTypeEntry);
@@ -1422,9 +1430,19 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
1422
1430
  while (retries++ < hostOptions.maxRetries) {
1423
1431
  try {
1424
1432
  const url = fileToDownload;
1425
- const response = yield axios.get(url, {
1433
+ const response = yield axiosGet(url, {
1426
1434
  responseType: "arraybuffer"
1427
1435
  }).catch(downloadErrorLogger(destinationFolder, url));
1436
+ try {
1437
+ if (hostOptions.deleteTypesFolder) {
1438
+ yield rm(destinationPath, {
1439
+ recursive: true,
1440
+ force: true
1441
+ });
1442
+ }
1443
+ } catch (error2) {
1444
+ fileLog(`Unable to remove types folder, ${error2}`, "downloadTypesArchive", "error");
1445
+ }
1428
1446
  const zip = new AdmZip(Buffer.from(response.data));
1429
1447
  zip.extractAllTo(destinationPath, true);
1430
1448
  return [
@@ -1445,7 +1463,7 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
1445
1463
  }, "downloadTypesArchive");
1446
1464
 
1447
1465
  // packages/dts-plugin/src/core/configurations/hostPlugin.ts
1448
- import { parseEntry } from "@module-federation/sdk";
1466
+ import { parseEntry, ENCODE_NAME_PREFIX, decodeName } from "@module-federation/sdk";
1449
1467
  import { utils } from "@module-federation/managers";
1450
1468
  var defaultOptions = {
1451
1469
  typesFolder: "@mf-types",
@@ -1471,8 +1489,12 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
1471
1489
  }, "buildApiTypeUrl");
1472
1490
  var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
1473
1491
  const { hostOptions, remoteAlias, remote } = options;
1474
- const parsedInfo = parseEntry(remote, void 0, "@");
1475
- const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === remote ? remote : "";
1492
+ let decodedRemote = remote;
1493
+ if (decodedRemote.startsWith(ENCODE_NAME_PREFIX)) {
1494
+ decodedRemote = decodeName(decodedRemote, ENCODE_NAME_PREFIX);
1495
+ }
1496
+ const parsedInfo = parseEntry(decodedRemote, void 0, "@");
1497
+ const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
1476
1498
  const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
1477
1499
  return {
1478
1500
  name: parsedInfo.name || remoteAlias,
@@ -1511,7 +1533,6 @@ var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
1511
1533
  }, "retrieveHostConfig");
1512
1534
 
1513
1535
  // packages/dts-plugin/src/core/lib/DTSManager.ts
1514
- import axios2 from "axios";
1515
1536
  var _a;
1516
1537
  var DTSManager = (_a = class {
1517
1538
  constructor(options) {
@@ -1607,11 +1628,17 @@ var DTSManager = (_a = class {
1607
1628
  apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
1608
1629
  fs2.writeFileSync(apiTypesPath, apiTypes);
1609
1630
  }
1610
- if (remoteOptions.deleteTypesFolder) {
1611
- yield rm(retrieveMfTypesPath(tsConfig, remoteOptions), {
1612
- recursive: true,
1613
- force: true
1614
- });
1631
+ try {
1632
+ if (remoteOptions.deleteTypesFolder) {
1633
+ yield rm2(retrieveMfTypesPath(tsConfig, remoteOptions), {
1634
+ recursive: true,
1635
+ force: true
1636
+ });
1637
+ }
1638
+ } catch (err) {
1639
+ if (isDebugMode()) {
1640
+ console.error(err);
1641
+ }
1615
1642
  }
1616
1643
  console.log(ansiColors2.green("Federated types created correctly"));
1617
1644
  } catch (error2) {
@@ -1630,10 +1657,7 @@ var DTSManager = (_a = class {
1630
1657
  return remoteInfo;
1631
1658
  }
1632
1659
  const url = remoteInfo.url;
1633
- const res = yield axios2({
1634
- method: "get",
1635
- url
1636
- });
1660
+ const res = yield axiosGet(url);
1637
1661
  const manifestJson = res.data;
1638
1662
  if (!manifestJson.metaData.types.zip) {
1639
1663
  throw new Error(`Can not get ${remoteInfo.name}'s types archive url!`);
@@ -1682,7 +1706,7 @@ var DTSManager = (_a = class {
1682
1706
  }
1683
1707
  try {
1684
1708
  const url = apiTypeUrl;
1685
- const res = yield axios2.get(url);
1709
+ const res = yield axiosGet(url);
1686
1710
  let apiTypeFile = res.data;
1687
1711
  apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
1688
1712
  const filePath = path2.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
@@ -1739,12 +1763,6 @@ var DTSManager = (_a = class {
1739
1763
  consumeArchiveTypes(options) {
1740
1764
  return __async(this, null, function* () {
1741
1765
  const { hostOptions, mapRemotesToDownload } = retrieveHostConfig(options);
1742
- if (hostOptions.deleteTypesFolder) {
1743
- yield rm(hostOptions.typesFolder, {
1744
- recursive: true,
1745
- force: true
1746
- }).catch((error2) => fileLog(`Unable to remove types folder, ${error2}`, "consumeArchiveTypes", "error"));
1747
- }
1748
1766
  const downloadPromises = Object.entries(mapRemotesToDownload).map((item) => __async(this, null, function* () {
1749
1767
  const remoteInfo = item[1];
1750
1768
  if (!this.remoteAliasMap[remoteInfo.alias]) {
@@ -1859,8 +1877,6 @@ var DTSManager = (_a = class {
1859
1877
  }, __name(_a, "DTSManager"), _a);
1860
1878
 
1861
1879
  // packages/dts-plugin/src/core/lib/utils.ts
1862
- import fs3 from "fs";
1863
- import ansiColors3 from "ansi-colors";
1864
1880
  function getDTSManagerConstructor(implementation) {
1865
1881
  if (implementation) {
1866
1882
  const NewConstructor = __require(implementation);
@@ -1909,6 +1925,10 @@ function retrieveTypesAssetsInfo(options) {
1909
1925
  }
1910
1926
  }
1911
1927
  __name(retrieveTypesAssetsInfo, "retrieveTypesAssetsInfo");
1928
+ function isDebugMode() {
1929
+ return Boolean(process.env["FEDERATION_DEBUG"]);
1930
+ }
1931
+ __name(isDebugMode, "isDebugMode");
1912
1932
  var isTSProject = /* @__PURE__ */ __name((dtsOptions, context = process.cwd()) => {
1913
1933
  if (dtsOptions === false) {
1914
1934
  return false;
@@ -1928,6 +1948,21 @@ var isTSProject = /* @__PURE__ */ __name((dtsOptions, context = process.cwd()) =
1928
1948
  return false;
1929
1949
  }
1930
1950
  }, "isTSProject");
1951
+ function axiosGet(url, config) {
1952
+ return __async(this, null, function* () {
1953
+ const httpAgent = new http.Agent({
1954
+ family: 4
1955
+ });
1956
+ const httpsAgent = new https.Agent({
1957
+ family: 4
1958
+ });
1959
+ return axios.get(url, __spreadValues({
1960
+ httpAgent,
1961
+ httpsAgent
1962
+ }, config));
1963
+ });
1964
+ }
1965
+ __name(axiosGet, "axiosGet");
1931
1966
 
1932
1967
  // packages/dts-plugin/src/core/configurations/remotePlugin.ts
1933
1968
  var defaultOptions2 = {
package/dist/esm/core.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  retrieveTypesZipPath,
15
15
  rpc_exports,
16
16
  validateOptions
17
- } from "./chunk-AJO6KMSF.js";
17
+ } from "./chunk-55BKSNZ4.js";
18
18
  import {
19
19
  HOST_API_TYPES_FILE_NAME,
20
20
  REMOTE_ALIAS_IDENTIFIER,
@@ -9,7 +9,7 @@ import {
9
9
  retrieveRemoteConfig,
10
10
  retrieveTypesZipPath,
11
11
  rpc_exports
12
- } from "./chunk-AJO6KMSF.js";
12
+ } from "./chunk-55BKSNZ4.js";
13
13
  import {
14
14
  getIpFromEntry
15
15
  } from "./chunk-G7ONFBMA.js";
@@ -2,7 +2,7 @@ import {
2
2
  RpcGMCallTypes,
3
3
  exposeRpc,
4
4
  generateTypes
5
- } from "./chunk-AJO6KMSF.js";
5
+ } from "./chunk-55BKSNZ4.js";
6
6
  import {
7
7
  __async,
8
8
  __name
package/dist/esm/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  retrieveTypesAssetsInfo,
8
8
  rpc_exports,
9
9
  validateOptions
10
- } from "./chunk-AJO6KMSF.js";
10
+ } from "./chunk-55BKSNZ4.js";
11
11
  import {
12
12
  WEB_CLIENT_OPTIONS_IDENTIFIER,
13
13
  __async,
@@ -219,7 +219,7 @@ var _DevPlugin = class _DevPlugin {
219
219
  implementation: normalizedDtsOptions === false ? void 0 : normalizedDtsOptions.implementation,
220
220
  context: compiler.context,
221
221
  moduleFederationConfig: this._options,
222
- typesFolder: "@mf-types",
222
+ typesFolder: normalizedConsumeTypes.typesFolder || "@mf-types",
223
223
  abortOnError: false
224
224
  }, normalizedConsumeTypes);
225
225
  const extraOptions = normalizedDtsOptions ? normalizedDtsOptions.extraOptions || {} : {};
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Broker,
3
3
  fileLog
4
- } from "./chunk-AJO6KMSF.js";
4
+ } from "./chunk-55BKSNZ4.js";
5
5
  import {
6
6
  __async,
7
7
  __name
@@ -81,10 +81,16 @@ var import_path5 = require("path");
81
81
  var import_managers2 = require("@module-federation/managers");
82
82
  var import_typescript2 = __toESM(require("typescript"));
83
83
 
84
+ // packages/dts-plugin/src/core/lib/utils.ts
85
+ var import_axios = __toESM(require("axios"));
86
+ var import_http2 = __toESM(require("http"));
87
+ var import_https = __toESM(require("https"));
88
+ var import_ansi_colors3 = __toESM(require("ansi-colors"));
89
+
84
90
  // packages/dts-plugin/src/core/lib/DTSManager.ts
85
91
  var import_ansi_colors2 = __toESM(require("ansi-colors"));
86
92
  var import_path4 = __toESM(require("path"));
87
- var import_promises = require("fs/promises");
93
+ var import_promises2 = require("fs/promises");
88
94
  var import_fs = __toESM(require("fs"));
89
95
  var import_sdk4 = require("@module-federation/sdk");
90
96
  var import_lodash = __toESM(require("lodash.clonedeepwith"));
@@ -92,8 +98,8 @@ var import_third_party_dts_extractor2 = require("@module-federation/third-party-
92
98
 
93
99
  // packages/dts-plugin/src/core/lib/archiveHandler.ts
94
100
  var import_adm_zip = __toESM(require("adm-zip"));
95
- var import_axios = __toESM(require("axios"));
96
101
  var import_path3 = require("path");
102
+ var import_promises = require("fs/promises");
97
103
 
98
104
  // packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
99
105
  var import_ansi_colors = __toESM(require("ansi-colors"));
@@ -121,7 +127,10 @@ var createHost = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remote
121
127
  host.writeFile = (filepath, text, writeOrderByteMark, onError, sourceFiles, data) => {
122
128
  originalWriteFile(filepath, text, writeOrderByteMark, onError, sourceFiles, data);
123
129
  for (const sourceFile of sourceFiles || []) {
124
- const sourceEntry = mapExposeToEntry[(0, import_path.normalize)(sourceFile.fileName)];
130
+ let sourceEntry = mapExposeToEntry[(0, import_path.normalize)(sourceFile.fileName)];
131
+ if (sourceEntry === ".") {
132
+ sourceEntry = "index";
133
+ }
125
134
  if (sourceEntry) {
126
135
  const mfeTypeEntry = (0, import_path.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
127
136
  const mfeTypeEntryDirectory = (0, import_path.dirname)(mfeTypeEntry);
@@ -1601,9 +1610,19 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
1601
1610
  while (retries++ < hostOptions.maxRetries) {
1602
1611
  try {
1603
1612
  const url = fileToDownload;
1604
- const response = yield import_axios.default.get(url, {
1613
+ const response = yield axiosGet(url, {
1605
1614
  responseType: "arraybuffer"
1606
1615
  }).catch(downloadErrorLogger(destinationFolder, url));
1616
+ try {
1617
+ if (hostOptions.deleteTypesFolder) {
1618
+ yield (0, import_promises.rm)(destinationPath, {
1619
+ recursive: true,
1620
+ force: true
1621
+ });
1622
+ }
1623
+ } catch (error2) {
1624
+ fileLog(`Unable to remove types folder, ${error2}`, "downloadTypesArchive", "error");
1625
+ }
1607
1626
  const zip = new import_adm_zip.default(Buffer.from(response.data));
1608
1627
  zip.extractAllTo(destinationPath, true);
1609
1628
  return [
@@ -1650,8 +1669,12 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
1650
1669
  }, "buildApiTypeUrl");
1651
1670
  var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
1652
1671
  const { hostOptions, remoteAlias, remote } = options;
1653
- const parsedInfo = (0, import_sdk3.parseEntry)(remote, void 0, "@");
1654
- const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === remote ? remote : "";
1672
+ let decodedRemote = remote;
1673
+ if (decodedRemote.startsWith(import_sdk3.ENCODE_NAME_PREFIX)) {
1674
+ decodedRemote = (0, import_sdk3.decodeName)(decodedRemote, import_sdk3.ENCODE_NAME_PREFIX);
1675
+ }
1676
+ const parsedInfo = (0, import_sdk3.parseEntry)(decodedRemote, void 0, "@");
1677
+ const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
1655
1678
  const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
1656
1679
  return {
1657
1680
  name: parsedInfo.name || remoteAlias,
@@ -1690,7 +1713,6 @@ var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
1690
1713
  }, "retrieveHostConfig");
1691
1714
 
1692
1715
  // packages/dts-plugin/src/core/lib/DTSManager.ts
1693
- var import_axios2 = __toESM(require("axios"));
1694
1716
  var _a;
1695
1717
  var DTSManager = (_a = class {
1696
1718
  constructor(options) {
@@ -1786,11 +1808,17 @@ var DTSManager = (_a = class {
1786
1808
  apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
1787
1809
  import_fs.default.writeFileSync(apiTypesPath, apiTypes);
1788
1810
  }
1789
- if (remoteOptions.deleteTypesFolder) {
1790
- yield (0, import_promises.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
1791
- recursive: true,
1792
- force: true
1793
- });
1811
+ try {
1812
+ if (remoteOptions.deleteTypesFolder) {
1813
+ yield (0, import_promises2.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
1814
+ recursive: true,
1815
+ force: true
1816
+ });
1817
+ }
1818
+ } catch (err) {
1819
+ if (isDebugMode()) {
1820
+ console.error(err);
1821
+ }
1794
1822
  }
1795
1823
  console.log(import_ansi_colors2.default.green("Federated types created correctly"));
1796
1824
  } catch (error2) {
@@ -1809,10 +1837,7 @@ var DTSManager = (_a = class {
1809
1837
  return remoteInfo;
1810
1838
  }
1811
1839
  const url = remoteInfo.url;
1812
- const res = yield (0, import_axios2.default)({
1813
- method: "get",
1814
- url
1815
- });
1840
+ const res = yield axiosGet(url);
1816
1841
  const manifestJson = res.data;
1817
1842
  if (!manifestJson.metaData.types.zip) {
1818
1843
  throw new Error(`Can not get ${remoteInfo.name}'s types archive url!`);
@@ -1861,7 +1886,7 @@ var DTSManager = (_a = class {
1861
1886
  }
1862
1887
  try {
1863
1888
  const url = apiTypeUrl;
1864
- const res = yield import_axios2.default.get(url);
1889
+ const res = yield axiosGet(url);
1865
1890
  let apiTypeFile = res.data;
1866
1891
  apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
1867
1892
  const filePath = import_path4.default.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
@@ -1918,12 +1943,6 @@ var DTSManager = (_a = class {
1918
1943
  consumeArchiveTypes(options) {
1919
1944
  return __async(this, null, function* () {
1920
1945
  const { hostOptions, mapRemotesToDownload } = retrieveHostConfig(options);
1921
- if (hostOptions.deleteTypesFolder) {
1922
- yield (0, import_promises.rm)(hostOptions.typesFolder, {
1923
- recursive: true,
1924
- force: true
1925
- }).catch((error2) => fileLog(`Unable to remove types folder, ${error2}`, "consumeArchiveTypes", "error"));
1926
- }
1927
1946
  const downloadPromises = Object.entries(mapRemotesToDownload).map((item) => __async(this, null, function* () {
1928
1947
  const remoteInfo = item[1];
1929
1948
  if (!this.remoteAliasMap[remoteInfo.alias]) {
@@ -2038,7 +2057,6 @@ var DTSManager = (_a = class {
2038
2057
  }, __name(_a, "DTSManager"), _a);
2039
2058
 
2040
2059
  // packages/dts-plugin/src/core/lib/utils.ts
2041
- var import_ansi_colors3 = __toESM(require("ansi-colors"));
2042
2060
  function getDTSManagerConstructor(implementation) {
2043
2061
  if (implementation) {
2044
2062
  const NewConstructor = require(implementation);
@@ -2052,6 +2070,25 @@ var validateOptions = /* @__PURE__ */ __name((options) => {
2052
2070
  throw new Error("moduleFederationConfig is required");
2053
2071
  }
2054
2072
  }, "validateOptions");
2073
+ function isDebugMode() {
2074
+ return Boolean(process.env["FEDERATION_DEBUG"]);
2075
+ }
2076
+ __name(isDebugMode, "isDebugMode");
2077
+ function axiosGet(url, config) {
2078
+ return __async(this, null, function* () {
2079
+ const httpAgent = new import_http2.default.Agent({
2080
+ family: 4
2081
+ });
2082
+ const httpsAgent = new import_https.default.Agent({
2083
+ family: 4
2084
+ });
2085
+ return import_axios.default.get(url, __spreadValues({
2086
+ httpAgent,
2087
+ httpsAgent
2088
+ }, config));
2089
+ });
2090
+ }
2091
+ __name(axiosGet, "axiosGet");
2055
2092
 
2056
2093
  // packages/dts-plugin/src/core/configurations/remotePlugin.ts
2057
2094
  var defaultOptions2 = {
@@ -143,6 +143,12 @@ function exposeRpc(fn) {
143
143
  }
144
144
  __name(exposeRpc, "exposeRpc");
145
145
 
146
+ // packages/dts-plugin/src/core/lib/utils.ts
147
+ var import_axios = __toESM(require("axios"));
148
+ var import_http2 = __toESM(require("http"));
149
+ var import_https = __toESM(require("https"));
150
+ var import_ansi_colors3 = __toESM(require("ansi-colors"));
151
+
146
152
  // packages/dts-plugin/src/core/configurations/remotePlugin.ts
147
153
  var import_fs = require("fs");
148
154
  var import_path = require("path");
@@ -226,7 +232,7 @@ var retrieveRemoteConfig = /* @__PURE__ */ __name((options) => {
226
232
  // packages/dts-plugin/src/core/lib/DTSManager.ts
227
233
  var import_ansi_colors2 = __toESM(require("ansi-colors"));
228
234
  var import_path4 = __toESM(require("path"));
229
- var import_promises = require("fs/promises");
235
+ var import_promises2 = require("fs/promises");
230
236
  var import_fs2 = __toESM(require("fs"));
231
237
  var import_sdk4 = require("@module-federation/sdk");
232
238
  var import_lodash2 = __toESM(require("lodash.clonedeepwith"));
@@ -234,8 +240,8 @@ var import_third_party_dts_extractor2 = require("@module-federation/third-party-
234
240
 
235
241
  // packages/dts-plugin/src/core/lib/archiveHandler.ts
236
242
  var import_adm_zip = __toESM(require("adm-zip"));
237
- var import_axios = __toESM(require("axios"));
238
243
  var import_path3 = require("path");
244
+ var import_promises = require("fs/promises");
239
245
 
240
246
  // packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
241
247
  var import_ansi_colors = __toESM(require("ansi-colors"));
@@ -263,7 +269,10 @@ var createHost = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remote
263
269
  host.writeFile = (filepath, text, writeOrderByteMark, onError, sourceFiles, data) => {
264
270
  originalWriteFile(filepath, text, writeOrderByteMark, onError, sourceFiles, data);
265
271
  for (const sourceFile of sourceFiles || []) {
266
- const sourceEntry = mapExposeToEntry[(0, import_path2.normalize)(sourceFile.fileName)];
272
+ let sourceEntry = mapExposeToEntry[(0, import_path2.normalize)(sourceFile.fileName)];
273
+ if (sourceEntry === ".") {
274
+ sourceEntry = "index";
275
+ }
267
276
  if (sourceEntry) {
268
277
  const mfeTypeEntry = (0, import_path2.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
269
278
  const mfeTypeEntryDirectory = (0, import_path2.dirname)(mfeTypeEntry);
@@ -600,8 +609,12 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
600
609
  }, "buildApiTypeUrl");
601
610
  var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
602
611
  const { hostOptions, remoteAlias, remote } = options;
603
- const parsedInfo = (0, import_sdk3.parseEntry)(remote, void 0, "@");
604
- const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === remote ? remote : "";
612
+ let decodedRemote = remote;
613
+ if (decodedRemote.startsWith(import_sdk3.ENCODE_NAME_PREFIX)) {
614
+ decodedRemote = (0, import_sdk3.decodeName)(decodedRemote, import_sdk3.ENCODE_NAME_PREFIX);
615
+ }
616
+ const parsedInfo = (0, import_sdk3.parseEntry)(decodedRemote, void 0, "@");
617
+ const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
605
618
  const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
606
619
  return {
607
620
  name: parsedInfo.name || remoteAlias,
@@ -1449,9 +1462,19 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
1449
1462
  while (retries++ < hostOptions.maxRetries) {
1450
1463
  try {
1451
1464
  const url = fileToDownload;
1452
- const response = yield import_axios.default.get(url, {
1465
+ const response = yield axiosGet(url, {
1453
1466
  responseType: "arraybuffer"
1454
1467
  }).catch(downloadErrorLogger(destinationFolder, url));
1468
+ try {
1469
+ if (hostOptions.deleteTypesFolder) {
1470
+ yield (0, import_promises.rm)(destinationPath, {
1471
+ recursive: true,
1472
+ force: true
1473
+ });
1474
+ }
1475
+ } catch (error2) {
1476
+ fileLog(`Unable to remove types folder, ${error2}`, "downloadTypesArchive", "error");
1477
+ }
1455
1478
  const zip = new import_adm_zip.default(Buffer.from(response.data));
1456
1479
  zip.extractAllTo(destinationPath, true);
1457
1480
  return [
@@ -1472,7 +1495,6 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
1472
1495
  }, "downloadTypesArchive");
1473
1496
 
1474
1497
  // packages/dts-plugin/src/core/lib/DTSManager.ts
1475
- var import_axios2 = __toESM(require("axios"));
1476
1498
  var _a2;
1477
1499
  var DTSManager = (_a2 = class {
1478
1500
  constructor(options) {
@@ -1568,11 +1590,17 @@ var DTSManager = (_a2 = class {
1568
1590
  apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
1569
1591
  import_fs2.default.writeFileSync(apiTypesPath, apiTypes);
1570
1592
  }
1571
- if (remoteOptions.deleteTypesFolder) {
1572
- yield (0, import_promises.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
1573
- recursive: true,
1574
- force: true
1575
- });
1593
+ try {
1594
+ if (remoteOptions.deleteTypesFolder) {
1595
+ yield (0, import_promises2.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
1596
+ recursive: true,
1597
+ force: true
1598
+ });
1599
+ }
1600
+ } catch (err) {
1601
+ if (isDebugMode()) {
1602
+ console.error(err);
1603
+ }
1576
1604
  }
1577
1605
  console.log(import_ansi_colors2.default.green("Federated types created correctly"));
1578
1606
  } catch (error2) {
@@ -1591,10 +1619,7 @@ var DTSManager = (_a2 = class {
1591
1619
  return remoteInfo;
1592
1620
  }
1593
1621
  const url = remoteInfo.url;
1594
- const res = yield (0, import_axios2.default)({
1595
- method: "get",
1596
- url
1597
- });
1622
+ const res = yield axiosGet(url);
1598
1623
  const manifestJson = res.data;
1599
1624
  if (!manifestJson.metaData.types.zip) {
1600
1625
  throw new Error(`Can not get ${remoteInfo.name}'s types archive url!`);
@@ -1643,7 +1668,7 @@ var DTSManager = (_a2 = class {
1643
1668
  }
1644
1669
  try {
1645
1670
  const url = apiTypeUrl;
1646
- const res = yield import_axios2.default.get(url);
1671
+ const res = yield axiosGet(url);
1647
1672
  let apiTypeFile = res.data;
1648
1673
  apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
1649
1674
  const filePath = import_path4.default.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
@@ -1700,12 +1725,6 @@ var DTSManager = (_a2 = class {
1700
1725
  consumeArchiveTypes(options) {
1701
1726
  return __async(this, null, function* () {
1702
1727
  const { hostOptions, mapRemotesToDownload } = retrieveHostConfig(options);
1703
- if (hostOptions.deleteTypesFolder) {
1704
- yield (0, import_promises.rm)(hostOptions.typesFolder, {
1705
- recursive: true,
1706
- force: true
1707
- }).catch((error2) => fileLog(`Unable to remove types folder, ${error2}`, "consumeArchiveTypes", "error"));
1708
- }
1709
1728
  const downloadPromises = Object.entries(mapRemotesToDownload).map((item) => __async(this, null, function* () {
1710
1729
  const remoteInfo = item[1];
1711
1730
  if (!this.remoteAliasMap[remoteInfo.alias]) {
@@ -1820,7 +1839,6 @@ var DTSManager = (_a2 = class {
1820
1839
  }, __name(_a2, "DTSManager"), _a2);
1821
1840
 
1822
1841
  // packages/dts-plugin/src/core/lib/utils.ts
1823
- var import_ansi_colors3 = __toESM(require("ansi-colors"));
1824
1842
  function getDTSManagerConstructor(implementation) {
1825
1843
  if (implementation) {
1826
1844
  const NewConstructor = require(implementation);
@@ -1834,6 +1852,25 @@ var validateOptions = /* @__PURE__ */ __name((options) => {
1834
1852
  throw new Error("moduleFederationConfig is required");
1835
1853
  }
1836
1854
  }, "validateOptions");
1855
+ function isDebugMode() {
1856
+ return Boolean(process.env["FEDERATION_DEBUG"]);
1857
+ }
1858
+ __name(isDebugMode, "isDebugMode");
1859
+ function axiosGet(url, config) {
1860
+ return __async(this, null, function* () {
1861
+ const httpAgent = new import_http2.default.Agent({
1862
+ family: 4
1863
+ });
1864
+ const httpsAgent = new import_https.default.Agent({
1865
+ family: 4
1866
+ });
1867
+ return import_axios.default.get(url, __spreadValues({
1868
+ httpAgent,
1869
+ httpsAgent
1870
+ }, config));
1871
+ });
1872
+ }
1873
+ __name(axiosGet, "axiosGet");
1837
1874
 
1838
1875
  // packages/dts-plugin/src/core/lib/generateTypes.ts
1839
1876
  function generateTypes(options) {
package/dist/index.js CHANGED
@@ -94,12 +94,17 @@ var import_managers2 = require("@module-federation/managers");
94
94
  var import_typescript2 = __toESM(require("typescript"));
95
95
 
96
96
  // packages/dts-plugin/src/core/lib/utils.ts
97
+ var import_fs2 = __toESM(require("fs"));
97
98
  var import_path4 = __toESM(require("path"));
99
+ var import_axios = __toESM(require("axios"));
100
+ var import_http2 = __toESM(require("http"));
101
+ var import_https = __toESM(require("https"));
102
+ var import_ansi_colors3 = __toESM(require("ansi-colors"));
98
103
 
99
104
  // packages/dts-plugin/src/core/lib/DTSManager.ts
100
105
  var import_ansi_colors2 = __toESM(require("ansi-colors"));
101
106
  var import_path3 = __toESM(require("path"));
102
- var import_promises = require("fs/promises");
107
+ var import_promises2 = require("fs/promises");
103
108
  var import_fs = __toESM(require("fs"));
104
109
  var import_sdk4 = require("@module-federation/sdk");
105
110
  var import_lodash = __toESM(require("lodash.clonedeepwith"));
@@ -107,8 +112,8 @@ var import_third_party_dts_extractor2 = require("@module-federation/third-party-
107
112
 
108
113
  // packages/dts-plugin/src/core/lib/archiveHandler.ts
109
114
  var import_adm_zip = __toESM(require("adm-zip"));
110
- var import_axios = __toESM(require("axios"));
111
115
  var import_path2 = require("path");
116
+ var import_promises = require("fs/promises");
112
117
 
113
118
  // packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
114
119
  var import_ansi_colors = __toESM(require("ansi-colors"));
@@ -136,7 +141,10 @@ var createHost = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remote
136
141
  host.writeFile = (filepath, text, writeOrderByteMark, onError, sourceFiles, data) => {
137
142
  originalWriteFile(filepath, text, writeOrderByteMark, onError, sourceFiles, data);
138
143
  for (const sourceFile of sourceFiles || []) {
139
- const sourceEntry = mapExposeToEntry[(0, import_path.normalize)(sourceFile.fileName)];
144
+ let sourceEntry = mapExposeToEntry[(0, import_path.normalize)(sourceFile.fileName)];
145
+ if (sourceEntry === ".") {
146
+ sourceEntry = "index";
147
+ }
140
148
  if (sourceEntry) {
141
149
  const mfeTypeEntry = (0, import_path.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
142
150
  const mfeTypeEntryDirectory = (0, import_path.dirname)(mfeTypeEntry);
@@ -1116,9 +1124,19 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
1116
1124
  while (retries++ < hostOptions.maxRetries) {
1117
1125
  try {
1118
1126
  const url = fileToDownload;
1119
- const response = yield import_axios.default.get(url, {
1127
+ const response = yield axiosGet(url, {
1120
1128
  responseType: "arraybuffer"
1121
1129
  }).catch(downloadErrorLogger(destinationFolder, url));
1130
+ try {
1131
+ if (hostOptions.deleteTypesFolder) {
1132
+ yield (0, import_promises.rm)(destinationPath, {
1133
+ recursive: true,
1134
+ force: true
1135
+ });
1136
+ }
1137
+ } catch (error2) {
1138
+ fileLog(`Unable to remove types folder, ${error2}`, "downloadTypesArchive", "error");
1139
+ }
1122
1140
  const zip = new import_adm_zip.default(Buffer.from(response.data));
1123
1141
  zip.extractAllTo(destinationPath, true);
1124
1142
  return [
@@ -1165,8 +1183,12 @@ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
1165
1183
  }, "buildApiTypeUrl");
1166
1184
  var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
1167
1185
  const { hostOptions, remoteAlias, remote } = options;
1168
- const parsedInfo = (0, import_sdk3.parseEntry)(remote, void 0, "@");
1169
- const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === remote ? remote : "";
1186
+ let decodedRemote = remote;
1187
+ if (decodedRemote.startsWith(import_sdk3.ENCODE_NAME_PREFIX)) {
1188
+ decodedRemote = (0, import_sdk3.decodeName)(decodedRemote, import_sdk3.ENCODE_NAME_PREFIX);
1189
+ }
1190
+ const parsedInfo = (0, import_sdk3.parseEntry)(decodedRemote, void 0, "@");
1191
+ const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
1170
1192
  const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
1171
1193
  return {
1172
1194
  name: parsedInfo.name || remoteAlias,
@@ -1205,7 +1227,6 @@ var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
1205
1227
  }, "retrieveHostConfig");
1206
1228
 
1207
1229
  // packages/dts-plugin/src/core/lib/DTSManager.ts
1208
- var import_axios2 = __toESM(require("axios"));
1209
1230
  var _a;
1210
1231
  var DTSManager = (_a = class {
1211
1232
  constructor(options) {
@@ -1301,11 +1322,17 @@ var DTSManager = (_a = class {
1301
1322
  apiTypesPath = retrieveMfAPITypesPath(tsConfig, remoteOptions);
1302
1323
  import_fs.default.writeFileSync(apiTypesPath, apiTypes);
1303
1324
  }
1304
- if (remoteOptions.deleteTypesFolder) {
1305
- yield (0, import_promises.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
1306
- recursive: true,
1307
- force: true
1308
- });
1325
+ try {
1326
+ if (remoteOptions.deleteTypesFolder) {
1327
+ yield (0, import_promises2.rm)(retrieveMfTypesPath(tsConfig, remoteOptions), {
1328
+ recursive: true,
1329
+ force: true
1330
+ });
1331
+ }
1332
+ } catch (err) {
1333
+ if (isDebugMode()) {
1334
+ console.error(err);
1335
+ }
1309
1336
  }
1310
1337
  console.log(import_ansi_colors2.default.green("Federated types created correctly"));
1311
1338
  } catch (error2) {
@@ -1324,10 +1351,7 @@ var DTSManager = (_a = class {
1324
1351
  return remoteInfo;
1325
1352
  }
1326
1353
  const url = remoteInfo.url;
1327
- const res = yield (0, import_axios2.default)({
1328
- method: "get",
1329
- url
1330
- });
1354
+ const res = yield axiosGet(url);
1331
1355
  const manifestJson = res.data;
1332
1356
  if (!manifestJson.metaData.types.zip) {
1333
1357
  throw new Error(`Can not get ${remoteInfo.name}'s types archive url!`);
@@ -1376,7 +1400,7 @@ var DTSManager = (_a = class {
1376
1400
  }
1377
1401
  try {
1378
1402
  const url = apiTypeUrl;
1379
- const res = yield import_axios2.default.get(url);
1403
+ const res = yield axiosGet(url);
1380
1404
  let apiTypeFile = res.data;
1381
1405
  apiTypeFile = apiTypeFile.replaceAll(REMOTE_ALIAS_IDENTIFIER, remoteInfo.alias);
1382
1406
  const filePath = import_path3.default.join(destinationPath, REMOTE_API_TYPES_FILE_NAME);
@@ -1433,12 +1457,6 @@ var DTSManager = (_a = class {
1433
1457
  consumeArchiveTypes(options) {
1434
1458
  return __async(this, null, function* () {
1435
1459
  const { hostOptions, mapRemotesToDownload } = retrieveHostConfig(options);
1436
- if (hostOptions.deleteTypesFolder) {
1437
- yield (0, import_promises.rm)(hostOptions.typesFolder, {
1438
- recursive: true,
1439
- force: true
1440
- }).catch((error2) => fileLog(`Unable to remove types folder, ${error2}`, "consumeArchiveTypes", "error"));
1441
- }
1442
1460
  const downloadPromises = Object.entries(mapRemotesToDownload).map((item) => __async(this, null, function* () {
1443
1461
  const remoteInfo = item[1];
1444
1462
  if (!this.remoteAliasMap[remoteInfo.alias]) {
@@ -1553,8 +1571,6 @@ var DTSManager = (_a = class {
1553
1571
  }, __name(_a, "DTSManager"), _a);
1554
1572
 
1555
1573
  // packages/dts-plugin/src/core/lib/utils.ts
1556
- var import_fs2 = __toESM(require("fs"));
1557
- var import_ansi_colors3 = __toESM(require("ansi-colors"));
1558
1574
  function getDTSManagerConstructor(implementation) {
1559
1575
  if (implementation) {
1560
1576
  const NewConstructor = require(implementation);
@@ -1603,6 +1619,10 @@ function retrieveTypesAssetsInfo(options) {
1603
1619
  }
1604
1620
  }
1605
1621
  __name(retrieveTypesAssetsInfo, "retrieveTypesAssetsInfo");
1622
+ function isDebugMode() {
1623
+ return Boolean(process.env["FEDERATION_DEBUG"]);
1624
+ }
1625
+ __name(isDebugMode, "isDebugMode");
1606
1626
  var isTSProject = /* @__PURE__ */ __name((dtsOptions, context = process.cwd()) => {
1607
1627
  if (dtsOptions === false) {
1608
1628
  return false;
@@ -1622,6 +1642,21 @@ var isTSProject = /* @__PURE__ */ __name((dtsOptions, context = process.cwd()) =
1622
1642
  return false;
1623
1643
  }
1624
1644
  }, "isTSProject");
1645
+ function axiosGet(url, config) {
1646
+ return __async(this, null, function* () {
1647
+ const httpAgent = new import_http2.default.Agent({
1648
+ family: 4
1649
+ });
1650
+ const httpsAgent = new import_https.default.Agent({
1651
+ family: 4
1652
+ });
1653
+ return import_axios.default.get(url, __spreadValues({
1654
+ httpAgent,
1655
+ httpsAgent
1656
+ }, config));
1657
+ });
1658
+ }
1659
+ __name(axiosGet, "axiosGet");
1625
1660
 
1626
1661
  // packages/dts-plugin/src/core/configurations/remotePlugin.ts
1627
1662
  var defaultOptions2 = {
@@ -2197,7 +2232,7 @@ var _DevPlugin = class _DevPlugin {
2197
2232
  implementation: normalizedDtsOptions === false ? void 0 : normalizedDtsOptions.implementation,
2198
2233
  context: compiler.context,
2199
2234
  moduleFederationConfig: this._options,
2200
- typesFolder: "@mf-types",
2235
+ typesFolder: normalizedConsumeTypes.typesFolder || "@mf-types",
2201
2236
  abortOnError: false
2202
2237
  }, normalizedConsumeTypes);
2203
2238
  const extraOptions = normalizedDtsOptions ? normalizedDtsOptions.extraOptions || {} : {};
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -82,6 +82,10 @@ var import_http = require("http");
82
82
  var import_managers2 = require("@module-federation/managers");
83
83
  var import_typescript2 = __toESM(require("typescript"));
84
84
 
85
+ // packages/dts-plugin/src/core/lib/utils.ts
86
+ var import_axios = __toESM(require("axios"));
87
+ var import_ansi_colors3 = __toESM(require("ansi-colors"));
88
+
85
89
  // packages/dts-plugin/src/core/lib/DTSManager.ts
86
90
  var import_ansi_colors2 = __toESM(require("ansi-colors"));
87
91
  var import_sdk4 = require("@module-federation/sdk");
@@ -90,7 +94,6 @@ var import_third_party_dts_extractor2 = require("@module-federation/third-party-
90
94
 
91
95
  // packages/dts-plugin/src/core/lib/archiveHandler.ts
92
96
  var import_adm_zip = __toESM(require("adm-zip"));
93
- var import_axios = __toESM(require("axios"));
94
97
 
95
98
  // packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
96
99
  var import_ansi_colors = __toESM(require("ansi-colors"));
@@ -406,12 +409,6 @@ var defaultOptions = {
406
409
  consumeAPITypes: false
407
410
  };
408
411
 
409
- // packages/dts-plugin/src/core/lib/DTSManager.ts
410
- var import_axios2 = __toESM(require("axios"));
411
-
412
- // packages/dts-plugin/src/core/lib/utils.ts
413
- var import_ansi_colors3 = __toESM(require("ansi-colors"));
414
-
415
412
  // packages/dts-plugin/src/core/configurations/remotePlugin.ts
416
413
  var defaultOptions2 = {
417
414
  tsConfigPath: "./tsconfig.json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -55,15 +55,15 @@
55
55
  "log4js": "6.9.1",
56
56
  "node-schedule": "2.1.1",
57
57
  "ws": "8.17.0",
58
- "@module-federation/sdk": "0.1.20",
59
- "@module-federation/managers": "0.1.20",
60
- "@module-federation/third-party-dts-extractor": "0.1.20"
58
+ "@module-federation/sdk": "0.1.21",
59
+ "@module-federation/managers": "0.1.21",
60
+ "@module-federation/third-party-dts-extractor": "0.1.21"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/ws": "8.5.10",
64
64
  "@types/koa": "2.11.2",
65
65
  "@types/node-schedule": "2.1.7",
66
- "@module-federation/runtime": "0.1.20"
66
+ "@module-federation/runtime": "0.1.21"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "typescript": "^4.9.0 || ^5.0.0",