@module-federation/dts-plugin 0.0.0-fix-loop-load-20260203135642 → 0.0.0-fix-array-share-scope-20260225123251

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,13 +1,44 @@
1
1
  # @module-federation/dts-plugin
2
2
 
3
- ## 0.0.0-fix-loop-load-20260203135642
3
+ ## 0.0.0-fix-array-share-scope-20260225123251
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - @module-federation/sdk@0.0.0-fix-loop-load-20260203135642
8
- - @module-federation/managers@0.0.0-fix-loop-load-20260203135642
9
- - @module-federation/third-party-dts-extractor@0.0.0-fix-loop-load-20260203135642
10
- - @module-federation/error-codes@0.0.0-fix-loop-load-20260203135642
7
+ - 6235711: Replace the Koa-based dev types server with a native Node HTTP server to reduce dependencies and keep type generation behavior unchanged.
8
+ - 5954fe7: Fix fork-dev-worker crashes in dts-plugin when consumeTypes is disabled
9
+ - @module-federation/sdk@0.0.0-fix-array-share-scope-20260225123251
10
+ - @module-federation/managers@0.0.0-fix-array-share-scope-20260225123251
11
+ - @module-federation/third-party-dts-extractor@0.0.0-fix-array-share-scope-20260225123251
12
+ - @module-federation/error-codes@0.0.0-fix-array-share-scope-20260225123251
13
+
14
+ ## 2.0.1
15
+
16
+ ### Patch Changes
17
+
18
+ - 28a2db4: Fix Windows TypeScript type generation by invoking the compiler with
19
+ `execFile` and properly quoted project paths.
20
+ - @module-federation/sdk@2.0.1
21
+ - @module-federation/managers@2.0.1
22
+ - @module-federation/third-party-dts-extractor@2.0.1
23
+ - @module-federation/error-codes@2.0.1
24
+
25
+ ## 2.0.0
26
+
27
+ ### Patch Changes
28
+
29
+ - @module-federation/sdk@2.0.0
30
+ - @module-federation/managers@2.0.0
31
+ - @module-federation/third-party-dts-extractor@2.0.0
32
+ - @module-federation/error-codes@2.0.0
33
+
34
+ ## 0.24.1
35
+
36
+ ### Patch Changes
37
+
38
+ - @module-federation/sdk@0.24.1
39
+ - @module-federation/managers@0.24.1
40
+ - @module-federation/third-party-dts-extractor@0.24.1
41
+ - @module-federation/error-codes@0.24.1
11
42
 
12
43
  ## 0.24.0
13
44
 
package/dist/core.js CHANGED
@@ -1015,9 +1015,8 @@ __publicField(_Broker, "DEFAULT_SECURE_WEB_SOCKET_PORT", 16324);
1015
1015
  __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
1016
1016
  var Broker = _Broker;
1017
1017
 
1018
- // src/server/createKoaServer.ts
1018
+ // src/server/createHttpServer.ts
1019
1019
  var import_fs_extra = __toESM(require("fs-extra"));
1020
- var import_koa = __toESM(require("koa"));
1021
1020
 
1022
1021
  // src/core/lib/typeScriptCompiler.ts
1023
1022
  var STARTS_WITH_SLASH = /^\//;
@@ -1101,6 +1100,59 @@ var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
1101
1100
  return "npx";
1102
1101
  }
1103
1102
  }, "resolvePackageManagerExecutable");
1103
+ var splitCommandArgs = /* @__PURE__ */ __name((value) => {
1104
+ const args = [];
1105
+ let current = "";
1106
+ let quote = null;
1107
+ let escaped = false;
1108
+ for (const char of value) {
1109
+ if (escaped) {
1110
+ current += char;
1111
+ escaped = false;
1112
+ continue;
1113
+ }
1114
+ if (char === "\\") {
1115
+ escaped = true;
1116
+ continue;
1117
+ }
1118
+ if (quote) {
1119
+ if (char === quote) {
1120
+ quote = null;
1121
+ } else {
1122
+ current += char;
1123
+ }
1124
+ continue;
1125
+ }
1126
+ if (char === '"' || char === "'") {
1127
+ quote = char;
1128
+ continue;
1129
+ }
1130
+ if (char.trim() === "") {
1131
+ if (current) {
1132
+ args.push(current);
1133
+ current = "";
1134
+ }
1135
+ continue;
1136
+ }
1137
+ current += char;
1138
+ }
1139
+ if (current) {
1140
+ args.push(current);
1141
+ }
1142
+ return args;
1143
+ }, "splitCommandArgs");
1144
+ var formatCommandForDisplay = /* @__PURE__ */ __name((executable, args) => {
1145
+ const formatArg = /* @__PURE__ */ __name((arg) => {
1146
+ if (/[\s'"]/.test(arg)) {
1147
+ return JSON.stringify(arg);
1148
+ }
1149
+ return arg;
1150
+ }, "formatArg");
1151
+ return [
1152
+ executable,
1153
+ ...args
1154
+ ].map(formatArg).join(" ");
1155
+ }, "formatCommandForDisplay");
1104
1156
  var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
1105
1157
  var _a3, _b, _c, _d;
1106
1158
  if (!Object.keys(mapComponentsToExpose).length) {
@@ -1116,12 +1168,22 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
1116
1168
  context: remoteOptions.context,
1117
1169
  exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
1118
1170
  });
