@module-federation/dts-plugin 0.2.7 → 0.3.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.
@@ -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;
@@ -334,6 +336,7 @@ var processTypesFile = /* @__PURE__ */ __name((options) => __async(void 0, null,
334
336
  const mfeTypeEntry = (0, import_path2.join)(mfTypePath, `${sourceEntry}${DEFINITION_FILE_EXTENSION}`);
335
337
  const mfeTypeEntryDirectory = (0, import_path2.dirname)(mfeTypeEntry);
336
338
  const relativePathToOutput = (0, import_path2.relative)(mfeTypeEntryDirectory, filePath).replace(DEFINITION_FILE_EXTENSION, "").replace(STARTS_WITH_SLASH, "").split(import_path2.sep).join("/");
339
+ (0, import_fs_extra.ensureDirSync)(mfeTypeEntryDirectory);
337
340
  yield (0, import_promises.writeFile)(mfeTypeEntry, `export * from './${relativePathToOutput}';
338
341
  export { default } from './${relativePathToOutput}';`);
339
342
  }
@@ -346,7 +349,7 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
346
349
  return;
347
350
  }
348
351
  const { compilerOptions } = tsConfig;
349
- const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context);
352
+ const tempTsConfigJsonPath = writeTempTsConfig(tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || "mf");
350
353
  try {
351
354
  const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);
352
355
  const thirdPartyExtractor = new import_third_party_dts_extractor.ThirdPartyExtractor((0, import_path2.resolve)(mfTypePath, "node_modules"), remoteOptions.context);
@@ -384,6 +387,9 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
384
387
  }
385
388
  yield (0, import_promises.rm)(tempTsConfigJsonPath);
386
389
  } catch (err) {
390
+ if (isDebugMode()) {
391
+ console.log("tsconfig: ", JSON.stringify(tsConfig, null, 2));
392
+ }
387
393
  throw err;
388
394
  }
389
395
  }), "compileTs");
@@ -505,11 +511,16 @@ var import_chalk2 = __toESM(require("chalk"));
505
511
  // packages/dts-plugin/src/server/constant.ts
506
512
  var DEFAULT_WEB_SOCKET_PORT = 16322;
507
513
  var WEB_SOCKET_CONNECT_MAGIC_ID = "1hpzW-zo2z-o8io-gfmV1-2cb1d82";
514
+ var UpdateMode;
515
+ (function(UpdateMode2) {
516
+ UpdateMode2["POSITIVE"] = "POSITIVE";
517
+ UpdateMode2["PASSIVE"] = "PASSIVE";
518
+ })(UpdateMode || (UpdateMode = {}));
508
519
 
509
520
  // packages/dts-plugin/src/server/utils/log.ts
