@module-federation/dts-plugin 0.2.8 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -189,6 +189,7 @@ function getEffectiveRootDir(parsedCommandLine) {
189
189
  }
190
190
  __name(getEffectiveRootDir, "getEffectiveRootDir");
191
191
  var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiledTypesFolder, context, additionalFilesToCompile }, mapComponentsToExpose) => {
192
+ var _a2;
192
193
  const resolvedTsConfigPath = (0, import_path.resolve)(context, tsConfigPath);
193
194
  const readResult = import_typescript.default.readConfigFile(resolvedTsConfigPath, import_typescript.default.sys.readFile);
194
195
  if (readResult.error) {
@@ -207,6 +208,7 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
207
208
  };
208
209
  rawTsConfigJson.compilerOptions = rawTsConfigJson.compilerOptions || {};
209
210
  rawTsConfigJson.compilerOptions = __spreadValues(__spreadValues({}, rawTsConfigJson.compilerOptions), defaultCompilerOptions);
211
+ (_a2 = rawTsConfigJson.compilerOptions) == null ? true : delete _a2.paths;
210
212
  const filesToCompile = [
211
213
  ...Object.values(mapComponentsToExpose),
212
214
  ...additionalFilesToCompile
@@ -215,10 +217,7 @@ var readTsConfig = /* @__PURE__ */ __name(({ tsConfigPath, typesFolder, compiled
215
217
  rawTsConfigJson.files = filesToCompile;
216
218
  rawTsConfigJson.exclude = [];
217
219
  "references" in rawTsConfigJson && delete rawTsConfigJson.references;
218
- const extendsPath = rawTsConfigJson.extends;
219
- if (extendsPath && extendsPath.startsWith(".")) {
220
- rawTsConfigJson.extends = (0, import_path.resolve)(context, extendsPath);
221
- }
220
+ rawTsConfigJson.extends = resolvedTsConfigPath;
222
221
  return rawTsConfigJson;
223
222
  }, "readTsConfig");
224
223
  var TS_EXTENSIONS = [
@@ -271,7 +270,6 @@ var import_path4 = __toESM(require("path"));
271
270
  var import_promises3 = require("fs/promises");
272
271
  var import_fs2 = __toESM(require("fs"));
273
272
  var import_sdk5 = require("@module-federation/sdk");
274
- var import_lodash2 = __toESM(require("lodash.clonedeepwith"));
275
273
  var import_third_party_dts_extractor2 = require("@module-federation/third-party-dts-extractor");
276
274
 
277
275
  // packages/dts-plugin/src/core/lib/archiveHandler.ts
@@ -281,8 +279,8 @@ var import_promises2 = require("fs/promises");
281
279
 
282
280
  // packages/dts-plugin/src/core/lib/typeScriptCompiler.ts
283
281
  var import_fs_extra = require("fs-extra");
282
+ var import_crypto = __toESM(require("crypto"));
284
283
  var import_promises = require("fs/promises");
285
- var import_crypto = require("crypto");
286
284
  var import_path2 = require("path");
287
285
  var import_third_party_dts_extractor = require("@module-federation/third-party-dts-extractor");
288
286
  var import_child_process = require("child_process");
@@ -293,8 +291,12 @@ var DEFINITION_FILE_EXTENSION = ".d.ts";
293
291
  var retrieveMfTypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "")), "retrieveMfTypesPath");
294
292
  var retrieveOriginalOutDir = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.normalize)(tsConfig.compilerOptions.outDir.replace(remoteOptions.compiledTypesFolder, "").replace(remoteOptions.typesFolder, "")), "retrieveOriginalOutDir");
295
293
  var retrieveMfAPITypesPath = /* @__PURE__ */ __name((tsConfig, remoteOptions) => (0, import_path2.join)(retrieveOriginalOutDir(tsConfig, remoteOptions), `${remoteOptions.typesFolder}.d.ts`), "retrieveMfAPITypesPath");
