@module-federation/dts-plugin 0.11.3 → 0.12.0

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,31 @@
1
1
  # @module-federation/dts-plugin
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Patch Changes
6
+
7
+ - ebef2d0: chore(dts-plugin): optimize type-001 message
8
+ - ef96c4d: feat(dts-plugin): support exclude extract specify third party dts
9
+ - Updated dependencies [c399b9a]
10
+ - Updated dependencies [ef96c4d]
11
+ - Updated dependencies [f4fb242]
12
+ - @module-federation/sdk@0.12.0
13
+ - @module-federation/third-party-dts-extractor@0.12.0
14
+ - @module-federation/managers@0.12.0
15
+ - @module-federation/error-codes@0.12.0
16
+
17
+ ## 0.11.4
18
+
19
+ ### Patch Changes
20
+
21
+ - ed8bda3: remove query strings from exposed modules to fix tsc resolves
22
+ - Updated dependencies [64a2bc1]
23
+ - Updated dependencies [c14842f]
24
+ - @module-federation/sdk@0.11.4
25
+ - @module-federation/managers@0.11.4
26
+ - @module-federation/third-party-dts-extractor@0.11.4
27
+ - @module-federation/error-codes@0.11.4
28
+
3
29
  ## 0.11.3
4
30
 
5
31
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { a as RemoteOptions, D as DTSManagerOptions, R as RemoteInfo, H as HostOptions } from './DTSManagerOptions-c74c59ed.js';
1
+ import { a as RemoteOptions, D as DTSManagerOptions, R as RemoteInfo, H as HostOptions } from './DTSManagerOptions-QVchWb0x.js';
2
2
  import ts from 'typescript';
3
3
 