510
521
  function fileLog(msg, module2, level) {
511
- var _a3, _b;
512
- if (!((_a3 = process == null ? void 0 : process.env) == null ? void 0 : _a3["FEDERATION_DEBUG"])) {
522
+ var _a2, _b;
523
+ if (!((_a2 = process == null ? void 0 : process.env) == null ? void 0 : _a2["FEDERATION_DEBUG"])) {
513
524
  return;
514
525
  }
515
526
  log4js.configure({
@@ -650,255 +661,6 @@ var Publisher = _Publisher;
650
661
  // packages/dts-plugin/src/server/DevServer.ts
651
662
  var import_isomorphic_ws2 = __toESM(require("isomorphic-ws"));
652
663
 
653
- // packages/dts-plugin/src/core/configurations/hostPlugin.ts
654
- var import_sdk4 = require("@module-federation/sdk");
655
- var import_managers2 = require("@module-federation/managers");
656
- var defaultOptions2 = {
657
- typesFolder: "@mf-types",
658
- remoteTypesFolder: "@mf-types",
659
- deleteTypesFolder: true,
660
- maxRetries: 3,
661
- implementation: "",
662
- context: process.cwd(),
663
- abortOnError: true,
664
- consumeAPITypes: false
665
- };
666
- var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
667
- const remoteUrl = new URL(url, "file:");
668
- const pathnameWithoutEntry = remoteUrl.pathname.split("/").slice(0, -1).join("/");
669
- remoteUrl.pathname = `${pathnameWithoutEntry}/${hostOptions.remoteTypesFolder}.zip`;
670
- return remoteUrl.protocol === "file:" ? remoteUrl.pathname : remoteUrl.href;
671
- }, "buildZipUrl");
672
- var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
673
- if (!zipUrl) {
674
- return void 0;
675
- }
676
- return zipUrl.replace(".zip", ".d.ts");
677
- }, "buildApiTypeUrl");
678
- var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
679
- const { hostOptions, remoteAlias, remote } = options;
680
- let decodedRemote = remote;
681
- if (decodedRemote.startsWith(import_sdk4.ENCODE_NAME_PREFIX)) {
682
- decodedRemote = (0, import_sdk4.decodeName)(decodedRemote, import_sdk4.ENCODE_NAME_PREFIX);
683
- }
684
- const parsedInfo = (0, import_sdk4.parseEntry)(decodedRemote, void 0, "@");
685
- const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
686
- const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
687
- return {
688
- name: parsedInfo.name || remoteAlias,
689
- url,
690
- zipUrl,
691
- apiTypeUrl: buildApiTypeUrl(zipUrl),
692
- alias: remoteAlias
693
- };
694
- }, "retrieveRemoteInfo");
695
- var resolveRemotes = /* @__PURE__ */ __name((hostOptions) => {
696
- const parsedOptions = import_managers2.utils.parseOptions(hostOptions.moduleFederationConfig.remotes || {}, (item, key) => ({
697
- remote: Array.isArray(item) ? item[0] : item,
698
- key
699
- }), (item, key) => ({
700
- remote: Array.isArray(item.external) ? item.external[0] : item.external,
701
- key
702
- }));
703
- return parsedOptions.reduce((accumulator, item) => {
704
- const { key, remote } = item[1];
705
- accumulator[key] = retrieveRemoteInfo({
706
- hostOptions,
707
- remoteAlias: key,
708
- remote
709
- });
710
- return accumulator;
711
- }, {});
712
- }, "resolveRemotes");
713
- var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
714
- validateOptions(options);
715
- const hostOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
716
- const mapRemotesToDownload = resolveRemotes(hostOptions);
717
- return {
718
- hostOptions,
719
- mapRemotesToDownload
720
- };
721
- }, "retrieveHostConfig");
722
-
723
- // packages/dts-plugin/src/core/lib/DtsWorker.ts
724
- var import_lodash = __toESM(require("lodash.clonedeepwith"));
725
-
726
- // packages/dts-plugin/src/core/rpc/index.ts
727
- var rpc_exports = {};
728
- __export(rpc_exports, {
729
- RpcExitError: () => RpcExitError,
730
- RpcGMCallTypes: () => RpcGMCallTypes,
731
- createRpcWorker: () => createRpcWorker,
732
- exposeRpc: () => exposeRpc,
733
- getRpcWorkerData: () => getRpcWorkerData,
734
- wrapRpc: () => wrapRpc
735
- });
736
-
737
- // packages/dts-plugin/src/core/rpc/rpc-error.ts
738
- var _a;
739
- var RpcExitError = (_a = class extends Error {
740
- constructor(message, code, signal) {
741
- super(message);
742
- __publicField(this, "code");
743
- __publicField(this, "signal");
744
- this.code = code;
745
- this.signal = signal;
746
- this.name = "RpcExitError";
747
- }
748
- }, __name(_a, "RpcExitError"), _a);
749
-
750
- // packages/dts-plugin/src/core/rpc/wrap-rpc.ts
751
- function createControlledPromise() {
752
- let resolve4 = /* @__PURE__ */ __name(() => void 0, "resolve");
753
- let reject = /* @__PURE__ */ __name(() => void 0, "reject");
754
- const promise = new Promise((aResolve, aReject) => {
755
- resolve4 = aResolve;
756
- reject = aReject;
757
- });
758
- return {
759
- promise,
760
- resolve: resolve4,
761
- reject
762
- };
763
- }
764
- __name(createControlledPromise, "createControlledPromise");
765
- function wrapRpc(childProcess, options) {
766
- return (...args) => __async(this, null, function* () {
767
- if (!childProcess.send) {
768
- throw new Error(`Process ${childProcess.pid} doesn't have IPC channels`);
769
- } else if (!childProcess.connected) {
770
- throw new Error(`Process ${childProcess.pid} doesn't have open IPC channels`);
771
- }
772
- const { id, once } = options;
773
- const { promise: resultPromise, resolve: resolveResult, reject: rejectResult } = createControlledPromise();
774
- const { promise: sendPromise, resolve: resolveSend, reject: rejectSend } = createControlledPromise();
775
- const handleMessage = /* @__PURE__ */ __name((message) => {
776
- if ((message == null ? void 0 : message.id) === id) {
777
- if (message.type === RpcGMCallTypes.RESOLVE) {
778
- resolveResult(message.value);
779
- } else if (message.type === RpcGMCallTypes.REJECT) {
780
- rejectResult(message.error);
781
- }
782
- }
783
- if (once && (childProcess == null ? void 0 : childProcess.kill)) {
784
- childProcess.kill("SIGTERM");
785
- }
786
- }, "handleMessage");
787
- const handleClose = /* @__PURE__ */ __name((code, signal) => {
788
- rejectResult(new RpcExitError(code ? `Process ${childProcess.pid} exited with code ${code}${signal ? ` [${signal}]` : ""}` : `Process ${childProcess.pid} exited${signal ? ` [${signal}]` : ""}`, code, signal));
789
- removeHandlers();
790
- }, "handleClose");
791
- const removeHandlers = /* @__PURE__ */ __name(() => {
792
- childProcess.off("message", handleMessage);
793
- childProcess.off("close", handleClose);
794
- }, "removeHandlers");
795
- if (once) {
796
- childProcess.once("message", handleMessage);
797
- } else {
798
- childProcess.on("message", handleMessage);
799
- }
800
- childProcess.on("close", handleClose);
801
- childProcess.send({
802
- type: RpcGMCallTypes.CALL,
803
- id,
804
- args
805
- }, (error2) => {
806
- if (error2) {
807
- rejectSend(error2);
808
- removeHandlers();
809
- } else {
810
- resolveSend(void 0);
811
- }
812
- });
813
- return sendPromise.then(() => resultPromise);
814
- });
815
- }
816
- __name(wrapRpc, "wrapRpc");
817
-
818
- // packages/dts-plugin/src/core/rpc/rpc-worker.ts
819
- var child_process = __toESM(require("child_process"));
820
- var process3 = __toESM(require("process"));
821
- var import_crypto2 = require("crypto");
822
- var FEDERATION_WORKER_DATA_ENV_KEY = "VMOK_WORKER_DATA_ENV";
823
- function createRpcWorker(modulePath, data, memoryLimit, once) {
824
- const options = {
825
- env: __spreadProps(__spreadValues({}, process3.env), {
826
- [FEDERATION_WORKER_DATA_ENV_KEY]: JSON.stringify(data || {})
827
- }),
828
- stdio: [
829
- "inherit",
830
- "inherit",
831
- "inherit",
832
- "ipc"
833
- ],
834
- serialization: "advanced"
835
- };
836
- if (memoryLimit) {
837
- options.execArgv = [
838
- `--max-old-space-size=${memoryLimit}`
839
- ];
840
- }
841
- let childProcess, remoteMethod;
842
- const id = (0, import_crypto2.randomUUID)();
843
- const worker = {
844
- connect(...args) {
845
- if (childProcess && !childProcess.connected) {
846
- childProcess.send({
847
- type: RpcGMCallTypes.EXIT,
848
- id
849
- });
850
- childProcess = void 0;
851
- remoteMethod = void 0;
852
- }
853
- if (!(childProcess == null ? void 0 : childProcess.connected)) {
854
- childProcess = child_process.fork(modulePath, options);
855
- remoteMethod = wrapRpc(childProcess, {
856
- id,
857
- once
858
- });
859
- }
860
- if (!remoteMethod) {
861
- return Promise.reject(new Error("Worker is not connected - cannot perform RPC."));
862
- }
863
- return remoteMethod(...args);
864
- },
865
- terminate() {
866
- var _a3;
867
- (_a3 = childProcess == null ? void 0 : childProcess.send) == null ? void 0 : _a3.call(childProcess, {
868
- type: RpcGMCallTypes.EXIT,
869
- id
870
- });
871
- childProcess = void 0;
872
- remoteMethod = void 0;
873
- },
874
- get connected() {
875
- return Boolean(childProcess == null ? void 0 : childProcess.connected);
876
- },
877
- get process() {
878
- return childProcess;
879
- },
880
- get id() {
881
- return id;
882
- }
883
- };
884
- return worker;
885
- }
886
- __name(createRpcWorker, "createRpcWorker");
887
- function getRpcWorkerData() {
888
- return JSON.parse(process3.env[FEDERATION_WORKER_DATA_ENV_KEY] || "{}");
889
- }
890
- __name(getRpcWorkerData, "getRpcWorkerData");
891
-
892
- // packages/dts-plugin/src/core/constant.ts
893
- var REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
894
- var REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
895
- var HOST_API_TYPES_FILE_NAME = "index.d.ts";
896
- var UpdateMode;
897
- (function(UpdateMode2) {
898
- UpdateMode2["POSITIVE"] = "POSITIVE";
899
- UpdateMode2["PASSIVE"] = "PASSIVE";
900
- })(UpdateMode || (UpdateMode = {}));
901
-
902
664
  // packages/dts-plugin/src/server/broker/Broker.ts