296
- function writeTempTsConfig(tsConfig, context) {
297
- const tempTsConfigJsonPath = (0, import_path2.resolve)(context, "node_modules", import_sdk.TEMP_DIR, `tsconfig.${(0, import_crypto.randomUUID)()}.json`);
294
+ function writeTempTsConfig(tsConfig, context, name) {
295
+ const createHash = /* @__PURE__ */ __name((contents) => {
296
+ return import_crypto.default.createHash("md5").update(contents).digest("hex");
297
+ }, "createHash");
298
+ const hash = createHash(`${JSON.stringify(tsConfig)}${name}`);
299
+ const tempTsConfigJsonPath = (0, import_path2.resolve)(context, "node_modules", import_sdk.TEMP_DIR, `tsconfig.${hash}.json`);
298
300
  (0, import_fs_extra.ensureDirSync)((0, import_path2.dirname)(tempTsConfigJsonPath));
299
301
  (0, import_fs_extra.writeFileSync)(tempTsConfigJsonPath, JSON.stringify(tsConfig, null, 2));
300
302
  return tempTsConfigJsonPath;
@@ -347,7 +349,7 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
347
349
  return;
348
350
  }
349
351
  const { compilerOptions } = tsConfig;
350
- const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context);
352
+ const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf");
351
353
  try {
352
354
  const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
353
355
  const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor((0, import_path2.resolve)(mfTypePath, "node_modules"), remoteOptions.context);
@@ -385,9 +387,6 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
385
387
  }
386
388
  yield (0, import_promises.rm)(tempTsConfigJsonPath);
387
389
  } catch (err) {
388
- if (isDebugMode()) {
389
- console.log("tsconfig: ", JSON.stringify(tsConfig, null, 2));
390
- }
391
390
  throw err;
392
391
  }
393
392
  }), "compileTs");
@@ -509,11 +508,16 @@ var import_chalk2 = __toESM(require("chalk"));
509
508
  // packages/dts-plugin/src/server/constant.ts
510
509
  var DEFAULT_WEB_SOCKET_PORT = 16322;
511
510
  var WEB_SOCKET_CONNECT_MAGIC_ID = "1hpzW-zo2z-o8io-gfmV1-2cb1d82";
511
+ var UpdateMode;
512
+ (function(UpdateMode2) {
513
+ UpdateMode2["POSITIVE"] = "POSITIVE";
514
+ UpdateMode2["PASSIVE"] = "PASSIVE";
515
+ })(UpdateMode || (UpdateMode = {}));
512
516
 
513
517
  // packages/dts-plugin/src/server/utils/log.ts