1119
- const execPromise = import_util.default.promisify(import_child_process.exec);
1171
+ const execPromise = import_util.default.promisify(import_child_process.execFile);
1120
1172
  const pmExecutable = resolvePackageManagerExecutable();
1121
- const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
1173
+ const compilerArgs = splitCommandArgs(remoteOptions.compilerInstance);
1174
+ const resolvedCompilerArgs = compilerArgs.length > 0 ? compilerArgs : [
1175
+ remoteOptions.compilerInstance
1176
+ ];
1177
+ const cmdArgs = [
1178
+ ...resolvedCompilerArgs,
1179
+ "--project",
1180
+ tempTsConfigJsonPath
1181
+ ];
1182
+ const cmd = formatCommandForDisplay(pmExecutable, cmdArgs);
1122
1183
  try {
1123
- yield execPromise(cmd, {
1124
- cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
1184
+ yield execPromise(pmExecutable, cmdArgs, {
1185
+ cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0,
1186
+ shell: process.platform === "win32"
1125
1187
  });
1126
1188
  } catch (err) {
1127
1189
  if (compilerOptions.tsBuildInfoFile) {
@@ -1,4 +1,4 @@
1
- import { ModuleFederationRuntimePlugin } from '@module-federation/runtime/types';
1
+ import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
2
2
 
3
3
  declare function dynamicRemoteTypeHintsPlugin(): ModuleFederationRuntimePlugin;
4
4
 
@@ -1,4 +1,4 @@
1
- import { ModuleFederationRuntimePlugin } from '@module-federation/runtime/types';
1
+ import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
2
2
 
3
3
  declare function dynamicRemoteTypeHintsPlugin(): ModuleFederationRuntimePlugin;
4
4
 
@@ -4,7 +4,7 @@ import {
4
4
  exposeRpc,
5
5
  getDTSManagerConstructor,
6
6
  isDebugMode
7
- } from "./chunk-RWXNVNFM.js";
7
+ } from "./chunk-MCLO3DKC.js";
8
8
  import {
9
9
  __async,
10
10
  __export,
@@ -415,31 +415,47 @@ var _ModuleFederationDevServer = class _ModuleFederationDevServer {
415
415
  __name(_ModuleFederationDevServer, "ModuleFederationDevServer");
416
416
  var ModuleFederationDevServer = _ModuleFederationDevServer;
417
417
 
418
- // src/server/createKoaServer.ts
418
+ // src/server/createHttpServer.ts
419
+ import http from "http";
419
420
  import fs from "fs-extra";
420
- import Koa from "koa";
421
- function createKoaServer(options) {
421
+ function createHttpServer(options) {
422
422
  return __async(this, null, function* () {
423
423
  const { typeTarPath } = options;
424
424
  const freeport = yield getFreePort();
425
- const app = new Koa();
426
- app.use((ctx, next) => __async(this, null, function* () {
427
- if (ctx.path === `/${DEFAULT_TAR_NAME}`) {
428
- ctx.status = 200;
429
- ctx.body = fs.createReadStream(typeTarPath);
430
- ctx.response.type = "application/x-gzip";
431
- } else {
432
- yield next();
425
+ const server = http.createServer((req, res) => {
426
+ var _a2, _b;
427
+ const requestPath = (_b = (_a2 = req.url) == null ? void 0 : _a2.split("?")[0]) != null ? _b : "/";
428
+ if (requestPath === `/${DEFAULT_TAR_NAME}`) {
429
+ res.statusCode = 200;
430
+ res.setHeader("Content-Type", "application/x-gzip");
431
+ if (req.method === "HEAD") {
432
+ res.end();
433
+ return;
434
+ }
435
+ const stream = fs.createReadStream(typeTarPath);
436
+ stream.on("error", () => {
437
+ if (!res.headersSent) {
438
+ res.statusCode = 500;
439
+ }
440
+ res.end();
441
+ });
442
+ res.on("close", () => {
443
+ stream.destroy();
444
+ });
445
+ stream.pipe(res);
446
+ return;
433
447
  }
434
- }));
435
- app.listen(freeport);
448
+ res.statusCode = 404;
449
+ res.end();
450
+ });
451
+ server.listen(freeport);
436
452
  return {
437
- server: app,
453
+ server,
438
454
  serverAddress: `http://${getIPV4()}:${freeport}`
439
455
  };
440
456
  });
441
457
  }
442
- __name(createKoaServer, "createKoaServer");
458
+ __name(createHttpServer, "createHttpServer");
443
459
 
444
460
  // src/core/lib/typeScriptCompiler.ts
445
461
  import { ensureDirSync, writeFileSync, existsSync } from "fs-extra";
@@ -448,7 +464,7 @@ import { stat, readdir, writeFile, rm, readFile } from "fs/promises";
448
464
  import { dirname, join, normalize, relative, resolve, sep, extname, isAbsolute } from "path";
449
465
  import { getShortErrorMsg, TYPE_001, typeDescMap } from "@module-federation/error-codes";
450
466
  import { ThirdPartyExtractor } from "@module-federation/third-party-dts-extractor";
451
- import { exec } from "child_process";
467
+ import { execFile } from "child_process";
452
468
  import util from "util";
453
469
  import { TEMP_DIR } from "@module-federation/sdk";
454
470
  var STARTS_WITH_SLASH = /^\//;
@@ -532,6 +548,59 @@ var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
532
548
  return "npx";
533
549
  }
534
550
  }, "resolvePackageManagerExecutable");
551
+ var splitCommandArgs = /* @__PURE__ */ __name((value) => {
552
+ const args = [];
553
+ let current = "";
554
+ let quote = null;
555
+ let escaped = false;
556
+ for (const char of value) {
557
+ if (escaped) {
558
+ current += char;
559
+ escaped = false;
560
+ continue;
561
+ }
562
+ if (char === "\\") {
563
+ escaped = true;
564
+ continue;
565
+ }
566
+ if (quote) {
567
+ if (char === quote) {
568
+ quote = null;
569
+ } else {
570
+ current += char;
571
+ }
572
+ continue;
573
+ }
574
+ if (char === '"' || char === "'") {
575
+ quote = char;
576
+ continue;
577
+ }
578
+ if (char.trim() === "") {
579
+ if (current) {
580
+ args.push(current);
581
+ current = "";
582
+ }
583
+ continue;
584
+ }
585
+ current += char;
586
+ }
587
+ if (current) {
588
+ args.push(current);
589
+ }
590
+ return args;
591
+ }, "splitCommandArgs");
592
+ var formatCommandForDisplay = /* @__PURE__ */ __name((executable, args) => {
593
+ const formatArg = /* @__PURE__ */ __name((arg) => {
594
+ if (/[\s'"]/.test(arg)) {
595
+ return JSON.stringify(arg);
596
+ }
597
+ return arg;
598
+ }, "formatArg");
599
+ return [
600
+ executable,
601
+ ...args
602
+ ].map(formatArg).join(" ");
603
+ }, "formatCommandForDisplay");
535
604
  var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
536
605
  var _a2, _b, _c, _d;
537
606
  if (!Object.keys(mapComponentsToExpose).length) {
@@ -547,12 +616,22 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
547
616
  context: remoteOptions.context,
548
617
  exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
549
618
  });
550
- const execPromise = util.promisify(exec);
619
+ const execPromise = util.promisify(execFile);
551
620
  const pmExecutable = resolvePackageManagerExecutable();
552
- const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
621
+ const compilerArgs = splitCommandArgs(remoteOptions.compilerInstance);
622
+ const resolvedCompilerArgs = compilerArgs.length > 0 ? compilerArgs : [
623
+ remoteOptions.compilerInstance
624
+ ];
625
+ const cmdArgs = [
626
+ ...resolvedCompilerArgs,
627
+ "--project",
628
+ tempTsConfigJsonPath
629
+ ];
630
+ const cmd = formatCommandForDisplay(pmExecutable, cmdArgs);
553
631
  try {
554
- yield execPromise(cmd, {
555
- cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
632
+ yield execPromise(pmExecutable, cmdArgs, {
633
+ cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0,
634
+ shell: process.platform === "win32"
556
635
  });
557
636
  } catch (err) {
558
637
  if (compilerOptions.tsBuildInfoFile) {
@@ -607,7 +686,7 @@ import { rm as rm3 } from "fs/promises";
607
686
  import fs3 from "fs";
608
687
  import path3 from "path";
609
688
  import axios from "axios";
610
- import http from "http";
689
+ import http2 from "http";
611
690
  import https from "https";
612
691
  import { getProcessEnv } from "@module-federation/sdk";
613
692
  import ansiColors from "ansi-colors";
@@ -1397,7 +1476,7 @@ var getEnvHeaders = /* @__PURE__ */ __name(() => {
1397
1476
  function axiosGet(url, config) {
1398
1477
  return __async(this, null, function* () {
1399
1478
  var _a2, _b;
1400
- const httpAgent = new http.Agent({
1479
+ const httpAgent = new http2.Agent({
1401
1480
  family: (_a2 = config == null ? void 0 : config.family) != null ? _a2 : 4
1402
1481
  });
1403
1482
  const httpsAgent = new https.Agent({
@@ -1557,7 +1636,7 @@ __name(exposeRpc, "exposeRpc");
1557
1636
 
1558
1637
  export {
1559
1638
  ModuleFederationDevServer,
1560
- createKoaServer,
1639
+ createHttpServer,
1561
1640
  retrieveMfTypesPath,
1562
1641
  retrieveOriginalOutDir,
1563
1642
  retrieveTypesZipPath,
package/dist/esm/core.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  consumeTypes,
4
4
  generateTypesInChildProcess,
5
5
  rpc_exports
6
- } from "./chunk-N7GTIQUA.js";
6
+ } from "./chunk-D7JGZSG3.js";
7
7
  import {
8
8
  DTSManager,
9
9
  HOST_API_TYPES_FILE_NAME,
@@ -19,7 +19,7 @@ import {
19
19
  retrieveTypesAssetsInfo,
20
20
  retrieveTypesZipPath,
21
21
  validateOptions
22
- } from "./chunk-RWXNVNFM.js";
22
+ } from "./chunk-MCLO3DKC.js";
23
23
  import "./chunk-WWV5RWOP.js";
24
24
  import "./chunk-647HGGGS.js";
25
25
  export {
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  rpc_exports
3
- } from "./chunk-N7GTIQUA.js";
3
+ } from "./chunk-D7JGZSG3.js";
4
4
  import {
5
5
  ModuleFederationDevServer,
6
- createKoaServer,
6
+ createHttpServer,
7
7
  getDTSManagerConstructor,
8
8
  retrieveHostConfig,
9
9
  retrieveMfTypesPath,
10
10
  retrieveRemoteConfig,
11
11
  retrieveTypesZipPath
12
- } from "./chunk-RWXNVNFM.js";
12
+ } from "./chunk-MCLO3DKC.js";
13
13
  import {
14
14
  fileLog,
15
15
  getIPV4
@@ -35,7 +35,14 @@ function getLocalRemoteNames(options, encodeNameIdentifier) {
35
35
  if (!options) {
36
36
  return [];
37
37
  }
38
- const { mapRemotesToDownload } = retrieveHostConfig(options);
38
+ let hostConfig;
39
+ try {
40
+ hostConfig = retrieveHostConfig(options);
41
+ } catch (e) {
42
+ fileLog(`getLocalRemoteNames: retrieveHostConfig failed: ${e.message}`, "forkDevWorker", "warn");
43
+ return [];
44
+ }
45
+ const { mapRemotesToDownload } = hostConfig;
39
46
  return Object.keys(mapRemotesToDownload).reduce((sum, remoteModuleName) => {
40
47
  const remoteInfo = mapRemotesToDownload[remoteModuleName];
41
48
  const name = encodeNameIdentifier ? decodeName(remoteInfo.name, encodeNameIdentifier) : remoteInfo.name;
@@ -89,7 +96,7 @@ function forkDevWorker(options, action) {
89
96
  const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
90
97
  const mfTypesZipPath = retrieveTypesZipPath(mfTypesPath, remoteOptions);
91
98
  yield Promise.all([
92
- createKoaServer({
99
+ createHttpServer({
93
100
  typeTarPath: mfTypesZipPath
94
101
  }).then((res) => {
95
102
  serverAddress = res.serverAddress;
@@ -135,7 +142,7 @@ process.on("message", (message) => {
135
142
  fileLog(`ChildProcess(${process.pid}), message: ${JSON.stringify(message)} `, "forkDevWorker", "info");
136
143
  if (message.type === rpc_exports.RpcGMCallTypes.EXIT) {
137
144
  fileLog(`ChildProcess(${process.pid}) SIGTERM, Federation DevServer will exit...`, "forkDevWorker", "error");
138
- moduleServer.exit();
145
+ moduleServer == null ? void 0 : moduleServer.exit();
139
146
  process.exit(0);
140
147
  }
141
148
  });
@@ -2,7 +2,7 @@ import {
2
2
  RpcGMCallTypes,
3
3
  exposeRpc,
4
4
  generateTypes
5
- } from "./chunk-RWXNVNFM.js";
5
+ } from "./chunk-MCLO3DKC.js";
6
6
  import "./chunk-WWV5RWOP.js";
7
7
  import {
8
8
  __async,
package/dist/esm/index.js CHANGED
@@ -2,14 +2,14 @@ import {
2
2
  consumeTypes,
3
3
  generateTypesInChildProcess,
4
4
  rpc_exports
5
- } from "./chunk-N7GTIQUA.js";
5
+ } from "./chunk-D7JGZSG3.js";
6
6
  import {
7
7
  cloneDeepOptions,
8
8
  generateTypes,
9
9
  isTSProject,
10
10
  retrieveTypesAssetsInfo,
11
11
  validateOptions
12
- } from "./chunk-RWXNVNFM.js";
12
+ } from "./chunk-MCLO3DKC.js";
13
13
  import {
14
14
  getIPV4,
15
15
  logger
@@ -456,10 +456,10 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
456
456
  logger3.debug("generate types success!");
457
457
  if (isProd) {
458
458
  if (zipTypesPath && !compilation.getAsset(zipName) && fs2.existsSync(zipTypesPath)) {
459
- compilation.emitAsset(zipName, new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath), false));
459
+ compilation.emitAsset(zipName, new compiler.webpack.sources.RawSource(fs2.readFileSync(zipTypesPath)));
460
460
  }
461
461
  if (apiTypesPath && !compilation.getAsset(apiFileName) && fs2.existsSync(apiTypesPath)) {
462
- compilation.emitAsset(apiFileName, new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath), false));
462
+ compilation.emitAsset(apiFileName, new compiler.webpack.sources.RawSource(fs2.readFileSync(apiTypesPath)));
463
463
  }
464
464
  callback();
465
465
  } else {
@@ -95,7 +95,7 @@ var import_typescript = __toESM(require("typescript"));
95
95
 
96
96
  // src/core/lib/utils.ts
97
97
  var import_axios = __toESM(require("axios"));
98
- var import_http2 = __toESM(require("http"));
98
+ var import_http3 = __toESM(require("http"));
99
99
  var import_https = __toESM(require("https"));
100
100
  var import_sdk6 = require("@module-federation/sdk");
101
101
  var import_ansi_colors = __toESM(require("ansi-colors"));
@@ -1513,31 +1513,47 @@ var _ModuleFederationDevServer = class _ModuleFederationDevServer {
1513
1513
  __name(_ModuleFederationDevServer, "ModuleFederationDevServer");
1514
1514
  var ModuleFederationDevServer = _ModuleFederationDevServer;
1515
1515
 
1516
- // src/server/createKoaServer.ts
1516
+ // src/server/createHttpServer.ts
1517
+ var import_http2 = __toESM(require("http"));
1517
1518
  var import_fs_extra = __toESM(require("fs-extra"));
1518
- var import_koa = __toESM(require("koa"));
1519
- function createKoaServer(options) {
1519
+ function createHttpServer(options) {
1520
1520
  return __async(this, null, function* () {
1521
1521
  const { typeTarPath } = options;
1522
1522
  const freeport = yield getFreePort();
1523
- const app = new import_koa.default();
1524
- app.use((ctx, next) => __async(this, null, function* () {
1525
- if (ctx.path === `/${DEFAULT_TAR_NAME}`) {
1526
- ctx.status = 200;
1527
- ctx.body = import_fs_extra.default.createReadStream(typeTarPath);
1528
- ctx.response.type = "application/x-gzip";
1529
- } else {
1530
- yield next();
1523
+ const server = import_http2.default.createServer((req, res) => {
1524
+ var _a3, _b;
1525
+ const requestPath = (_b = (_a3 = req.url) == null ? void 0 : _a3.split("?")[0]) != null ? _b : "/";
1526
+ if (requestPath === `/${DEFAULT_TAR_NAME}`) {
1527
+ res.statusCode = 200;
1528
+ res.setHeader("Content-Type", "application/x-gzip");
1529
+ if (req.method === "HEAD") {
1530
+ res.end();
1531
+ return;
1532
+ }
1533
+ const stream = import_fs_extra.default.createReadStream(typeTarPath);
1534
+ stream.on("error", () => {
1535
+ if (!res.headersSent) {
1536
+ res.statusCode = 500;
1537
+ }
1538
+ res.end();
1539
+ });
1540
+ res.on("close", () => {
1541
+ stream.destroy();
1542
+ });
1543
+ stream.pipe(res);
1544
+ return;
1531
1545
  }
1532
- }));
1533
- app.listen(freeport);
1546
+ res.statusCode = 404;
1547
+ res.end();
1548
+ });
1549
+ server.listen(freeport);
1534
1550
  return {
1535
- server: app,
1551
+ server,
1536
1552
  serverAddress: `http://${getIPV4()}:${freeport}`
1537
1553
  };
1538
1554
  });
1539
1555
  }
1540
- __name(createKoaServer, "createKoaServer");
1556
+ __name(createHttpServer, "createHttpServer");
1541
1557
 
1542
1558
  // src/core/lib/typeScriptCompiler.ts
1543
1559
  var STARTS_WITH_SLASH = /^\//;
@@ -1621,6 +1637,59 @@ var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
1621
1637
  return "npx";
1622
1638
  }
1623
1639
  }, "resolvePackageManagerExecutable");
1640
+ var splitCommandArgs = /* @__PURE__ */ __name((value) => {
1641
+ const args = [];
1642
+ let current = "";
1643
+ let quote = null;
1644
+ let escaped = false;
1645
+ for (const char of value) {
1646
+ if (escaped) {
1647
+ current += char;
1648
+ escaped = false;
1649
+ continue;
1650
+ }
1651
+ if (char === "\\") {
1652
+ escaped = true;
1653
+ continue;
1654
+ }
1655
+ if (quote) {
1656
+ if (char === quote) {
1657
+ quote = null;
1658
+ } else {
1659
+ current += char;
1660
+ }
1661
+ continue;
1662
+ }
1663
+ if (char === '"' || char === "'") {
1664
+ quote = char;
1665
+ continue;
1666
+ }
1667
+ if (char.trim() === "") {
1668
+ if (current) {
1669
+ args.push(current);
1670
+ current = "";
1671
+ }
1672
+ continue;
1673
+ }
1674
+ current += char;
1675
+ }
1676
+ if (current) {
1677
+ args.push(current);
1678
+ }
1679
+ return args;
1680
+ }, "splitCommandArgs");
1681
+ var formatCommandForDisplay = /* @__PURE__ */ __name((executable, args) => {
1682
+ const formatArg = /* @__PURE__ */ __name((arg) => {
1683
+ if (/[\s'"]/.test(arg)) {
1684
+ return JSON.stringify(arg);
1685
+ }
1686
+ return arg;
1687
+ }, "formatArg");
1688
+ return [
1689
+ executable,
1690
+ ...args
1691
+ ].map(formatArg).join(" ");
1692
+ }, "formatCommandForDisplay");
1624
1693
  var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
1625
1694
  var _a3, _b, _c, _d;
1626
1695
  if (!Object.keys(mapComponentsToExpose).length) {
@@ -1636,12 +1705,22 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
1636
1705
  context: remoteOptions.context,
1637
1706
  exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
1638
1707
  });
1639
- const execPromise = import_util.default.promisify(import_child_process2.exec);
1708
+ const execPromise = import_util.default.promisify(import_child_process2.execFile);
1640
1709
  const pmExecutable = resolvePackageManagerExecutable();
1641
- const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
1710
+ const compilerArgs = splitCommandArgs(remoteOptions.compilerInstance);
1711
+ const resolvedCompilerArgs = compilerArgs.length > 0 ? compilerArgs : [
1712
+ remoteOptions.compilerInstance
1713
+ ];
1714
+ const cmdArgs = [
1715
+ ...resolvedCompilerArgs,
1716
+ "--project",
1717
+ tempTsConfigJsonPath
1718
+ ];
1719
+ const cmd = formatCommandForDisplay(pmExecutable, cmdArgs);
1642
1720
  try {
1643
- yield execPromise(cmd, {
1644
- cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
1721
+ yield execPromise(pmExecutable, cmdArgs, {
1722
+ cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0,
1723
+ shell: process.platform === "win32"
1645
1724
  });
1646
1725
  } catch (err) {
1647
1726
  if (compilerOptions.tsBuildInfoFile) {
@@ -2330,7 +2409,7 @@ var getEnvHeaders = /* @__PURE__ */ __name(() => {
2330
2409
  function axiosGet(url, config) {
2331
2410
  return __async(this, null, function* () {
2332
2411
  var _a3, _b;
2333
- const httpAgent = new import_http2.default.Agent({
2412
+ const httpAgent = new import_http3.default.Agent({
2334
2413
  family: (_a3 = config == null ? void 0 : config.family) != null ? _a3 : 4
2335
2414
  });
2336
2415
  const httpsAgent = new import_https.default.Agent({
@@ -2762,7 +2841,14 @@ function getLocalRemoteNames(options, encodeNameIdentifier) {
2762
2841
  if (!options) {
2763
2842
  return [];
2764
2843
  }
2765
- const { mapRemotesToDownload } = retrieveHostConfig(options);
2844
+ let hostConfig;
2845
+ try {
2846
+ hostConfig = retrieveHostConfig(options);
2847
+ } catch (e) {
2848
+ fileLog(`getLocalRemoteNames: retrieveHostConfig failed: ${e.message}`, "forkDevWorker", "warn");
2849
+ return [];
2850
+ }
2851
+ const { mapRemotesToDownload } = hostConfig;
2766
2852
  return Object.keys(mapRemotesToDownload).reduce((sum, remoteModuleName) => {
2767
2853
  const remoteInfo = mapRemotesToDownload[remoteModuleName];
2768
2854
  const name = encodeNameIdentifier ? (0, import_sdk7.decodeName)(remoteInfo.name, encodeNameIdentifier) : remoteInfo.name;
@@ -2816,7 +2902,7 @@ function forkDevWorker(options, action) {
2816
2902
  const mfTypesPath = retrieveMfTypesPath(tsConfig, remoteOptions);
2817
2903
  const mfTypesZipPath = retrieveTypesZipPath(mfTypesPath, remoteOptions);
2818
2904
  yield Promise.all([
2819
- createKoaServer({
2905
+ createHttpServer({
2820
2906
  typeTarPath: mfTypesZipPath
2821
2907
  }).then((res) => {
2822
2908
  serverAddress = res.serverAddress;
@@ -2862,7 +2948,7 @@ process.on("message", (message) => {
2862
2948
  fileLog(`ChildProcess(${process.pid}), message: ${JSON.stringify(message)} `, "forkDevWorker", "info");
2863
2949
  if (message.type === rpc_exports.RpcGMCallTypes.EXIT) {
2864
2950
  fileLog(`ChildProcess(${process.pid}) SIGTERM, Federation DevServer will exit...`, "forkDevWorker", "error");
2865
- moduleServer.exit();
2951
+ moduleServer == null ? void 0 : moduleServer.exit();
2866
2952
  process.exit(0);
2867
2953
  }
2868
2954
  });
@@ -1201,9 +1201,8 @@ __publicField(_Broker, "DEFAULT_SECURE_WEB_SOCKET_PORT", 16324);
1201
1201
  __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
1202
1202
  var Broker = _Broker;
1203
1203
 
1204
- // src/server/createKoaServer.ts
1204
+ // src/server/createHttpServer.ts
1205
1205
  var import_fs_extra = __toESM(require("fs-extra"));
1206
- var import_koa = __toESM(require("koa"));
1207
1206
 
1208
1207
  // src/core/lib/typeScriptCompiler.ts
1209
1208
  var STARTS_WITH_SLASH = /^\//;
@@ -1287,6 +1286,59 @@ var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
1287
1286
  return "npx";
1288
1287
  }
1289
1288
  }, "resolvePackageManagerExecutable");
1289
+ var splitCommandArgs = /* @__PURE__ */ __name((value) => {
1290
+ const args = [];
1291
+ let current = "";
1292
+ let quote = null;
1293
+ let escaped = false;
1294
+ for (const char of value) {
1295
+ if (escaped) {
1296
+ current += char;
1297
+ escaped = false;
1298
+ continue;
1299
+ }
1300
+ if (char === "\\") {
1301
+ escaped = true;
1302
+ continue;
1303
+ }
1304
+ if (quote) {
1305
+ if (char === quote) {
1306
+ quote = null;
1307
+ } else {
1308
+ current += char;
1309
+ }
1310
+ continue;
1311
+ }
1312
+ if (char === '"' || char === "'") {
1313
+ quote = char;
1314
+ continue;
1315
+ }
1316
+ if (char.trim() === "") {
1317
+ if (current) {
1318
+ args.push(current);
1319
+ current = "";
1320
+ }
1321
+ continue;
1322
+ }
1323
+ current += char;
1324
+ }
1325
+ if (current) {
1326
+ args.push(current);
1327
+ }
1328
+ return args;
1329
+ }, "splitCommandArgs");
1330
+ var formatCommandForDisplay = /* @__PURE__ */ __name((executable, args) => {
1331
+ const formatArg = /* @__PURE__ */ __name((arg) => {
1332
+ if (/[\s'"]/.test(arg)) {
1333
+ return JSON.stringify(arg);
1334
+ }
1335
+ return arg;
1336
+ }, "formatArg");
1337
+ return [
1338
+ executable,
1339
+ ...args
1340
+ ].map(formatArg).join(" ");
1341
+ }, "formatCommandForDisplay");
1290
1342
  var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
1291
1343
  var _a2, _b, _c, _d;
1292
1344
  if (!Object.keys(mapComponentsToExpose).length) {
@@ -1302,12 +1354,22 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
1302
1354
  context: remoteOptions.context,
1303
1355
  exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
1304
1356
  });
1305
- const execPromise = import_util.default.promisify(import_child_process.exec);
1357
+ const execPromise = import_util.default.promisify(import_child_process.execFile);
1306
1358
  const pmExecutable = resolvePackageManagerExecutable();
1307
- const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
1359
+ const compilerArgs = splitCommandArgs(remoteOptions.compilerInstance);
1360
+ const resolvedCompilerArgs = compilerArgs.length > 0 ? compilerArgs : [
1361
+ remoteOptions.compilerInstance
1362
+ ];
1363
+ const cmdArgs = [
1364
+ ...resolvedCompilerArgs,
1365
+ "--project",
1366
+ tempTsConfigJsonPath
1367
+ ];
1368
+ const cmd = formatCommandForDisplay(pmExecutable, cmdArgs);
1308
1369
  try {
1309
- yield execPromise(cmd, {
1310
- cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
1370
+ yield execPromise(pmExecutable, cmdArgs, {
1371
+ cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0,
1372
+ shell: process.platform === "win32"
1311
1373
  });
1312
1374
  } catch (err) {
1313
1375
  if (compilerOptions.tsBuildInfoFile) {
package/dist/index.js CHANGED
@@ -1044,9 +1044,8 @@ __publicField(_Broker, "DEFAULT_SECURE_WEB_SOCKET_PORT", 16324);
1044
1044
  __publicField(_Broker, "DEFAULT_WAITING_TIME", 1.5 * 60 * 60 * 1e3);
1045
1045
  var Broker = _Broker;
1046
1046
 
1047
- // src/server/createKoaServer.ts
1047
+ // src/server/createHttpServer.ts
1048
1048
  var import_fs_extra = __toESM(require("fs-extra"));
1049
- var import_koa = __toESM(require("koa"));
1050
1049
 
1051
1050
  // src/core/lib/typeScriptCompiler.ts
1052
1051
  var STARTS_WITH_SLASH = /^\//;
@@ -1130,6 +1129,59 @@ var resolvePackageManagerExecutable = /* @__PURE__ */ __name(() => {
1130
1129
  return "npx";
1131
1130
  }
1132
1131
  }, "resolvePackageManagerExecutable");
1132
+ var splitCommandArgs = /* @__PURE__ */ __name((value) => {
1133
+ const args = [];
1134
+ let current = "";
1135
+ let quote = null;
1136
+ let escaped = false;
1137
+ for (const char of value) {
1138
+ if (escaped) {
1139
+ current += char;
1140
+ escaped = false;
1141
+ continue;
1142
+ }
1143
+ if (char === "\\") {
1144
+ escaped = true;
1145
+ continue;
1146
+ }
1147
+ if (quote) {
1148
+ if (char === quote) {
1149
+ quote = null;
1150
+ } else {
1151
+ current += char;
1152
+ }
1153
+ continue;
1154
+ }
1155
+ if (char === '"' || char === "'") {
1156
+ quote = char;
1157
+ continue;
1158
+ }
1159
+ if (char.trim() === "") {
1160
+ if (current) {
1161
+ args.push(current);
1162
+ current = "";
1163
+ }
1164
+ continue;
1165
+ }
1166
+ current += char;
1167
+ }
1168
+ if (current) {
1169
+ args.push(current);
1170
+ }
1171
+ return args;
1172
+ }, "splitCommandArgs");
1173
+ var formatCommandForDisplay = /* @__PURE__ */ __name((executable, args) => {
1174
+ const formatArg = /* @__PURE__ */ __name((arg) => {
1175
+ if (/[\s'"]/.test(arg)) {
1176
+ return JSON.stringify(arg);
1177
+ }
1178
+ return arg;
1179
+ }, "formatArg");
1180
+ return [
1181
+ executable,
1182
+ ...args
1183
+ ].map(formatArg).join(" ");
1184
+ }, "formatCommandForDisplay");
1133
1185
  var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteOptions) => __async(void 0, null, function* () {
1134
1186
  var _a3, _b, _c, _d;
1135
1187
  if (!Object.keys(mapComponentsToExpose).length) {
@@ -1145,12 +1197,22 @@ var compileTs = /* @__PURE__ */ __name((mapComponentsToExpose, tsConfig, remoteO
1145
1197
  context: remoteOptions.context,
1146
1198
  exclude: typeof remoteOptions.extractThirdParty === "object" ? remoteOptions.extractThirdParty.exclude : void 0
1147
1199
  });
1148
- const execPromise = import_util.default.promisify(import_child_process.exec);
1200
+ const execPromise = import_util.default.promisify(import_child_process.execFile);
1149
1201
  const pmExecutable = resolvePackageManagerExecutable();
1150
- const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`;
1202
+ const compilerArgs = splitCommandArgs(remoteOptions.compilerInstance);
1203
+ const resolvedCompilerArgs = compilerArgs.length > 0 ? compilerArgs : [
1204
+ remoteOptions.compilerInstance
1205
+ ];
1206
+ const cmdArgs = [
1207
+ ...resolvedCompilerArgs,
1208
+ "--project",
1209
+ tempTsConfigJsonPath
1210
+ ];
1211
+ const cmd = formatCommandForDisplay(pmExecutable, cmdArgs);
1151
1212
  try {
1152
- yield execPromise(cmd, {
1153
- cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0
1213
+ yield execPromise(pmExecutable, cmdArgs, {
1214
+ cwd: typeof remoteOptions.moduleFederationConfig.dts !== "boolean" ? (_d = (_c = remoteOptions.moduleFederationConfig.dts) == null ? void 0 : _c.cwd) != null ? _d : void 0 : void 0,
1215
+ shell: process.platform === "win32"
1154
1216
  });
1155
1217
  } catch (err) {
1156
1218
  if (compilerOptions.tsBuildInfoFile) {
@@ -2813,10 +2875,10 @@ var _GenerateTypesPlugin = class _GenerateTypesPlugin {
2813
2875
  import_sdk10.logger.debug("generate types success!");
2814
2876
  if (isProd) {
2815
2877
  if (zipTypesPath && !compilation.getAsset(zipName) && import_fs4.default.existsSync(zipTypesPath)) {
2816
- compilation.emitAsset(zipName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(zipTypesPath), false));
2878
+ compilation.emitAsset(zipName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(zipTypesPath)));
2817
2879
  }
2818
2880
  if (apiTypesPath && !compilation.getAsset(apiFileName) && import_fs4.default.existsSync(apiTypesPath)) {
2819
- compilation.emitAsset(apiFileName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(apiTypesPath), false));
2881
+ compilation.emitAsset(apiFileName, new compiler.webpack.sources.RawSource(import_fs4.default.readFileSync(apiTypesPath)));
2820
2882
  }
2821
2883
  callback();
2822
2884
  } else {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.0.0-fix-loop-load-20260203135642",
3
+ "version": "0.0.0-fix-array-share-scope-20260225123251",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -58,7 +58,6 @@
58
58
  "chalk": "3.0.0",
59
59
  "fs-extra": "9.1.0",
60
60
  "isomorphic-ws": "5.0.0",
61
- "koa": "3.0.3",
62
61
  "lodash.clonedeepwith": "4.5.0",
63
62
  "log4js": "6.9.1",
64
63
  "node-schedule": "2.1.1",
@@ -67,14 +66,13 @@
67
66
  },
68
67
  "devDependencies": {
69
68
  "@module-federation/runtime": "workspace:*",
70
- "@types/koa": "2.15.0",
71
69
  "@types/node-schedule": "2.1.7",
72
70
  "@types/ws": "8.5.12",
73
71
  "@vue/tsconfig": "^0.7.0",
74
72
  "rimraf": "~6.0.1",
75
73
  "vue": "^3.5.13",
76
74
  "vue-tsc": "^2.2.10",
77
- "webpack": "^5.98.0"
75
+ "webpack": "^5.104.1"
78
76
  },
79
77
  "peerDependencies": {
80
78
  "typescript": "^4.9.0 || ^5.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/dts-plugin",
3
- "version": "0.0.0-fix-loop-load-20260203135642",
3
+ "version": "0.0.0-fix-array-share-scope-20260225123251",
4
4
  "author": "hanric <hanric.zhang@gmail.com>",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -54,27 +54,25 @@
54
54
  "chalk": "3.0.0",
55
55
  "fs-extra": "9.1.0",
56
56
  "isomorphic-ws": "5.0.0",
57
- "koa": "3.0.3",
58
57
  "lodash.clonedeepwith": "4.5.0",
59
58
  "log4js": "6.9.1",
60
59
  "node-schedule": "2.1.1",
61
60
  "rambda": "^9.1.0",
62
61
  "ws": "8.18.0",
63
- "@module-federation/error-codes": "0.0.0-fix-loop-load-20260203135642",
64
- "@module-federation/sdk": "0.0.0-fix-loop-load-20260203135642",
65
- "@module-federation/managers": "0.0.0-fix-loop-load-20260203135642",
66
- "@module-federation/third-party-dts-extractor": "0.0.0-fix-loop-load-20260203135642"
62
+ "@module-federation/error-codes": "0.0.0-fix-array-share-scope-20260225123251",
63
+ "@module-federation/managers": "0.0.0-fix-array-share-scope-20260225123251",
64
+ "@module-federation/sdk": "0.0.0-fix-array-share-scope-20260225123251",
65
+ "@module-federation/third-party-dts-extractor": "0.0.0-fix-array-share-scope-20260225123251"
67
66
  },
68
67
  "devDependencies": {
69
- "@types/koa": "2.15.0",
70
68
  "@types/node-schedule": "2.1.7",
71
69
  "@types/ws": "8.5.12",
72
70
  "@vue/tsconfig": "^0.7.0",
73
71
  "rimraf": "~6.0.1",
74
72
  "vue": "^3.5.13",
75
73
  "vue-tsc": "^2.2.10",
76
- "webpack": "^5.98.0",
77
- "@module-federation/runtime": "0.0.0-fix-loop-load-20260203135642"
74
+ "webpack": "^5.104.1",
75
+ "@module-federation/runtime": "0.0.0-fix-array-share-scope-20260225123251"
78
76
  },
79
77
  "peerDependencies": {
80
78
  "typescript": "^4.9.0 || ^5.0.0",