4
4
  interface TsConfigJson {
@@ -50,4 +50,4 @@ declare class DTSManager {
50
50
  updateTypes(options: UpdateTypesOptions): Promise<void>;
51
51
  }
52
52
 
53
- export { DTSManager as D, TsConfigJson as T, retrieveRemoteConfig as r };
53
+ export { DTSManager as D, type TsConfigJson as T, retrieveRemoteConfig as r };
@@ -29,4 +29,4 @@ interface DTSManagerOptions {
29
29
  displayErrorInTerminal?: moduleFederationPlugin.PluginDtsOptions['displayErrorInTerminal'];
30
30
  }
31
31
 
32
- export { DTSManagerOptions as D, HostOptions as H, RemoteInfo as R, RemoteOptions as a };
32
+ export type { DTSManagerOptions as D, HostOptions as H, RemoteInfo as R, RemoteOptions as a };
@@ -1,6 +1,6 @@
1
1
  import { ChildProcess } from 'child_process';
2
- import { D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
3
- import { D as DTSManager } from './DTSManager-81645796.js';
2
+ import { D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
3
+ import { D as DTSManager } from './DTSManager-b15Gfat3.js';
4
4
 
5
5
  declare enum RpcGMCallTypes {
6
6
  CALL = "mf_call",
@@ -53,4 +53,4 @@ declare class DtsWorker {
53
53
  exit(): void;
54
54
  }
55
55
 
56
- export { DtsWorker as D, RpcRemoteMethod as R, RpcCallMessage as a, RpcGMCallTypes as b, RpcMessage as c, RpcMethod as d, RpcRejectMessage as e, RpcResolveMessage as f, RpcWorker as g, createRpcWorker as h, getRpcWorkerData as i, DtsWorkerOptions as j };
56
+ export { DtsWorker as D, type RpcRemoteMethod as R, type RpcCallMessage as a, RpcGMCallTypes as b, type RpcMessage as c, type RpcMethod as d, type RpcRejectMessage as e, type RpcResolveMessage as f, type RpcWorker as g, createRpcWorker as h, getRpcWorkerData as i, type DtsWorkerOptions as j };
package/dist/core.d.mts CHANGED
@@ -1,9 +1,9 @@
1
- import { T as TsConfigJson } from './DTSManager-81645796.js';
2
- export { D as DTSManager, r as retrieveRemoteConfig } from './DTSManager-81645796.js';
3
- import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
4
- export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-0ec746b7.js';
5
- import { 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-c39c84fb.js';
6
- export { D as DtsWorker } from './DtsWorker-c39c84fb.js';
1
+ import { T as TsConfigJson } from './DTSManager-b15Gfat3.js';
2
+ export { D as DTSManager, r as retrieveRemoteConfig } from './DTSManager-b15Gfat3.js';
3
+ import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
4
+ export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-BjKKtOcx.js';
5
+ import { 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-BrHsGz8C.js';
6
+ export { D as DtsWorker } from './DtsWorker-BrHsGz8C.js';
7
7
  import { ChildProcess } from 'child_process';
8
8
  import 'typescript';
9
9
  import '@module-federation/sdk';
@@ -56,21 +56,7 @@ declare const index_exposeRpc: typeof exposeRpc;
56
56
  declare const index_getRpcWorkerData: typeof getRpcWorkerData;
57
57
  declare const index_wrapRpc: typeof wrapRpc;
58
58
  declare namespace index {
59
- export {
60
- index_RpcCallMessage as RpcCallMessage,
61
- index_RpcExitError as RpcExitError,
62
- index_RpcGMCallTypes as RpcGMCallTypes,
63
- index_RpcMessage as RpcMessage,
64
- index_RpcMethod as RpcMethod,
65
- index_RpcRejectMessage as RpcRejectMessage,
66
- index_RpcRemoteMethod as RpcRemoteMethod,
67
- index_RpcResolveMessage as RpcResolveMessage,
68
- index_RpcWorker as RpcWorker,
69
- index_createRpcWorker as createRpcWorker,
70
- index_exposeRpc as exposeRpc,
71
- index_getRpcWorkerData as getRpcWorkerData,
72
- index_wrapRpc as wrapRpc,
73
- };
59
+ export { index_RpcCallMessage as RpcCallMessage, index_RpcExitError as RpcExitError, index_RpcGMCallTypes as RpcGMCallTypes, index_RpcMessage as RpcMessage, index_RpcMethod as RpcMethod, index_RpcRejectMessage as RpcRejectMessage, index_RpcRemoteMethod as RpcRemoteMethod, index_RpcResolveMessage as RpcResolveMessage, index_RpcWorker as RpcWorker, index_createRpcWorker as createRpcWorker, index_exposeRpc as exposeRpc, index_getRpcWorkerData as getRpcWorkerData, index_wrapRpc as wrapRpc };
74
60
  }
75
61
 
76
62
  declare function consumeTypes(options: DTSManagerOptions): Promise<void>;
package/dist/core.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { T as TsConfigJson } from './DTSManager-81645796.js';
2
- export { D as DTSManager, r as retrieveRemoteConfig } from './DTSManager-81645796.js';
3
- import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
4
- export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-0ec746b7.js';
5
- import { 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-c39c84fb.js';
6
- export { D as DtsWorker } from './DtsWorker-c39c84fb.js';
1
+ import { T as TsConfigJson } from './DTSManager-b15Gfat3.js';
2
+ export { D as DTSManager, r as retrieveRemoteConfig } from './DTSManager-b15Gfat3.js';
3
+ import { H as HostOptions, R as RemoteInfo, a as RemoteOptions, D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
4
+ export { g as getDTSManagerConstructor, i as isTSProject, r as retrieveTypesAssetsInfo, v as validateOptions } from './utils-BjKKtOcx.js';
5
+ import { 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-BrHsGz8C.js';
6
+ export { D as DtsWorker } from './DtsWorker-BrHsGz8C.js';
7
7
  import { ChildProcess } from 'child_process';
8
8
  import 'typescript';
9
9
  import '@module-federation/sdk';
@@ -56,21 +56,7 @@ declare const index_exposeRpc: typeof exposeRpc;
56
56
  declare const index_getRpcWorkerData: typeof getRpcWorkerData;
57
57
  declare const index_wrapRpc: typeof wrapRpc;
58
58
  declare namespace index {
59
- export {
60
- index_RpcCallMessage as RpcCallMessage,
61
- index_RpcExitError as RpcExitError,
62
- index_RpcGMCallTypes as RpcGMCallTypes,
63
- index_RpcMessage as RpcMessage,
64
- index_RpcMethod as RpcMethod,
65
- index_RpcRejectMessage as RpcRejectMessage,
66
- index_RpcRemoteMethod as RpcRemoteMethod,
67
- index_RpcResolveMessage as RpcResolveMessage,
68
- index_RpcWorker as RpcWorker,
69
- index_createRpcWorker as createRpcWorker,
70
- index_exposeRpc as exposeRpc,
71
- index_getRpcWorkerData as getRpcWorkerData,
72
- index_wrapRpc as wrapRpc,
73
- };
59
+ export { index_RpcCallMessage as RpcCallMessage, index_RpcExitError as RpcExitError, index_RpcGMCallTypes as RpcGMCallTypes, index_RpcMessage as RpcMessage, index_RpcMethod as RpcMethod, index_RpcRejectMessage as RpcRejectMessage, index_RpcRemoteMethod as RpcRemoteMethod, index_RpcResolveMessage as RpcResolveMessage, index_RpcWorker as RpcWorker, index_createRpcWorker as createRpcWorker, index_exposeRpc as exposeRpc, index_getRpcWorkerData as getRpcWorkerData, index_wrapRpc as wrapRpc };
74
60
  }
75
61
 
76
62
  declare function consumeTypes(options: DTSManagerOptions): Promise<void>;
package/dist/core.js CHANGED
@@ -213,7 +213,11 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
213
213
  const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a3 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a3.cwd) != null ? _b : void 0 : void 0);
214
214
  try {
215
215
  const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
216
- const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor((0, import_path.resolve)(mfTypePath, "node_modules"), remoteOptions.context);
216
+ const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
217
+ destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
218
+ context: remoteOptions.context,
219
+ exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
220
+ });
217
221
  const execPromise = import_util.default.promisify(import_child_process.exec);
218
222
  const cmd = `npx ${remoteOptions.compilerInstance} --project ${tempTsConfigJsonPath}`;
219
223
  try {
@@ -221,6 +225,12 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
221
225
  cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
222
226
  });
223
227
  } catch (err) {
228
+ if (compilerOptions.tsBuildInfoFile) {
229
+ try {
230
+ yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
231
+ } catch (e) {
232
+ }
233
+ }
224
234
  throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
225
235
  cmd
226
236
  }));
@@ -1439,7 +1449,7 @@ var DTSManager = (_a = class {
1439
1449
  } catch (error2) {
1440
1450
  if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
1441
1451
  if (this.options.displayErrorInTerminal) {
1442
- logger.error(`Unable to compile federated types ${error2}`);
1452
+ logger.error(error2);
1443
1453
  }
1444
1454
  } else {
1445
1455
  throw error2;
@@ -1538,7 +1548,9 @@ var DTSManager = (_a = class {
1538
1548
  const apiTypeFileName = import_path3.default.join(hostOptions.context, hostOptions.typesFolder, HOST_API_TYPES_FILE_NAME);
1539
1549
  try {
1540
1550
  const existedFile = import_fs.default.readFileSync(apiTypeFileName, "utf-8");
1541
- const existedImports = new import_third_party_dts_extractor2.ThirdPartyExtractor("").collectTypeImports(existedFile);
1551
+ const existedImports = new import_third_party_dts_extractor2.ThirdPartyExtractor({
1552
+ destDir: ""
1553
+ }).collectTypeImports(existedFile);
1542
1554
  existedImports.forEach((existedImport) => {
1543
1555
  const alias = existedImport.split("./").slice(1).join("./").replace("/apis.d.ts", "");
1544
1556
  this.loadedRemoteAPIAlias.add(alias);
@@ -1815,6 +1827,11 @@ function cloneDeepOptions(options) {
1815
1827
  if (typeof value === "function") {
1816
1828
  return false;
1817
1829
  }
1830
+ if (key === "extractThirdParty" && Array.isArray(value)) {
1831
+ return value.map((item) => {
1832
+ return item.toString();
1833
+ });
1834
+ }
1818
1835
  });
1819
1836
  }
1820
1837
  __name(cloneDeepOptions, "cloneDeepOptions");
@@ -1878,7 +1895,7 @@ function getEffectiveRootDir(parsedCommandLine) {
1878
1895
  throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
1879
1896
  }
1880
1897
  __name(getEffectiveRootDir, "getEffectiveRootDir");
1881
- var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
1898
+ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
1882
1899
  const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
1883
1900
  const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
1884
1901
  if (readResult.error) {
@@ -1902,9 +1919,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
1902
1919
  }, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
1903
1920
  const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
1904
1921
  rawTsConfigJson.compilerOptions = restCompilerOptions;
1922
+ const outDirWithoutTypesFolder = (0, import_path5.resolve)(context, outputDir || configContent.options.outDir || "dist");
1905
1923
  const filesToCompile = [
1906
1924
  ...Object.values(mapComponentsToExpose),
1907
- ...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts")),
1925
+ ...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
1908
1926
  ...additionalFilesToCompile
1909
1927
  ];
1910
1928
  rawTsConfigJson.include = [];
@@ -8,7 +8,7 @@ import {
8
8
  getIPV4,
9
9
  getIdentifier,
10
10
  logger
11
- } from "./chunk-56UE3H52.js";
11
+ } from "./chunk-Y5Q47C4P.js";
12
12
  import {
13
13
  AddPublisherAction,
14
14
  AddSubscriberAction,
@@ -27,7 +27,7 @@ import {
27
27
  __require,
28
28
  __spreadProps,
29
29
  __spreadValues
30
- } from "./chunk-SPSJLB6F.js";
30
+ } from "./chunk-3I5UINHZ.js";
31
31
 
32
32
  // packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
33
33
  import { ensureDirSync, writeFileSync, existsSync } from "fs-extra";
@@ -110,7 +110,11 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
110
110
  const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a2 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a2.cwd) != null ? _b : void 0 : void 0);
111
111
  try {
112
112
  const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
113
- const thirdPartyExtractor = new ThirdPartyExtractor(resolve(mfTypePath, "node_modules"), remoteOptions.context);
113
+ const thirdPartyExtractor = new ThirdPartyExtractor({
114
+ destDir: resolve(mfTypePath, "node_modules"),
115
+ context: remoteOptions.context,
116
+ exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
117
+ });
114
118
  const execPromise = util.promisify(exec);
115
119
  const cmd = `npx ${remoteOptions.compilerInstance} --project ${tempTsConfigJsonPath}`;
116
120
  try {
@@ -118,6 +122,12 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
118
122
  cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
119
123
  });
120
124
  } catch (err) {
125
+ if (compilerOptions.tsBuildInfoFile) {
126
+ try {
127
+ yield rm(compilerOptions.tsBuildInfoFile);
128
+ } catch (e) {
129
+ }
130
+ }
121
131
  throw new Error(getShortErrorMsg(TYPE_001, typeDescMap, {
122
132
  cmd
123
133
  }));
@@ -619,7 +629,7 @@ function getEffectiveRootDir(parsedCommandLine) {
619
629
  throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
620
630
  }
621
631
  __name(getEffectiveRootDir, "getEffectiveRootDir");
622
- var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
632
+ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
623
633
  const resolvedTsConfigPath = resolve2(context, tsConfigPath);
624
634
  const readResult = typescript.readConfigFile(resolvedTsConfigPath, typescript.sys.readFile);
625
635
  if (readResult.error) {
@@ -643,9 +653,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
643
653
  }, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
644
654
  const _a2 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a2, restCompilerOptions = __objRest(_a2, ["paths", "baseUrl"]);
645
655
  rawTsConfigJson.compilerOptions = restCompilerOptions;
656
+ const outDirWithoutTypesFolder = resolve2(context, outputDir || configContent.options.outDir || "dist");
646
657
  const filesToCompile = [
647
658
  ...Object.values(mapComponentsToExpose),
648
- ...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts")),
659
+ ...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
649
660
  ...additionalFilesToCompile
650
661
  ];
651
662
  rawTsConfigJson.include = [];
@@ -955,7 +966,7 @@ var DTSManager = (_a = class {
955
966
  } catch (error) {
956
967
  if (((_a2 = this.options.remote) == null ? void 0 : _a2.abortOnError) === false) {
957
968
  if (this.options.displayErrorInTerminal) {
958
- logger.error(`Unable to compile federated types ${error}`);
969
+ logger.error(error);
959
970
  }
960
971
  } else {
961
972
  throw error;
@@ -1054,7 +1065,9 @@ var DTSManager = (_a = class {
1054
1065
  const apiTypeFileName = path2.join(hostOptions.context, hostOptions.typesFolder, HOST_API_TYPES_FILE_NAME);
1055
1066
  try {
1056
1067
  const existedFile = fs2.readFileSync(apiTypeFileName, "utf-8");
1057
- const existedImports = new ThirdPartyExtractor2("").collectTypeImports(existedFile);
1068
+ const existedImports = new ThirdPartyExtractor2({
1069
+ destDir: ""
1070
+ }).collectTypeImports(existedFile);
1058
1071
  existedImports.forEach((existedImport) => {
1059
1072
  const alias = existedImport.split("./").slice(1).join("./").replace("/apis.d.ts", "");
1060
1073
  this.loadedRemoteAPIAlias.add(alias);
@@ -1331,6 +1344,11 @@ function cloneDeepOptions(options) {
1331
1344
  if (typeof value === "function") {
1332
1345
  return false;
1333
1346
  }
1347
+ if (key === "extractThirdParty" && Array.isArray(value)) {
1348
+ return value.map((item) => {
1349
+ return item.toString();
1350
+ });
1351
+ }
1334
1352
  });
1335
1353
  }
1336
1354
  __name(cloneDeepOptions, "cloneDeepOptions");
@@ -4,7 +4,7 @@ import {
4
4
  exposeRpc,
5
5
  getDTSManagerConstructor,
6
6
  isDebugMode
7
- } from "./chunk-A4MGPQ34.js";
7
+ } from "./chunk-C52DTW7U.js";
8
8
  import {
9
9
  __async,
10
10
  __export,
@@ -12,7 +12,7 @@ import {
12
12
  __publicField,
13
13
  __spreadProps,
14
14
  __spreadValues
15
- } from "./chunk-SPSJLB6F.js";
15
+ } from "./chunk-3I5UINHZ.js";
16
16
 
17
17
  // packages/dts-plugin/src/core/lib/DtsWorker.ts
18
18
  import path from "path";
@@ -9,7 +9,7 @@ import {
9
9
  __async,
10
10
  __name,
11
11
  __publicField
12
- } from "./chunk-SPSJLB6F.js";
12
+ } from "./chunk-3I5UINHZ.js";
13
13
 
14
14
  // packages/dts-plugin/src/server/utils/log.ts
15
15
  import { createLogger } from "@module-federation/sdk";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-SPSJLB6F.js";
3
+ } from "./chunk-3I5UINHZ.js";
4
4
 
5
5
  // packages/dts-plugin/src/dev-worker/utils.ts
6
6
  var DEFAULT_LOCAL_IPS = [
package/dist/esm/core.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  consumeTypes,
4
4
  generateTypesInChildProcess,
5
5
  rpc_exports
6
- } from "./chunk-GX5A7XT2.js";
6
+ } from "./chunk-QDIWQJEJ.js";
7
7
  import {
8
8
  DTSManager,
9
9
  HOST_API_TYPES_FILE_NAME,
@@ -19,9 +19,9 @@ import {
19
19
  retrieveTypesAssetsInfo,
20
20
  retrieveTypesZipPath,
21
21
  validateOptions
22
- } from "./chunk-A4MGPQ34.js";
23
- import "./chunk-56UE3H52.js";
24
- import "./chunk-SPSJLB6F.js";
22
+ } from "./chunk-C52DTW7U.js";
23
+ import "./chunk-Y5Q47C4P.js";
24
+ import "./chunk-3I5UINHZ.js";
25
25
  export {
26
26
  DTSManager,
27
27
  DtsWorker,
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  getIpFromEntry
3
- } from "./chunk-L22LIZUP.js";
3
+ } from "./chunk-YPIQPQRG.js";
4
4
  import {
5
5
  AddDynamicRemoteAction,
6
6
  DEFAULT_WEB_SOCKET_PORT,
7
7
  FetchTypesAction,
8
8
  WEB_SOCKET_CONNECT_MAGIC_ID,
9
9
  __name
10
- } from "./chunk-SPSJLB6F.js";
10
+ } from "./chunk-3I5UINHZ.js";
11
11
 
12
12
  // packages/dts-plugin/src/server/createWebsocket.ts
13
13
  import WebSocket from "isomorphic-ws";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  rpc_exports
3
- } from "./chunk-GX5A7XT2.js";
3
+ } from "./chunk-QDIWQJEJ.js";
4
4
  import {
5
5
  ModuleFederationDevServer,
6
6
  createKoaServer,
@@ -9,21 +9,21 @@ import {
9
9
  retrieveMfTypesPath,
10
10
  retrieveRemoteConfig,
11
11
  retrieveTypesZipPath
12
- } from "./chunk-A4MGPQ34.js";
12
+ } from "./chunk-C52DTW7U.js";
13
13
  import {
14
14
  fileLog,
15
15
  getIPV4
16
- } from "./chunk-56UE3H52.js";
16
+ } from "./chunk-Y5Q47C4P.js";
17
17
  import {
18
18
  getIpFromEntry
19
- } from "./chunk-L22LIZUP.js";
19
+ } from "./chunk-YPIQPQRG.js";
20
20
  import {
21
21
  DEFAULT_TAR_NAME,
22
22
  UpdateKind,
23
23
  UpdateMode,
24
24
  __async,
25
25
  __name
26
- } from "./chunk-SPSJLB6F.js";
26
+ } from "./chunk-3I5UINHZ.js";
27
27
 