514
518
  function fileLog(msg, module2, level) {
515
- var _a3, _b;
516
- if (!((_a3 = process == null ? void 0 : process.env) == null ? void 0 : _a3["FEDERATION_DEBUG"])) {
519
+ var _a2, _b;
520
+ if (!((_a2 = process == null ? void 0 : process.env) == null ? void 0 : _a2["FEDERATION_DEBUG"])) {
517
521
  return;
518
522
  }
519
523
  log4js.configure({
@@ -654,255 +658,6 @@ var Publisher = _Publisher;
654
658
  // packages/dts-plugin/src/server/DevServer.ts
655
659
  var import_isomorphic_ws2 = __toESM(require("isomorphic-ws"));
656
660
 
657
- // packages/dts-plugin/src/core/configurations/hostPlugin.ts
658
- var import_sdk4 = require("@module-federation/sdk");
659
- var import_managers2 = require("@module-federation/managers");
660
- var defaultOptions2 = {
661
- typesFolder: "@mf-types",
662
- remoteTypesFolder: "@mf-types",
663
- deleteTypesFolder: true,
664
- maxRetries: 3,
665
- implementation: "",
666
- context: process.cwd(),
667
- abortOnError: true,
668
- consumeAPITypes: false
669
- };
670
- var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
671
- const remoteUrl = new URL(url, "file:");
672
- const pathnameWithoutEntry = remoteUrl.pathname.split("/").slice(0, -1).join("/");
673
- remoteUrl.pathname = `${pathnameWithoutEntry}/${hostOptions.remoteTypesFolder}.zip`;
674
- return remoteUrl.protocol === "file:" ? remoteUrl.pathname : remoteUrl.href;
675
- }, "buildZipUrl");
676
- var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
677
- if (!zipUrl) {
678
- return void 0;
679
- }
680
- return zipUrl.replace(".zip", ".d.ts");
681
- }, "buildApiTypeUrl");
682
- var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
683
- const { hostOptions, remoteAlias, remote } = options;
684
- let decodedRemote = remote;
685
- if (decodedRemote.startsWith(import_sdk4.ENCODE_NAME_PREFIX)) {
686
- decodedRemote = (0, import_sdk4.decodeName)(decodedRemote, import_sdk4.ENCODE_NAME_PREFIX);
687
- }
688
- const parsedInfo = (0, import_sdk4.parseEntry)(decodedRemote, void 0, "@");
689
- const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
690
- const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
691
- return {
692
- name: parsedInfo.name || remoteAlias,
693
- url,
694
- zipUrl,
695
- apiTypeUrl: buildApiTypeUrl(zipUrl),
696
- alias: remoteAlias
697
- };
698
- }, "retrieveRemoteInfo");
699
- var resolveRemotes = /* @__PURE__ */ __name((hostOptions) => {
700
- const parsedOptions = import_managers2.utils.parseOptions(hostOptions.moduleFederationConfig.remotes || {}, (item, key) => ({
701
- remote: Array.isArray(item) ? item[0] : item,
702
- key
703
- }), (item, key) => ({
704
- remote: Array.isArray(item.external) ? item.external[0] : item.external,
705
- key
706
- }));
707
- return parsedOptions.reduce((accumulator, item) => {
708
- const { key, remote } = item[1];
709
- accumulator[key] = retrieveRemoteInfo({
710
- hostOptions,
711
- remoteAlias: key,
712
- remote
713
- });
714
- return accumulator;
715
- }, {});
716
- }, "resolveRemotes");
717
- var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
718
- validateOptions(options);
719
- const hostOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
720
- const mapRemotesToDownload = resolveRemotes(hostOptions);
721
- return {
722
- hostOptions,
723
- mapRemotesToDownload
724
- };
725
- }, "retrieveHostConfig");
726
-
727
- // packages/dts-plugin/src/core/lib/DtsWorker.ts
728
- var import_lodash = __toESM(require("lodash.clonedeepwith"));
729
-
730
- // packages/dts-plugin/src/core/rpc/index.ts
731
- var rpc_exports = {};
732
- __export(rpc_exports, {
733
- RpcExitError: () => RpcExitError,
734
- RpcGMCallTypes: () => RpcGMCallTypes,
735
- createRpcWorker: () => createRpcWorker,
736
- exposeRpc: () => exposeRpc,
737
- getRpcWorkerData: () => getRpcWorkerData,
738
- wrapRpc: () => wrapRpc
739
- });
740
-
741
- // packages/dts-plugin/src/core/rpc/rpc-error.ts
742
- var _a;
743
- var RpcExitError = (_a = class extends Error {
744
- constructor(message, code, signal) {
745
- super(message);
746
- __publicField(this, "code");
747
- __publicField(this, "signal");
748
- this.code = code;
749
- this.signal = signal;
750
- this.name = "RpcExitError";
751
- }
752
- }, __name(_a, "RpcExitError"), _a);
753
-
754
- // packages/dts-plugin/src/core/rpc/wrap-rpc.ts
755
- function createControlledPromise() {
756
- let resolve4 = /* @__PURE__ */ __name(() => void 0, "resolve");
757
- let reject = /* @__PURE__ */ __name(() => void 0, "reject");
758
- const promise = new Promise((aResolve, aReject) => {
759
- resolve4 = aResolve;
760
- reject = aReject;
761
- });
762
- return {
763
- promise,
764
- resolve: resolve4,
765
- reject
766
- };
767
- }
768
- __name(createControlledPromise, "createControlledPromise");
769
- function wrapRpc(childProcess, options) {
770
- return (...args) => __async(this, null, function* () {
771
- if (!childProcess.send) {
772
- throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
773
- } else if (!childProcess.connected) {
774
- throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
775
- }
776
- const { id, once } = options;
777
- const { promise: resultPromise, resolve: resolveResult, reject: rejectResult } = createControlledPromise();
778
- const { promise: sendPromise, resolve: resolveSend, reject: rejectSend } = createControlledPromise();
779
- const handleMessage = /* @__PURE__ */ __name((message) => {
780
- if ((message == null ? void 0 : message.id) === id) {
781
- if (message.type === RpcGMCallTypes.RESOLVE) {
782
- resolveResult(message.value);
783
- } else if (message.type === RpcGMCallTypes.REJECT) {
784
- rejectResult(message.error);
785
- }
786
- }
787
- if (once && (childProcess == null ? void 0 : childProcess.kill)) {
788
- childProcess.kill("SIGTERM");
789
- }
790
- }, "handleMessage");
791
- const handleClose = /* @__PURE__ */ __name((code, signal) => {
792
- rejectResult(new RpcExitError(code ? `Process ${childProcess.pid} exited with code ${code}${signal ? ` [${signal}]` : ""}` : `Process ${childProcess.pid} exited${signal ? ` [${signal}]` : ""}`, code, signal));
793
- removeHandlers();
794
- }, "handleClose");
795
- const removeHandlers = /* @__PURE__ */ __name(() => {
796
- childProcess.off("message", handleMessage);
797
- childProcess.off("close", handleClose);
798
- }, "removeHandlers");
799
- if (once) {
800
- childProcess.once("message", handleMessage);
801
- } else {
802
- childProcess.on("message", handleMessage);
803
- }
804
- childProcess.on("close", handleClose);
805
- childProcess.send({
806
- type: RpcGMCallTypes.CALL,
807
- id,
808
- args
809
- }, (error2) => {
810
- if (error2) {
811
- rejectSend(error2);
812
- removeHandlers();
813
- } else {
814
- resolveSend(void 0);
815
- }
816
- });
817
- return sendPromise.then(() => resultPromise);
818
- });
819
- }
820
- __name(wrapRpc, "wrapRpc");
821
-
822
- // packages/dts-plugin/src/core/rpc/rpc-worker.ts
823
- var child_process = __toESM(require("child_process"));
824
- var process3 = __toESM(require("process"));
825
- var import_crypto2 = require("crypto");
826
- var FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
827
- function createRpcWorker(modulePath, data, memoryLimit, once) {
828
- const options = {
829
- env: __spreadProps(__spreadValues({}, process3.env), {
830
- [FEDERATION_WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
831
- }),
832
- stdio: [
833
- "inherit",
834
- "inherit",
835
- "inherit",
836
- "ipc"
837
- ],
838
- serialization: "advanced"
839
- };
840
- if (memoryLimit) {
841
- options.execArgv = [
842
- `--max-old-space-size=${memoryLimit}`
843
- ];
844
- }
845
- let childProcess, remoteMethod;
846
- const id = (0, import_crypto2.randomUUID)();
847
- const worker = {
848
- connect(...args) {
849
- if (childProcess && !childProcess.connected) {
850
- childProcess.send({
851
- type: RpcGMCallTypes.EXIT,
852
- id
853
- });
854
- childProcess = void 0;
855
- remoteMethod = void 0;
856
- }
857
- if (!(childProcess == null ? void 0 : childProcess.connected)) {
858
- childProcess = child_process.fork(modulePath, options);
859
- remoteMethod = wrapRpc(childProcess, {
860
- id,
861
- once
862
- });
863
- }
864
- if (!remoteMethod) {
865
- return Promise.reject(new Error("Worker is not connected - cannot perform RPC."));
866
- }
867
- return remoteMethod(...args);
868
- },
869
- terminate() {
870
- var _a3;
871
- (_a3 = childProcess == null ? void 0 : childProcess.send) == null ? void 0 : _a3.call(childProcess, {
872
- type: RpcGMCallTypes.EXIT,
873
- id
874
- });
875
- childProcess = void 0;
876
- remoteMethod = void 0;
877
- },
878
- get connected() {
879
- return Boolean(childProcess == null ? void 0 : childProcess.connected);
880
- },
881
- get process() {
882
- return childProcess;
883
- },
884
- get id() {
885
- return id;
886
- }
887
- };
888
- return worker;
889
- }
890
- __name(createRpcWorker, "createRpcWorker");
891
- function getRpcWorkerData() {
892
- return JSON.parse(process3.env[FEDERATION_WORKER_DATA_ENV_KEY] || "{}");
893
- }
894
- __name(getRpcWorkerData, "getRpcWorkerData");
895
-
896
- // packages/dts-plugin/src/core/constant.ts
897
- var REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
898
- var REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
899
- var HOST_API_TYPES_FILE_NAME = "index.d.ts";
900
- var UpdateMode;
901
- (function(UpdateMode2) {
902
- UpdateMode2["POSITIVE"] = "POSITIVE";
903
- UpdateMode2["PASSIVE"] = "PASSIVE";
904
- })(UpdateMode || (UpdateMode = {}));
905
-
906
661
  // packages/dts-plugin/src/server/broker/Broker.ts
907
662
  var import_http = require("http");
908
663
  var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
@@ -993,13 +748,13 @@ ${err.message}
993
748
  this._webSocketServer = void 0;
994
749
  });