903
665
  var import_http = require("http");
904
666
  var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
@@ -989,13 +751,13 @@ ${err.message}
989
751
  this._webSocketServer = void 0;
990
752
  });
991
753
  server.on("upgrade", (req, socket, head) => {
992
- var _a3;
754
+ var _a2;
993
755
  if (req.url) {
994
756
  const { pathname } = (0, import_url.parse)(req.url);
995
757
  if (pathname === "/") {
996
- (_a3 = this._webSocketServer) == null ? void 0 : _a3.handleUpgrade(req, socket, head, (ws) => {
997
- var _a4;
998
- (_a4 = this._webSocketServer) == null ? void 0 : _a4.emit("connection", ws, req);
758
+ (_a2 = this._webSocketServer) == null ? void 0 : _a2.handleUpgrade(req, socket, head, (ws) => {
759
+ var _a3;
760
+ (_a3 = this._webSocketServer) == null ? void 0 : _a3.emit("connection", ws, req);
999
761
  });
1000
762
  }
1001
763
  }
@@ -1380,8 +1142,8 @@ ${err.message}
1380
1142
  }
1381
1143
  }
1382
1144
  _getTmpSubScribers(publisherIdentifier) {
1383
- var _a3;
1384
- return (_a3 = this._tmpSubscriberShelter.get(publisherIdentifier)) == null ? void 0 : _a3.subscribers;
1145
+ var _a2;
1146
+ return (_a2 = this._tmpSubscriberShelter.get(publisherIdentifier)) == null ? void 0 : _a2.subscribers;
1385
1147
  }
1386
1148
  // after adding publisher, it will change the temp subscriber to regular subscriber
1387
1149
  _consumeTmpSubScribers(publisher, tmpSubScribers) {
@@ -1486,9 +1248,9 @@ ${err.message}
1486
1248
  process.exit(0);
1487
1249
  }
1488
1250
  broadcast(message) {
1489
- var _a3, _b;
1251
+ var _a2, _b;
1490
1252
  fileLog(`[broadcast] exit info : ${JSON.stringify(message)}`, "Broker", "warn");
1491
- (_a3 = this._webSocketServer) == null ? void 0 : _a3.clients.forEach((client) => {
1253
+ (_a2 = this._webSocketServer) == null ? void 0 : _a2.clients.forEach((client) => {
1492
1254
  client.send(JSON.stringify(message));
1493
1255
  });
1494
1256
  (_b = this._secureWebSocketServer) == null ? void 0 : _b.clients.forEach((client) => {
@@ -1562,9 +1324,85 @@ var downloadTypesArchive = /* @__PURE__ */ __name((hostOptions) => {
1562
1324
  });
1563
1325
  }, "downloadTypesArchive");
1564
1326
 
1327
+ // packages/dts-plugin/src/core/configurations/hostPlugin.ts
1328
+ var import_sdk4 = require("@module-federation/sdk");
1329
+ var import_managers2 = require("@module-federation/managers");
1330
+ var defaultOptions2 = {
1331
+ typesFolder: "@mf-types",
1332
+ remoteTypesFolder: "@mf-types",
1333
+ deleteTypesFolder: true,
1334
+ maxRetries: 3,
1335
+ implementation: "",
1336
+ context: process.cwd(),
1337
+ abortOnError: true,
1338
+ consumeAPITypes: false,
1339
+ runtimePkgs: []
1340
+ };
1341
+ var buildZipUrl = /* @__PURE__ */ __name((hostOptions, url) => {
1342
+ const remoteUrl = new URL(url, "file:");
1343
+ const pathnameWithoutEntry = remoteUrl.pathname.split("/").slice(0, -1).join("/");
1344
+ remoteUrl.pathname = `${pathnameWithoutEntry}/${hostOptions.remoteTypesFolder}.zip`;
1345
+ return remoteUrl.protocol === "file:" ? remoteUrl.pathname : remoteUrl.href;
1346
+ }, "buildZipUrl");
1347
+ var buildApiTypeUrl = /* @__PURE__ */ __name((zipUrl) => {
1348
+ if (!zipUrl) {
1349
+ return void 0;
1350
+ }
1351
+ return zipUrl.replace(".zip", ".d.ts");
1352
+ }, "buildApiTypeUrl");
1353
+ var retrieveRemoteInfo = /* @__PURE__ */ __name((options) => {
1354
+ const { hostOptions, remoteAlias, remote } = options;
1355
+ let decodedRemote = remote;
1356
+ if (decodedRemote.startsWith(import_sdk4.ENCODE_NAME_PREFIX)) {
1357
+ decodedRemote = (0, import_sdk4.decodeName)(decodedRemote, import_sdk4.ENCODE_NAME_PREFIX);
1358
+ }
1359
+ const parsedInfo = (0, import_sdk4.parseEntry)(decodedRemote, void 0, "@");
1360
+ const url = "entry" in parsedInfo ? parsedInfo.entry : parsedInfo.name === decodedRemote ? decodedRemote : "";
1361
+ const zipUrl = url ? buildZipUrl(hostOptions, url) : "";
1362
+ return {
1363
+ name: parsedInfo.name || remoteAlias,
1364
+ url,
1365
+ zipUrl,
1366
+ apiTypeUrl: buildApiTypeUrl(zipUrl),
1367
+ alias: remoteAlias
1368
+ };
1369
+ }, "retrieveRemoteInfo");
1370
+ var resolveRemotes = /* @__PURE__ */ __name((hostOptions) => {
1371
+ const parsedOptions = import_managers2.utils.parseOptions(hostOptions.moduleFederationConfig.remotes || {}, (item, key) => ({
1372
+ remote: Array.isArray(item) ? item[0] : item,
1373
+ key
1374
+ }), (item, key) => ({
1375
+ remote: Array.isArray(item.external) ? item.external[0] : item.external,
1376
+ key
1377
+ }));
1378
+ return parsedOptions.reduce((accumulator, item) => {
1379
+ const { key, remote } = item[1];
1380
+ accumulator[key] = retrieveRemoteInfo({
1381
+ hostOptions,
1382
+ remoteAlias: key,
1383
+ remote
1384
+ });
1385
+ return accumulator;
1386
+ }, {});
1387
+ }, "resolveRemotes");
1388
+ var retrieveHostConfig = /* @__PURE__ */ __name((options) => {
1389
+ validateOptions(options);
1390
+ const hostOptions = __spreadValues(__spreadValues({}, defaultOptions2), options);
1391
+ const mapRemotesToDownload = resolveRemotes(hostOptions);
1392
+ return {
1393
+ hostOptions,
1394
+ mapRemotesToDownload
1395
+ };
1396
+ }, "retrieveHostConfig");
1397
+
1398
+ // packages/dts-plugin/src/core/constant.ts
1399
+ var REMOTE_ALIAS_IDENTIFIER = "REMOTE_ALIAS_IDENTIFIER";
1400
+ var REMOTE_API_TYPES_FILE_NAME = "apis.d.ts";
1401
+ var HOST_API_TYPES_FILE_NAME = "index.d.ts";
1402
+
1565
1403
  // packages/dts-plugin/src/core/lib/DTSManager.ts
1566
- var _a2;
1567
- var DTSManager = (_a2 = class {
1404
+ var _a;
1405
+ var DTSManager = (_a = class {
1568
1406
  constructor(options) {
1569
1407
  __publicField(this, "options");
1570
1408
  __publicField(this, "runtimePkgs");
@@ -1572,11 +1410,7 @@ var DTSManager = (_a2 = class {
1572
1410
  __publicField(this, "loadedRemoteAPIAlias");
1573
1411
  __publicField(this, "extraOptions");
1574
1412
  __publicField(this, "updatedRemoteInfos");
1575
- this.options = (0, import_lodash2.default)(options, (_value, key) => {
1576
- if (key === "manifest") {
1577
- return false;
1578
- }
1579
- });
1413
+ this.options = cloneDeepOptions(options);
1580
1414
  this.runtimePkgs = [
1581
1415
  "@module-federation/runtime",
1582
1416
  "@module-federation/enhanced/runtime",
@@ -1635,7 +1469,7 @@ var DTSManager = (_a2 = class {
1635
1469
  }
1636
1470
  generateTypes() {
1637
1471
  return __async(this, null, function* () {
1638
- var _a3;
1472
+ var _a2;
1639
1473
  try {
1640
1474
  const { options } = this;
1641
1475
  if (!options.remote) {
@@ -1645,7 +1479,7 @@ var DTSManager = (_a2 = class {
1645
1479
  if (!Object.keys(mapComponentsToExpose).length) {
1646
1480
  return;
1647
1481
  }
1648
- this.extractRemoteTypes({
1482
+ yield this.extractRemoteTypes({
1649
1483
  remoteOptions,
1650
1484
  tsConfig,
1651
1485
  mapComponentsToExpose
@@ -1672,7 +1506,7 @@ var DTSManager = (_a2 = class {
1672
1506
  }
1673
1507
  console.log(import_ansi_colors.default.green("Federated types created correctly"));
1674
1508
  } catch (error2) {
1675
- if (((_a3 = this.options.remote) == null ? void 0 : _a3.abortOnError) === false) {
1509
+ if (((_a2 = this.options.remote) == null ? void 0 : _a2.abortOnError) === false) {
1676
1510
  console.error(import_ansi_colors.default.red(`Unable to compile federated types, ${error2}`));
1677
1511
  } else {
1678
1512
  throw error2;
@@ -1787,7 +1621,16 @@ var DTSManager = (_a2 = class {
1787
1621
  ...packageTypes,
1788
1622
  "Y"
1789
1623
  ].join(" :\n")} ;`;
1790
- const pkgsDeclareStr = this.runtimePkgs.map((pkg) => {
1624
+ const runtimePkgs = /* @__PURE__ */ new Set();
1625
+ [
1626
+ ...this.runtimePkgs,
1627
+ ...hostOptions.runtimePkgs
1628
+ ].forEach((pkg) => {
1629
+ runtimePkgs.add(pkg);
1630
+ });
1631
+ const pkgsDeclareStr = [
1632
+ ...runtimePkgs
1633
+ ].map((pkg) => {
1791
1634
  return `declare module "${pkg}" {
1792
1635
  ${remoteKeysStr}
1793
1636
  ${packageTypesStr}
@@ -1820,7 +1663,7 @@ var DTSManager = (_a2 = class {
1820
1663
  }
1821
1664
  consumeTypes() {
1822
1665
  return __async(this, null, function* () {
1823
- var _a3;
1666
+ var _a2;
1824
1667
  try {
1825
1668
  const { options } = this;
1826
1669
  if (!options.host) {
@@ -1847,7 +1690,7 @@ var DTSManager = (_a2 = class {
1847
1690
  }
1848
1691
  console.log(import_ansi_colors.default.green("Federated types extraction completed"));
1849
1692
  } catch (err) {
1850
- if (((_a3 = this.options.host) == null ? void 0 : _a3.abortOnError) === false) {
1693
+ if (((_a2 = this.options.host) == null ? void 0 : _a2.abortOnError) === false) {
1851
1694
  fileLog(`Unable to consume federated types, ${err}`, "consumeTypes", "error");
1852
1695
  } else {
1853
1696
  throw err;
@@ -1857,10 +1700,10 @@ var DTSManager = (_a2 = class {
1857
1700
  }
1858
1701
  updateTypes(options) {
1859
1702
  return __async(this, null, function* () {
1860
- var _a3, _b, _c;
1703
+ var _a2, _b, _c;
1861
1704
  try {
1862
1705
  const { remoteName, updateMode, remoteInfo: updatedRemoteInfo, once } = options;
1863
- const hostName = (_c = (_b = (_a3 = this.options) == null ? void 0 : _a3.host) == null ? void 0 : _b.moduleFederationConfig) == null ? void 0 : _c.name;
1706
+ const hostName = (_c = (_b = (_a2 = this.options) == null ? void 0 : _a2.host) == null ? void 0 : _b.moduleFederationConfig) == null ? void 0 : _c.name;
1864
1707
  fileLog(`updateTypes options:, ${JSON.stringify(options, null, 2)}`, "consumeTypes", "info");
1865
1708
  if (updateMode === UpdateMode.POSITIVE && remoteName === hostName) {
1866
1709
  if (!this.options.remote) {
@@ -1874,7 +1717,7 @@ var DTSManager = (_a2 = class {
1874
1717
  }
1875
1718
  const { hostOptions, mapRemotesToDownload } = retrieveHostConfig(this.options.host);
1876
1719
  const loadedRemoteInfo = Object.values(remoteAliasMap).find((i) => i.name === remoteName);
1877
- const consumeTypes2 = /* @__PURE__ */ __name((requiredRemoteInfo) => __async(this, null, function* () {
1720
+ const consumeTypes = /* @__PURE__ */ __name((requiredRemoteInfo) => __async(this, null, function* () {
1878
1721
  const [_alias, destinationPath] = yield this.consumeTargetRemotes(hostOptions, requiredRemoteInfo);
1879
1722
  yield this.downloadAPITypes(requiredRemoteInfo, destinationPath);
1880
1723
  }), "consumeTypes");
@@ -1887,10 +1730,10 @@ var DTSManager = (_a2 = class {
1887
1730
  const requiredRemoteInfo = yield this.requestRemoteManifest(remoteInfo);
1888
1731
  this.remoteAliasMap[remoteInfo.alias] = requiredRemoteInfo;
1889
1732
  }
1890
- yield consumeTypes2(this.remoteAliasMap[remoteInfo.alias]);
1733
+ yield consumeTypes(this.remoteAliasMap[remoteInfo.alias]);
1891
1734
  } else if (updatedRemoteInfo) {
1892
1735
  const consumeDynamicRemoteTypes = /* @__PURE__ */ __name(() => __async(this, null, function* () {
1893
- yield consumeTypes2(this.updatedRemoteInfos[updatedRemoteInfo.name]);
1736
+ yield consumeTypes(this.updatedRemoteInfos[updatedRemoteInfo.name]);
1894
1737
  this.consumeAPITypes(hostOptions);
1895
1738
  }), "consumeDynamicRemoteTypes");
1896
1739
  if (!this.updatedRemoteInfos[updatedRemoteInfo.name]) {
@@ -1909,7 +1752,7 @@ var DTSManager = (_a2 = class {
1909
1752
  }
1910
1753
  }
1911
1754
  } else {
1912
- yield consumeTypes2(loadedRemoteInfo);
1755
+ yield consumeTypes(loadedRemoteInfo);
1913
1756
  }
1914
1757
  }
1915
1758
  } catch (err) {
@@ -1917,9 +1760,10 @@ var DTSManager = (_a2 = class {
1917
1760
  }
1918
1761
  });
1919
1762
  }
1920
- }, __name(_a2, "DTSManager"), _a2);
1763
+ }, __name(_a, "DTSManager"), _a);
1921
1764
 
1922
1765
  // packages/dts-plugin/src/core/lib/utils.ts
1766
+ var import_lodash = __toESM(require("lodash.clonedeepwith"));
1923
1767
  function getDTSManagerConstructor(implementation) {
1924
1768
  if (implementation) {
1925
1769
  const NewConstructor = require(implementation);
@@ -1937,6 +1781,18 @@ function isDebugMode() {
1937
1781
  return Boolean(process.env["FEDERATION_DEBUG"]) || process.env["NODE_ENV"] === "test";
1938
1782
  }
1939
1783
  __name(isDebugMode, "isDebugMode");
1784
+ function cloneDeepOptions(options) {
1785
+ const excludeKeys = [
1786
+ "manifest",
1787
+ "async"
1788
+ ];
1789
+ return (0, import_lodash.default)(options, (_value, key) => {
1790
+ if (typeof key === "string" && excludeKeys.includes(key)) {
1791
+ return false;
1792
+ }
1793
+ });
1794
+ }
1795
+ __name(cloneDeepOptions, "cloneDeepOptions");
1940
1796
  function axiosGet(url, config) {
1941
1797
  return __async(this, null, function* () {
1942
1798
  const httpAgent = new import_http2.default.Agent({
@@ -1956,8 +1812,8 @@ __name(axiosGet, "axiosGet");
1956
1812
  // packages/dts-plugin/src/core/lib/generateTypes.ts
1957
1813
  function generateTypes(options) {
1958
1814
  return __async(this, null, function* () {
1959
- var _a3;
1960
- const DTSManagerConstructor = getDTSManagerConstructor((_a3 = options.remote) == null ? void 0 : _a3.implementation);
1815
+ var _a2;
1816
+ const DTSManagerConstructor = getDTSManagerConstructor((_a2 = options.remote) == null ? void 0 : _a2.implementation);
1961
1817
  const dtsManager = new DTSManagerConstructor(options);
1962
1818
  return dtsManager.generateTypes();
1963
1819
  });
@@ -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) {