28
28
  // packages/dts-plugin/src/dev-worker/forkDevWorker.ts
29
29
  import { decodeName } from "@module-federation/sdk";
@@ -2,12 +2,12 @@ import {
2
2
  RpcGMCallTypes,
3
3
  exposeRpc,
4
4
  generateTypes
5
- } from "./chunk-A4MGPQ34.js";
6
- import "./chunk-56UE3H52.js";
5
+ } from "./chunk-C52DTW7U.js";
6
+ import "./chunk-Y5Q47C4P.js";
7
7
  import {
8
8
  __async,
9
9
  __name
10
- } from "./chunk-SPSJLB6F.js";
10
+ } from "./chunk-3I5UINHZ.js";
11
11
 
12
12
  // packages/dts-plugin/src/core/lib/forkGenerateDts.ts
13
13
  function forkGenerateDts(options) {
package/dist/esm/index.js CHANGED
@@ -2,18 +2,18 @@ import {
2
2
  consumeTypes,
3
3
  generateTypesInChildProcess,
4
4
  rpc_exports
5
- } from "./chunk-GX5A7XT2.js";
5
+ } from "./chunk-QDIWQJEJ.js";
6
6
  import {
7
7
  cloneDeepOptions,
8
8
  generateTypes,
9
9
  isTSProject,
10
10
  retrieveTypesAssetsInfo,
11
11
  validateOptions
12
- } from "./chunk-A4MGPQ34.js";
12
+ } from "./chunk-C52DTW7U.js";
13
13
  import {
14
14
  getIPV4,
15
15
  logger
16
- } from "./chunk-56UE3H52.js";
16
+ } from "./chunk-Y5Q47C4P.js";
17
17
  import {
18
18
  WEB_CLIENT_OPTIONS_IDENTIFIER,
19
19
  __async,
@@ -21,7 +21,7 @@ import {
21
21
  __publicField,
22
22
  __spreadProps,
23
23
  __spreadValues
24
- } from "./chunk-SPSJLB6F.js";
24
+ } from "./chunk-3I5UINHZ.js";
25
25
 