995
750
  server.on("upgrade", (req, socket, head) => {
996
- var _a3;
751
+ var _a2;
997
752
  if (req.url) {
998
753
  const { pathname } = (0, import_url.parse)(req.url);
999
754
  if (pathname === "/") {
1000
- (_a3 = this._webSocketServer) == null ? void 0 : _a3.handleUpgrade(req, socket, head, (ws) => {
1001
- var _a4;
1002
- (_a4 = this._webSocketServer) == null ? void 0 : _a4.emit("connection", ws, req);
755
+ (_a2 = this._webSocketServer) == null ? void 0 : _a2.handleUpgrade(req, socket, head, (ws) => {
756
+ var _a3;
757
+ (_a3 = this._webSocketServer) == null ? void 0 : _a3.emit("connection", ws, req);
1003
758
  });
1004
759
  }
1005
760
  }
@@ -1384,8 +1139,8 @@ ${err.message}
1384
1139
  }
1385
1140
  }
1386
1141
  _getTmpSubScribers(publisherIdentifier) {
1387
- var _a3;
1388
- return (_a3 = this._tmpSubscriberShelter.get(publisherIdentifier)) == null ? void 0 : _a3.subscribers;
1142
+ var _a2;
1143
+ return (_a2 = this._tmpSubscriberShelter.get(publisherIdentifier)) == null ? void 0 : _a2.subscribers;
1389
1144
  }
1390
1145
  // after adding publisher, it will change the temp subscriber to regular subscriber
1391
1146
  _consumeTmpSubScribers(publisher, tmpSubScribers) {
@@ -1490,9 +1245,9 @@ ${err.message}
1490
1245
  process.exit(0);
1491
1246
  }
1492
1247
  broadcast(message) {
1493
- var _a3, _b;
1248
+ var _a2, _b;
1494
1249
  fileLog(`[broadcast] exit info : ${JSON.stringify(message)}`, "Broker", "warn");
1495
- (_a3 = this._webSocketServer) == null ? void 0 : _a3.clients.forEach((client) => {
1250
+ (_a2 = this._webSocketServer) == null ? void 0 : _a2.clients.forEach((client) => {
1496
1251
  client.send(JSON.stringify(message));
1497
1252
  });
1498
1253
  (_b = this._secureWebSocketServer) == null ? void 0 : _b.clients.forEach((client) => {
@@ -1566,9 +1321,85 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
1566
1321
  });
1567
1322
  }, "downloadTypesArchive");
1568
1323
 
1324
+ // packages/dts-plugin/src/core/configurations/hostPlugin.ts
1325
+ var import_sdk4 = require("@module-federation/sdk");
1326
+ var import_managers2 = require("@module-federation/managers");
1327
+ var defaultOptions2 = {
1328
+ typesFolder: "@mf-types",
1329
+ remoteTypesFolder: "@mf-types",
1330
+ deleteTypesFolder: true,
1331
+ maxRetries: 3,
1332
+ implementation: "",
1333
+ context: process.cwd(),
1334
+ abortOnError: true,
1335
+ consumeAPITypes: false,
1336
+ runtimePkgs: []
1337
+ };
1338
+ var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
1339
+ const remoteUrl = new URL(url, "file:");
1340
+ const pathnameWithoutEntry = remoteUrl.pathname.split("/").slice(0, -1).join("/");
1341
+ remoteUrl.pathname = `${pathnameWithoutEntry}/${hostOptions.remoteTypesFolder}.zip`;
1342
+ return remoteUrl.protocol === "file:" ? remoteUrl.pathname : remoteUrl.href;
1343
+ }, "buildZipUrl");
1344
+ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
1345
+ if (!zipUrl) {
1346
+ return void 0;
1347
+ }
1348
+ return zipUrl.replace(".zip", ".d.ts");
1349
+ }, "buildApiTypeUrl");
1350
+ var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
1351
+ const { hostOptions, remoteAlias, remote } = options;
1352
+ let decodedRemote = remote;
1353
+ if (decodedRemote.startsWith(import_sdk4.ENCODE_NAME_PREFIX)) {
1354
+ decodedRemote = (0, import_sdk4.decodeName)(decodedRemote, import_sdk4.ENCODE_NAME_PREFIX);
1355
+ }
1356
+ const parsedInfo = (0, import_sdk4.parseEntry)(decodedRemote, void 0, "@");
1357
+ const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
1358
+ const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
1359
+ return {
1360
+ name: parsedInfo.name || remoteAlias,
1361
+ url,
1362
+ zipUrl,
1363
+ apiTypeUrl: buildApiTypeUrl(zipUrl),
1364
+ alias: remoteAlias
1365
+ };
1366
+ }, "retrieveRemoteInfo");
1367
+ var resolveRemotes = /* @__PURE__ */ __name((hostOptions) => {
1368
+ const parsedOptions = import_managers2.utils.parseOptions(hostOptions.moduleFederationConfig.remotes || {}, (item, key) => ({
1369
+ remote: Array.isArray(item) ? item[0] : item,
1370
+ key
1371
+ }), (item, key) => ({
1372
+ remote: Array.isArray(item.external) ? item.external[0] : item.external,
1373
+ key
1374
+ }));
1375
+ return parsedOptions.reduce((accumulator, item) => {
1376
+ const { key, remote } = item[1];
1377
+ accumulator[key] = retrieveRemoteInfo({
1378
+ hostOptions,
1379
+ remoteAlias: key,
1380
+ remote
1381
+ });
1382
+ return accumulator;
1383
+ }, {});
1384
+ }, "resolveRemotes");
1385
+ var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
1386
+ validateOptions(options);
1387
+ const hostOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
1388
+ const mapRemotesToDownload = resolveRemotes(hostOptions);
1389
+ return {
1390
+ hostOptions,
1391
+ mapRemotesToDownload
1392
+ };
1393
+ }, "retrieveHostConfig");
1394
+
1395
+ // packages/dts-plugin/src/core/constant.ts
1396
+ var REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
1397
+ var REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
1398
+ var HOST_API_TYPES_FILE_NAME = "index.d.ts";
1399
+
1569
1400
  // packages/dts-plugin/src/core/lib/DTSManager.ts
1570
- var _a2;
1571
- var DTSManager = (_a2 = class {
1401
+ var _a;
1402
+ var DTSManager = (_a = class {
1572
1403
  constructor(options) {
1573
1404
  __publicField(this, "options");
1574
1405
  __publicField(this, "runtimePkgs");
@@ -1576,11 +1407,7 @@ var DTSManager = (_a2 = class {
1576
1407
  __publicField(this, "loadedRemoteAPIAlias");
1577
1408
  __publicField(this, "extraOptions");
1578
1409
  __publicField(this, "updatedRemoteInfos");
1579
- this.options = (0, import_lodash2.default)(options, (_value, key) => {
1580
- if (key === "manifest") {
1581
- return false;
1582
- }
1583
- });
1410
+ this.options = cloneDeepOptions(options);
1584
1411
  this.runtimePkgs = [
1585
1412
  "@module-federation/runtime",
1586
1413
  "@module-federation/enhanced/runtime",
@@ -1639,7 +1466,7 @@ var DTSManager = (_a2 = class {
1639
1466
  }
1640
1467
  generateTypes() {
1641
1468
  return __async(this, null, function* () {
1642
- var _a3;
1469
+ var _a2;
1643
1470
  try {
1644
1471
  const { options } = this;
1645
1472
  if (!options.remote) {
@@ -1676,7 +1503,7 @@ var DTSManager = (_a2 = class {
1676
1503
  }
1677
1504
  console.log(import_ansi_colors.default.green("Federated types created correctly"));
1678
1505
  } catch (error2) {
1679
- if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
1506
+ if (((_a2 = this.options.remote) == null ? void 0 : _a2.abortOnError) === false) {
1680
1507
  console.error(import_ansi_colors.default.red(`Unable to compile federated types, ${error2}`));
1681
1508
  } else {
1682
1509
  throw error2;
@@ -1791,7 +1618,16 @@ var DTSManager = (_a2 = class {
1791
1618
  ...packageTypes,
1792
1619
  "Y"
1793
1620
  ].join(" :\n")} ;`;
1794
- const pkgsDeclareStr = this.runtimePkgs.map((pkg) => {
1621
+ const runtimePkgs = /* @__PURE__ */ new Set();
1622
+ [
1623
+ ...this.runtimePkgs,
1624
+ ...hostOptions.runtimePkgs
1625
+ ].forEach((pkg) => {
1626
+ runtimePkgs.add(pkg);
1627
+ });
1628
+ const pkgsDeclareStr = [
1629
+ ...runtimePkgs
1630
+ ].map((pkg) => {
1795
1631
  return `declare module "${pkg}" {
1796
1632
  ${remoteKeysStr}
1797
1633
  ${packageTypesStr}
@@ -1824,7 +1660,7 @@ var DTSManager = (_a2 = class {
1824
1660
  }
1825
1661
  consumeTypes() {
1826
1662
  return __async(this, null, function* () {
1827
- var _a3;
1663
+ var _a2;
1828
1664
  try {
1829
1665
  const { options } = this;
1830
1666
  if (!options.host) {
@@ -1851,7 +1687,7 @@ var DTSManager = (_a2 = class {
1851
1687
  }
1852
1688
  console.log(import_ansi_colors.default.green("Federated types extraction completed"));
1853
1689
  } catch (err) {
1854
- if (((_a3 = this.options.host) == null ? void 0 : _a3.abortOnError) === false) {
1690
+ if (((_a2 = this.options.host) == null ? void 0 : _a2.abortOnError) === false) {
1855
1691
  fileLog(`Unable to consume federated types, ${err}`, "consumeTypes", "error");
1856
1692
  } else {
1857
1693
  throw err;
@@ -1861,10 +1697,10 @@ var DTSManager = (_a2 = class {
1861
1697
  }
1862
1698
  updateTypes(options) {
1863
1699
  return __async(this, null, function* () {
1864
- var _a3, _b, _c;
1700
+ var _a2, _b, _c;
1865
1701
  try {
1866
1702
  const { remoteName, updateMode, remoteInfo: updatedRemoteInfo, once } = options;
1867
- const hostName = (_c = (_b = (_a3 = this.options) == null ? void 0 : _a3.host) == null ? void 0 : _b.moduleFederationConfig) == null ? void 0 : _c.name;
1703
+ const hostName = (_c = (_b = (_a2 = this.options) == null ? void 0 : _a2.host) == null ? void 0 : _b.moduleFederationConfig) == null ? void 0 : _c.name;
1868
1704
  fileLog(`updateTypes options:, ${JSON.stringify(options, null, 2)}`, "consumeTypes", "info");
1869
1705
  if (updateMode === UpdateMode.POSITIVE && remoteName === hostName) {
1870
1706
  if (!this.options.remote) {
@@ -1878,7 +1714,7 @@ var DTSManager = (_a2 = class {
1878
1714
  }
1879
1715
  const { hostOptions, mapRemotesToDownload } = retrieveHostConfig(this.options.host);
1880
1716
  const loadedRemoteInfo = Object.values(remoteAliasMap).find((i) => i.name === remoteName);
1881
- const consumeTypes2 = /* @__PURE__ */ __name((requiredRemoteInfo) => __async(this, null, function* () {
1717
+ const consumeTypes = /* @__PURE__ */ __name((requiredRemoteInfo) => __async(this, null, function* () {
1882
1718
  const [_alias, destinationPath] = yield this.consumeTargetRemotes(hostOptions, requiredRemoteInfo);
1883
1719
  yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
1884
1720
  }), "consumeTypes");
@@ -1891,10 +1727,10 @@ var DTSManager = (_a2 = class {
1891
1727
  const requiredRemoteInfo = yield this.requestRemoteManifest(remoteInfo);
1892
1728
  this.remoteAliasMap[remoteInfo.alias] = requiredRemoteInfo;
1893
1729
  }
1894
- yield consumeTypes2(this.remoteAliasMap[remoteInfo.alias]);
1730
+ yield consumeTypes(this.remoteAliasMap[remoteInfo.alias]);
1895
1731
  } else if (updatedRemoteInfo) {
1896
1732
  const consumeDynamicRemoteTypes = /* @__PURE__ */ __name(() => __async(this, null, function* () {
1897
- yield consumeTypes2(this.updatedRemoteInfos[updatedRemoteInfo.name]);
1733
+ yield consumeTypes(this.updatedRemoteInfos[updatedRemoteInfo.name]);
1898
1734
  this.consumeAPITypes(hostOptions);
1899
1735
  }), "consumeDynamicRemoteTypes");
1900
1736
  if (!this.updatedRemoteInfos[updatedRemoteInfo.name]) {
@@ -1913,7 +1749,7 @@ var DTSManager = (_a2 = class {
1913
1749
  }
1914
1750
  }
1915
1751
  } else {
1916
- yield consumeTypes2(loadedRemoteInfo);
1752
+ yield consumeTypes(loadedRemoteInfo);
1917
1753
  }
1918
1754
  }
1919
1755
  } catch (err) {
@@ -1921,9 +1757,10 @@ var DTSManager = (_a2 = class {
1921
1757
  }
1922
1758
  });
1923
1759
  }
1924
- }, __name(_a2, "DTSManager"), _a2);
1760
+ }, __name(_a, "DTSManager"), _a);
1925
1761
 
1926
1762
  // packages/dts-plugin/src/core/lib/utils.ts
1763
+ var import_lodash = __toESM(require("lodash.clonedeepwith"));
1927
1764
  function getDTSManagerConstructor(implementation) {
1928
1765
  if (implementation) {
1929
1766
  const NewConstructor = require(implementation);
@@ -1941,6 +1778,18 @@ function isDebugMode() {
1941
1778
  return Boolean(process.env["FEDERATION_DEBUG"]) || process.env["NODE_ENV"] === "test";
1942
1779
  }
1943
1780
  __name(isDebugMode, "isDebugMode");
1781
+ function cloneDeepOptions(options) {
1782
+ const excludeKeys = [
1783
+ "manifest",
1784
+ "async"
1785
+ ];
1786
+ return (0, import_lodash.default)(options, (_value, key) => {
1787
+ if (typeof key === "string" && excludeKeys.includes(key)) {
1788
+ return false;
1789
+ }
1790
+ });
1791
+ }
1792
+ __name(cloneDeepOptions, "cloneDeepOptions");
1944
1793
  function axiosGet(url, config) {
1945
1794
  return __async(this, null, function* () {
1946
1795
  const httpAgent = new import_http2.default.Agent({
@@ -1960,8 +1809,8 @@ __name(axiosGet, "axiosGet");
1960
1809
  // packages/dts-plugin/src/core/lib/generateTypes.ts
1961
1810
  function generateTypes(options) {
1962
1811
  return __async(this, null, function* () {
1963
- var _a3;
1964
- const DTSManagerConstructor = getDTSManagerConstructor((_a3 = options.remote) == null ? void 0 : _a3.implementation);
1812
+ var _a2;
1813
+ const DTSManagerConstructor = getDTSManagerConstructor((_a2 = options.remote) == null ? void 0 : _a2.implementation);
1965
1814
  const dtsManager = new DTSManagerConstructor(options);
1966
1815
  return dtsManager.generateTypes();
1967
1816
  });
@@ -10,6 +10,11 @@
10
10
  // packages/dts-plugin/src/server/constant.ts
11
11
  var DEFAULT_WEB_SOCKET_PORT = 16322;
12
12
  var WEB_SOCKET_CONNECT_MAGIC_ID = "1hpzW-zo2z-o8io-gfmV1-2cb1d82";
13
+ var UpdateMode;
14
+ (function(UpdateMode2) {
15
+ UpdateMode2["POSITIVE"] = "POSITIVE";
16
+ UpdateMode2["PASSIVE"] = "PASSIVE";
17
+ })(UpdateMode || (UpdateMode = {}));
13
18
 
14
19
  // packages/dts-plugin/src/server/message/Message.ts
15
20
  var _Message = class _Message {
@@ -68,13 +73,6 @@
68
73
  __name(_AddWebClientAction, "AddWebClientAction");
69
74
  var AddWebClientAction = _AddWebClientAction;
70
75
 
71
- // packages/dts-plugin/src/core/constant.ts
72
- var UpdateMode;
73
- (function(UpdateMode2) {
74
- UpdateMode2["POSITIVE"] = "POSITIVE";
75
- UpdateMode2["PASSIVE"] = "PASSIVE";
76
- })(UpdateMode || (UpdateMode = {}));
77
-
78
76
  // packages/dts-plugin/src/server/message/API/API.ts
79
77
  var APIKind;
80
78
  (function(APIKind2) {