26
26
  // packages/dts-plugin/src/plugins/DevPlugin.ts
27
27
  import fs from "fs-extra";
@@ -460,10 +460,10 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
460
460
  if (isProd) {
461
461
  const zipAssetName = path5.join(zipPrefix, zipName);
462
462
  const apiAssetName = path5.join(zipPrefix, apiFileName);
463
- if (zipTypesPath && !compilation.getAsset(zipAssetName)) {
463
+ if (zipTypesPath && !compilation.getAsset(zipAssetName) && fs2.existsSync(zipTypesPath)) {
464
464
  compilation.emitAsset(zipAssetName, new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
465
465
  }
466
- if (apiTypesPath && !compilation.getAsset(apiAssetName)) {
466
+ if (apiTypesPath && !compilation.getAsset(apiAssetName) && fs2.existsSync(apiTypesPath)) {
467
467
  compilation.emitAsset(apiAssetName, new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
468
468
  }
469
469
  callback();
@@ -471,7 +471,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
471
471
  const isEEXIST = /* @__PURE__ */ __name((err) => {
472
472
  return err.code == "EEXIST";
473
473
  }, "isEEXIST");
474
- if (zipTypesPath) {
474
+ if (zipTypesPath && fs2.existsSync(zipTypesPath)) {
475
475
  const zipContent = fs2.readFileSync(zipTypesPath);
476
476
  const zipOutputPath = path5.join(compiler.outputPath, zipPrefix, zipName);
477
477
  yield new Promise((resolve2, reject) => {
@@ -502,7 +502,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
502
502
  );
503
503
  });
504
504
  }
505
- if (apiTypesPath) {
505
+ if (apiTypesPath && fs2.existsSync(apiTypesPath)) {
506
506
  const apiContent = fs2.readFileSync(apiTypesPath);
507
507
  const apiOutputPath = path5.join(compiler.outputPath, zipPrefix, apiFileName);
508
508
  yield new Promise((resolve2, reject) => {
@@ -538,7 +538,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
538
538
  } catch (err) {
539
539
  callback();
540
540
  if (dtsManagerOptions.displayErrorInTerminal) {
541
- console.error("Error in mf:generateTypes processAssets hook:", err);
541
+ console.error(err);
542
542
  }
543
543
  logger3.debug("generate types fail!");
544
544
  }
@@ -579,7 +579,19 @@ var _DtsPlugin = class _DtsPlugin {
579
579
  }
580
580
  apply(compiler) {
581
581
  const { options } = this;
582
- const normalizedDtsOptions = normalizeDtsOptions(options, compiler.context);
582
+ const clonedOptions = __spreadValues({}, options);
583
+ if (options.exposes && typeof options.exposes === "object") {
584
+ const cleanedExposes = {};
585
+ Object.entries(options.exposes).forEach(([key, value]) => {
586
+ if (typeof value === "string") {
587
+ cleanedExposes[key] = value.split("?")[0];
588
+ } else {
589
+ cleanedExposes[key] = value;
590
+ }
591
+ });
592
+ clonedOptions.exposes = cleanedExposes;
593
+ }
594
+ const normalizedDtsOptions = normalizeDtsOptions(clonedOptions, compiler.context);
583
595
  if (typeof normalizedDtsOptions !== "object") {
584
596
  return;
585
597
  }
@@ -591,9 +603,9 @@ var _DtsPlugin = class _DtsPlugin {
591
603
  const generateTypesPromise = new Promise((resolve2) => {
592
604
  generateTypesPromiseResolve = resolve2;
593
605
  });
594
- new DevPlugin(options, normalizedDtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise).apply(compiler);
595
- new GenerateTypesPlugin(options, normalizedDtsOptions, fetchRemoteTypeUrlsPromise, generateTypesPromiseResolve).apply(compiler);
596
- new ConsumeTypesPlugin(options, normalizedDtsOptions, fetchRemoteTypeUrlsResolve).apply(compiler);
606
+ new DevPlugin(clonedOptions, normalizedDtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise).apply(compiler);
607
+ new GenerateTypesPlugin(clonedOptions, normalizedDtsOptions, fetchRemoteTypeUrlsPromise, generateTypesPromiseResolve).apply(compiler);
608
+ new ConsumeTypesPlugin(clonedOptions, normalizedDtsOptions, fetchRemoteTypeUrlsResolve).apply(compiler);
597
609
  }
598
610
  };
599
611
  __name(_DtsPlugin, "DtsPlugin");
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  Broker,
3
3
  fileLog
4
- } from "./chunk-56UE3H52.js";
4
+ } from "./chunk-Y5Q47C4P.js";
5
5
  import {
6
6
  __async,
7
7
  __name
8
- } from "./chunk-SPSJLB6F.js";
8
+ } from "./chunk-3I5UINHZ.js";
9
9
 
10
10
  // packages/dts-plugin/src/server/broker/startBroker.ts
11
11
  var broker;
@@ -1,4 +1,4 @@
1
- import { D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
1
+ import { D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
2
2
  import '@module-federation/sdk';
3
3
 
4
4
  interface DevWorkerOptions extends DTSManagerOptions {
@@ -1,4 +1,4 @@
1
- import { D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
1
+ import { D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
2
2
  import '@module-federation/sdk';
3
3
 
4
4
  interface DevWorkerOptions extends DTSManagerOptions {
@@ -194,7 +194,11 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
194
194
  const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a3 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a3.cwd) != null ? _b : void 0 : void 0);
195
195
  try {
196
196
  const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
197
- const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor((0, import_path.resolve)(mfTypePath, "node_modules"), remoteOptions.context);
197
+ const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
198
+ destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
199
+ context: remoteOptions.context,
200
+ exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
201
+ });
198
202
  const execPromise = import_util.default.promisify(import_child_process.exec);
199
203
  const cmd = `npx ${remoteOptions.compilerInstance} --project ${tempTsConfigJsonPath}`;
200
204
  try {
@@ -202,6 +206,12 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
202
206
  cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
203
207
  });
204
208
  } catch (err) {
209
+ if (compilerOptions.tsBuildInfoFile) {
210
+ try {
211
+ yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
212
+ } catch (e) {
213
+ }
214
+ }
205
215
  throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
206
216
  cmd
207
217
  }));
@@ -1959,7 +1969,7 @@ var DTSManager = (_a = class {
1959
1969
  } catch (error2) {
1960
1970
  if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
1961
1971
  if (this.options.displayErrorInTerminal) {
1962
- logger.error(`Unable to compile federated types ${error2}`);
1972
+ logger.error(error2);
1963
1973
  }
1964
1974
  } else {
1965
1975
  throw error2;
@@ -2058,7 +2068,9 @@ var DTSManager = (_a = class {
2058
2068
  const apiTypeFileName = import_path4.default.join(hostOptions.context, hostOptions.typesFolder, HOST_API_TYPES_FILE_NAME);
2059
2069
  try {
2060
2070
  const existedFile = import_fs.default.readFileSync(apiTypeFileName, "utf-8");
2061
- const existedImports = new import_third_party_dts_extractor2.ThirdPartyExtractor("").collectTypeImports(existedFile);
2071
+ const existedImports = new import_third_party_dts_extractor2.ThirdPartyExtractor({
2072
+ destDir: ""
2073
+ }).collectTypeImports(existedFile);
2062
2074
  existedImports.forEach((existedImport) => {
2063
2075
  const alias = existedImport.split("./").slice(1).join("./").replace("/apis.d.ts", "");
2064
2076
  this.loadedRemoteAPIAlias.add(alias);
@@ -2269,6 +2281,11 @@ function cloneDeepOptions(options) {
2269
2281
  if (typeof value === "function") {
2270
2282
  return false;
2271
2283
  }
2284
+ if (key === "extractThirdParty" && Array.isArray(value)) {
2285
+ return value.map((item) => {
2286
+ return item.toString();
2287
+ });
2288
+ }
2272
2289
  });
2273
2290
  }
2274
2291
  __name(cloneDeepOptions, "cloneDeepOptions");
@@ -2332,7 +2349,7 @@ function getEffectiveRootDir(parsedCommandLine) {
2332
2349
  throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
2333
2350
  }
2334
2351
  __name(getEffectiveRootDir, "getEffectiveRootDir");
2335
- var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
2352
+ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
2336
2353
  const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
2337
2354
  const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
2338
2355
  if (readResult.error) {
@@ -2356,9 +2373,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
2356
2373
  }, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
2357
2374
  const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
2358
2375
  rawTsConfigJson.compilerOptions = restCompilerOptions;
2376
+ const outDirWithoutTypesFolder = (0, import_path5.resolve)(context, outputDir || configContent.options.outDir || "dist");
2359
2377
  const filesToCompile = [
2360
2378
  ...Object.values(mapComponentsToExpose),
2361
- ...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts")),
2379
+ ...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
2362
2380
  ...additionalFilesToCompile
2363
2381
  ];
2364
2382
  rawTsConfigJson.include = [];
@@ -1,8 +1,8 @@
1
- import { j as DtsWorkerOptions } from './DtsWorker-c39c84fb.js';
1
+ import { j as DtsWorkerOptions } from './DtsWorker-BrHsGz8C.js';
2
2
  import 'child_process';
3
- import './DTSManagerOptions-c74c59ed.js';
3
+ import './DTSManagerOptions-QVchWb0x.js';
4
4
  import '@module-federation/sdk';
5
- import './DTSManager-81645796.js';
5
+ import './DTSManager-b15Gfat3.js';
6
6
  import 'typescript';
7
7
 
8
8
  declare function forkGenerateDts(options: DtsWorkerOptions): Promise<void>;
@@ -1,8 +1,8 @@
1
- import { j as DtsWorkerOptions } from './DtsWorker-c39c84fb.js';
1
+ import { j as DtsWorkerOptions } from './DtsWorker-BrHsGz8C.js';
2
2
  import 'child_process';
3
- import './DTSManagerOptions-c74c59ed.js';
3
+ import './DTSManagerOptions-QVchWb0x.js';
4
4
  import '@module-federation/sdk';
5
- import './DTSManager-81645796.js';
5
+ import './DTSManager-b15Gfat3.js';
6
6
  import 'typescript';
7
7
 
8
8
  declare function forkGenerateDts(options: DtsWorkerOptions): Promise<void>;
@@ -202,7 +202,7 @@ function getEffectiveRootDir(parsedCommandLine) {
202
202
  throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
203
203
  }
204
204
  __name(getEffectiveRootDir, "getEffectiveRootDir");
205
- var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
205
+ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
206
206
  const resolvedTsConfigPath = (0, import_path.resolve)(context, tsConfigPath);
207
207
  const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
208
208
  if (readResult.error) {
@@ -226,9 +226,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
226
226
  }, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
227
227
  const _a2 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a2, restCompilerOptions = __objRest(_a2, ["paths", "baseUrl"]);
228
228
  rawTsConfigJson.compilerOptions = restCompilerOptions;
229
+ const outDirWithoutTypesFolder = (0, import_path.resolve)(context, outputDir || configContent.options.outDir || "dist");
229
230
  const filesToCompile = [
230
231
  ...Object.values(mapComponentsToExpose),
231
- ...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts")),
232
+ ...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
232
233
  ...additionalFilesToCompile
233
234
  ];
234
235
  rawTsConfigJson.include = [];
@@ -379,7 +380,11 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
379
380
  const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a2 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a2.cwd) != null ? _b : void 0 : void 0);
380
381
  try {
381
382
  const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
382
- const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor((0, import_path2.resolve)(mfTypePath, "node_modules"), remoteOptions.context);
383
+ const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
384
+ destDir: (0, import_path2.resolve)(mfTypePath, "node_modules"),
385
+ context: remoteOptions.context,
386
+ exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
387
+ });
383
388
  const execPromise = import_util.default.promisify(import_child_process.exec);
384
389
  const cmd = `npx ${remoteOptions.compilerInstance} --project ${tempTsConfigJsonPath}`;
385
390
  try {
@@ -387,6 +392,12 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
387
392
  cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
388
393
  });
389
394
  } catch (err) {
395
+ if (compilerOptions.tsBuildInfoFile) {
396
+ try {
397
+ yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
398
+ } catch (e) {
399
+ }
400
+ }
390
401
  throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
391
402
  cmd
392
403
  }));
@@ -1605,7 +1616,7 @@ var DTSManager = (_a = class {
1605
1616
  } catch (error2) {
1606
1617
  if (((_a2 = this.options.remote) == null ? void 0 : _a2.abortOnError) === false) {
1607
1618
  if (this.options.displayErrorInTerminal) {
1608
- logger.error(`Unable to compile federated types ${error2}`);
1619
+ logger.error(error2);
1609
1620
  }
1610
1621
  } else {
1611
1622
  throw error2;
@@ -1704,7 +1715,9 @@ var DTSManager = (_a = class {
1704
1715
  const apiTypeFileName = import_path4.default.join(hostOptions.context, hostOptions.typesFolder, HOST_API_TYPES_FILE_NAME);
1705
1716
  try {
1706
1717
  const existedFile = import_fs2.default.readFileSync(apiTypeFileName, "utf-8");
1707
- const existedImports = new import_third_party_dts_extractor2.ThirdPartyExtractor("").collectTypeImports(existedFile);
1718
+ const existedImports = new import_third_party_dts_extractor2.ThirdPartyExtractor({
1719
+ destDir: ""
1720
+ }).collectTypeImports(existedFile);
1708
1721
  existedImports.forEach((existedImport) => {
1709
1722
  const alias = existedImport.split("./").slice(1).join("./").replace("/apis.d.ts", "");
1710
1723
  this.loadedRemoteAPIAlias.add(alias);
@@ -1915,6 +1928,11 @@ function cloneDeepOptions(options) {
1915
1928
  if (typeof value === "function") {
1916
1929
  return false;
1917
1930
  }
1931
+ if (key === "extractThirdParty" && Array.isArray(value)) {
1932
+ return value.map((item) => {
1933
+ return item.toString();
1934
+ });
1935
+ }
1918
1936
  });
1919
1937
  }
1920
1938
  __name(cloneDeepOptions, "cloneDeepOptions");
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { moduleFederationPlugin } from '@module-federation/sdk';
2
2
  import { WebpackPluginInstance, Compiler } from 'webpack';
3
- import { D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
4
- export { i as isTSProject } from './utils-0ec746b7.js';
5
- import './DTSManager-81645796.js';
3
+ import { D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
4
+ export { i as isTSProject } from './utils-BjKKtOcx.js';
5
+ import './DTSManager-b15Gfat3.js';
6
6
  import 'typescript';
7
7
 
8
8
  declare const normalizeDtsOptions: (options: moduleFederationPlugin.ModuleFederationPluginOptions, context: string, defaultOptions?: {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { moduleFederationPlugin } from '@module-federation/sdk';
2
2
  import { WebpackPluginInstance, Compiler } from 'webpack';
3
- import { D as DTSManagerOptions } from './DTSManagerOptions-c74c59ed.js';
4
- export { i as isTSProject } from './utils-0ec746b7.js';
5
- import './DTSManager-81645796.js';
3
+ import { D as DTSManagerOptions } from './DTSManagerOptions-QVchWb0x.js';
4
+ export { i as isTSProject } from './utils-BjKKtOcx.js';
5
+ import './DTSManager-b15Gfat3.js';
6
6
  import 'typescript';
7
7
 
8
8
  declare const normalizeDtsOptions: (options: moduleFederationPlugin.ModuleFederationPluginOptions, context: string, defaultOptions?: {
package/dist/index.js CHANGED
@@ -213,7 +213,11 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
213
213
  const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf", typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_b = (_a3 = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _a3.cwd) != null ? _b : void 0 : void 0);
214
214
  try {
215
215
  const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
216
- const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor((0, import_path.resolve)(mfTypePath, "node_modules"), remoteOptions.context);
216
+ const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor({
217
+ destDir: (0, import_path.resolve)(mfTypePath, "node_modules"),
218
+ context: remoteOptions.context,
219
+ exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
220
+ });
217
221
  const execPromise = import_util.default.promisify(import_child_process.exec);
218
222
  const cmd = `npx ${remoteOptions.compilerInstance} --project ${tempTsConfigJsonPath}`;
219
223
  try {
@@ -221,6 +225,12 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
221
225
  cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
222
226
  });
223
227
  } catch (err) {
228
+ if (compilerOptions.tsBuildInfoFile) {
229
+ try {
230
+ yield (0, import_promises.rm)(compilerOptions.tsBuildInfoFile);
231
+ } catch (e) {
232
+ }
233
+ }
224
234
  throw new Error((0, import_error_codes.getShortErrorMsg)(import_error_codes.TYPE_001, import_error_codes.typeDescMap, {
225
235
  cmd
226
236
  }));
@@ -1468,7 +1478,7 @@ var DTSManager = (_a = class {
1468
1478
  } catch (error2) {
1469
1479
  if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
1470
1480
  if (this.options.displayErrorInTerminal) {
1471
- logger.error(`Unable to compile federated types ${error2}`);
1481
+ logger.error(error2);
1472
1482
  }
1473
1483
  } else {
1474
1484
  throw error2;
@@ -1567,7 +1577,9 @@ var DTSManager = (_a = class {
1567
1577
  const apiTypeFileName = import_path3.default.join(hostOptions.context, hostOptions.typesFolder, HOST_API_TYPES_FILE_NAME);
1568
1578
  try {
1569
1579
  const existedFile = import_fs.default.readFileSync(apiTypeFileName, "utf-8");
1570
- const existedImports = new import_third_party_dts_extractor2.ThirdPartyExtractor("").collectTypeImports(existedFile);
1580
+ const existedImports = new import_third_party_dts_extractor2.ThirdPartyExtractor({
1581
+ destDir: ""
1582
+ }).collectTypeImports(existedFile);
1571
1583
  existedImports.forEach((existedImport) => {
1572
1584
  const alias = existedImport.split("./").slice(1).join("./").replace("/apis.d.ts", "");
1573
1585
  this.loadedRemoteAPIAlias.add(alias);
@@ -1844,6 +1856,11 @@ function cloneDeepOptions(options) {
1844
1856
  if (typeof value === "function") {
1845
1857
  return false;
1846
1858
  }
1859
+ if (key === "extractThirdParty" && Array.isArray(value)) {
1860
+ return value.map((item) => {
1861
+ return item.toString();
1862
+ });
1863
+ }
1847
1864
  });
1848
1865
  }
1849
1866
  __name(cloneDeepOptions, "cloneDeepOptions");
@@ -1907,7 +1924,7 @@ function getEffectiveRootDir(parsedCommandLine) {
1907
1924
  throw new Error("Can not get effective rootDir, please set compilerOptions.rootDir !");
1908
1925
  }
1909
1926
  __name(getEffectiveRootDir, "getEffectiveRootDir");
1910
- var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir, moduleFederationConfig }, mapComponentsToExpose) => {
1927
+ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile, outputDir }, mapComponentsToExpose) => {
1911
1928
  const resolvedTsConfigPath = (0, import_path5.resolve)(context, tsConfigPath);
1912
1929
  const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
1913
1930
  if (readResult.error) {
@@ -1931,9 +1948,10 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
1931
1948
  }, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
1932
1949
  const _a3 = rawTsConfigJson.compilerOptions || {}, { paths, baseUrl } = _a3, restCompilerOptions = __objRest(_a3, ["paths", "baseUrl"]);
1933
1950
  rawTsConfigJson.compilerOptions = restCompilerOptions;
1951
+ const outDirWithoutTypesFolder = (0, import_path5.resolve)(context, outputDir || configContent.options.outDir || "dist");
1934
1952
  const filesToCompile = [
1935
1953
  ...Object.values(mapComponentsToExpose),
1936
- ...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts")),
1954
+ ...configContent.fileNames.filter((filename) => filename.endsWith(".d.ts") && !filename.startsWith(outDirWithoutTypesFolder)),
1937
1955
  ...additionalFilesToCompile
1938
1956
  ];
1939
1957
  rawTsConfigJson.include = [];
@@ -2757,10 +2775,10 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2757
2775
  if (isProd) {
2758
2776
  const zipAssetName = import_path10.default.join(zipPrefix, zipName);
2759
2777
  const apiAssetName = import_path10.default.join(zipPrefix, apiFileName);
2760
- if (zipTypesPath && !compilation.getAsset(zipAssetName)) {
2778
+ if (zipTypesPath && !compilation.getAsset(zipAssetName) && import_fs4.default.existsSync(zipTypesPath)) {
2761
2779
  compilation.emitAsset(zipAssetName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(zipTypesPath), false));
2762
2780
  }
2763
- if (apiTypesPath && !compilation.getAsset(apiAssetName)) {
2781
+ if (apiTypesPath && !compilation.getAsset(apiAssetName) && import_fs4.default.existsSync(apiTypesPath)) {
2764
2782
  compilation.emitAsset(apiAssetName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(apiTypesPath), false));
2765
2783
  }
2766
2784
  callback();
@@ -2768,7 +2786,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2768
2786
  const isEEXIST = /* @__PURE__ */ __name((err) => {
2769
2787
  return err.code == "EEXIST";
2770
2788
  }, "isEEXIST");
2771
- if (zipTypesPath) {
2789
+ if (zipTypesPath && import_fs4.default.existsSync(zipTypesPath)) {
2772
2790
  const zipContent = import_fs4.default.readFileSync(zipTypesPath);
2773
2791
  const zipOutputPath = import_path10.default.join(compiler.outputPath, zipPrefix, zipName);
2774
2792
  yield new Promise((resolve5, reject) => {
@@ -2799,7 +2817,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2799
2817
  );
2800
2818
  });
2801
2819
  }
2802
- if (apiTypesPath) {
2820
+ if (apiTypesPath && import_fs4.default.existsSync(apiTypesPath)) {
2803
2821
  const apiContent = import_fs4.default.readFileSync(apiTypesPath);
2804
2822
  const apiOutputPath = import_path10.default.join(compiler.outputPath, zipPrefix, apiFileName);
2805
2823
  yield new Promise((resolve5, reject) => {
@@ -2835,7 +2853,7 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2835
2853
  } catch (err) {
2836
2854
  callback();
2837
2855
  if (dtsManagerOptions.displayErrorInTerminal) {
2838
- console.error("Error in mf:generateTypes processAssets hook:", err);
2856
+ console.error(err);
2839
2857
  }
2840
2858
  import_sdk10.logger.debug("generate types fail!");
2841
2859
  }
@@ -2876,7 +2894,19 @@ var _DtsPlugin = class _DtsPlugin {
2876
2894
  }
2877
2895
  apply(compiler) {
2878
2896
  const { options } = this;
2879
- const normalizedDtsOptions = normalizeDtsOptions(options, compiler.context);
2897
+ const clonedOptions = __spreadValues({}, options);
2898
+ if (options.exposes && typeof options.exposes === "object") {
2899
+ const cleanedExposes = {};
2900
+ Object.entries(options.exposes).forEach(([key, value]) => {
2901
+ if (typeof value === "string") {
2902
+ cleanedExposes[key] = value.split("?")[0];
2903
+ } else {
2904
+ cleanedExposes[key] = value;
2905
+ }
2906
+ });
2907
+ clonedOptions.exposes = cleanedExposes;
2908
+ }
2909
+ const normalizedDtsOptions = normalizeDtsOptions(clonedOptions, compiler.context);
2880
2910
  if (typeof normalizedDtsOptions !== "object") {
2881
2911
  return;
2882
2912
  }
@@ -2888,9 +2918,9 @@ var _DtsPlugin = class _DtsPlugin {
2888
2918
  const generateTypesPromise = new Promise((resolve5) => {
2889
2919
  generateTypesPromiseResolve = resolve5;
2890
2920
  });
2891
- new DevPlugin(options, normalizedDtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise).apply(compiler);
2892
- new GenerateTypesPlugin(options, normalizedDtsOptions, fetchRemoteTypeUrlsPromise, generateTypesPromiseResolve).apply(compiler);
2893
- new ConsumeTypesPlugin(options, normalizedDtsOptions, fetchRemoteTypeUrlsResolve).apply(compiler);
2921
+ new DevPlugin(clonedOptions, normalizedDtsOptions, generateTypesPromise, fetchRemoteTypeUrlsPromise).apply(compiler);
2922
+ new GenerateTypesPlugin(clonedOptions, normalizedDtsOptions, fetchRemoteTypeUrlsPromise, generateTypesPromiseResolve).apply(compiler);
2923
+ new ConsumeTypesPlugin(clonedOptions, normalizedDtsOptions, fetchRemoteTypeUrlsResolve).apply(compiler);
2894
2924
  }
2895
2925
  };
2896
2926
  __name(_DtsPlugin, "DtsPlugin");
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.11.3",
3
+ "version": "0.12.0",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -60,7 +60,7 @@
60
60
  "chalk": "3.0.0",
61
61
  "fs-extra": "9.1.0",
62
62
  "isomorphic-ws": "5.0.0",
63
- "koa": "2.15.4",
63
+ "koa": "2.16.1",
64
64
  "log4js": "6.9.1",
65
65
  "node-schedule": "2.1.1",
66
66
  "ws": "8.18.0"
@@ -1,6 +1,6 @@
1
1
  import { moduleFederationPlugin } from '@module-federation/sdk';
2
- import { H as HostOptions, a as RemoteOptions } from './DTSManagerOptions-c74c59ed.js';
3
- import { D as DTSManager } from './DTSManager-81645796.js';
2
+ import { H as HostOptions, a as RemoteOptions } from './DTSManagerOptions-QVchWb0x.js';
3
+ import { D as DTSManager } from './DTSManager-b15Gfat3.js';
4
4
 
5
5
  declare function getDTSManagerConstructor(implementation?: string): typeof DTSManager;
6
6
  declare const validateOptions: (options: HostOptions) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.11.3",
3
+ "version": "0.12.0",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -56,14 +56,14 @@
56
56
  "chalk": "3.0.0",
57
57
  "fs-extra": "9.1.0",
58
58
  "isomorphic-ws": "5.0.0",
59
- "koa": "2.15.4",
59
+ "koa": "2.16.1",
60
60
  "log4js": "6.9.1",
61
61
  "node-schedule": "2.1.1",
62
62
  "ws": "8.18.0",
63
- "@module-federation/sdk": "0.11.3",
64
- "@module-federation/managers": "0.11.3",
65
- "@module-federation/third-party-dts-extractor": "0.11.3",
66
- "@module-federation/error-codes": "0.11.3"
63
+ "@module-federation/sdk": "0.12.0",
64
+ "@module-federation/managers": "0.12.0",
65
+ "@module-federation/third-party-dts-extractor": "0.12.0",
66
+ "@module-federation/error-codes": "0.12.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/ws": "8.5.12",
@@ -73,7 +73,7 @@
73
73
  "@vue/tsconfig": "^0.5.1",
74
74
  "vue-tsc": "^2.0.26",
75
75
  "rimraf": "~6.0.1",
76
- "@module-federation/runtime": "0.11.3"
76
+ "@module-federation/runtime": "0.12.0"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "typescript": "^4.9.0 || ^5.0.0",