rolldown-plugin-dts 0.27.0-beta.1 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -836,8 +836,7 @@ function createGeneratePlugin({ entry, tsconfig, tsconfigRaw, build, incremental
836
836
  * ])
837
837
  */
838
838
  const inputAliasMap = /* @__PURE__ */ new Map();
839
- let childProcess;
840
- let rpc;
839
+ let tscWorker;
841
840
  let tscModule;
842
841
  let tscContext;
843
842
  let tsgoContext;
@@ -846,13 +845,8 @@ function createGeneratePlugin({ entry, tsconfig, tsconfigRaw, build, incremental
846
845
  name: "rolldown-plugin-dts:generate",
847
846
  async buildStart(options) {
848
847
  if (tsgo) tsgoContext = await runTsgo(rootDir, tsconfig, sourcemap, tsgo.path);
849
- else if (!oxc) if (parallel) {
850
- childProcess = fork(new URL(WORKER_URL, import.meta.url), { stdio: "inherit" });
851
- rpc = (await import("birpc")).createBirpc({}, {
852
- post: (data) => childProcess.send(data),
853
- on: (fn) => childProcess.on("message", fn)
854
- });
855
- } else {
848
+ else if (!oxc) if (parallel) tscWorker = createTscWorker();
849
+ else {
856
850
  tscModule = await import("./tsc.mjs");
857
851
  if (newContext) tscContext = createContext();
858
852
  }
@@ -989,7 +983,7 @@ function createGeneratePlugin({ entry, tsconfig, tsconfigRaw, build, incremental
989
983
  context: tscContext
990
984
  };
991
985
  let result;
992
- if (parallel) result = await rpc.tscEmit(options);
986
+ if (parallel) result = await tscWorker.emit(options);
993
987
  else result = tscModule.tscEmit(options);
994
988
  if (result.error) return this.error(result.error);
995
989
  dtsCode = result.code;
@@ -1023,7 +1017,8 @@ export { __json_default_export as default }`;
1023
1017
  for (const fileName of Object.keys(bundle)) if (bundle[fileName].type === "chunk" && !RE_DTS.test(fileName) && !RE_DTS_MAP.test(fileName)) delete bundle[fileName];
1024
1018
  } : void 0,
1025
1019
  async buildEnd() {
1026
- childProcess?.kill();
1020
+ tscWorker?.kill();
1021
+ tscWorker = void 0;
1027
1022
  await tsgoContext?.dispose();
1028
1023
  tsgoContext = void 0;
1029
1024
  if (newContext) tscContext = void 0;
@@ -1033,6 +1028,39 @@ export { __json_default_export as default }`;
1033
1028
  }
1034
1029
  };
1035
1030
  }
1031
+ function createTscWorker() {
1032
+ const childProcess = fork(new URL(WORKER_URL, import.meta.url), {
1033
+ stdio: "inherit",
1034
+ serialization: "advanced"
1035
+ });
1036
+ const pending = /* @__PURE__ */ new Map();
1037
+ let nextId = 0;
1038
+ childProcess.on("message", (response) => {
1039
+ const handler = pending.get(response.id);
1040
+ if (!handler) return;
1041
+ pending.delete(response.id);
1042
+ if (response.error) handler.reject(response.error);
1043
+ else handler.resolve(response.result);
1044
+ });
1045
+ childProcess.on("exit", (code) => {
1046
+ for (const handler of pending.values()) handler.reject(/* @__PURE__ */ new Error(`tsc worker exited with code ${code}`));
1047
+ pending.clear();
1048
+ });
1049
+ return {
1050
+ emit: (options) => new Promise((resolve, reject) => {
1051
+ const id = nextId++;
1052
+ pending.set(id, {
1053
+ resolve,
1054
+ reject
1055
+ });
1056
+ childProcess.send({
1057
+ id,
1058
+ options
1059
+ });
1060
+ }),
1061
+ kill: () => childProcess.kill()
1062
+ };
1063
+ }
1036
1064
  function collectJsonExportMap(code) {
1037
1065
  const exportMap = /* @__PURE__ */ new Map();
1038
1066
  const { program } = parse(code, {
@@ -1,8 +1,13 @@
1
- import { t as tscEmit } from "./index-Pfhuikcq.mjs";
1
+ import { i as TscResult, r as TscOptions } from "./index-Pfhuikcq.mjs";
2
2
  //#region src/tsc/worker.d.ts
3
- declare const functions: {
4
- tscEmit: typeof tscEmit;
5
- };
6
- type TscFunctions = typeof functions;
3
+ interface WorkerRequest {
4
+ id: number;
5
+ options: TscOptions;
6
+ }
7
+ interface WorkerResponse {
8
+ id: number;
9
+ result?: TscResult;
10
+ error?: unknown;
11
+ }
7
12
  //#endregion
8
- export { TscFunctions };
13
+ export { WorkerRequest, WorkerResponse };
@@ -1,10 +1,20 @@
1
1
  import { t as tscEmit } from "./tsc-CgJ-ct_1.mjs";
2
2
  import process from "node:process";
3
- import { createBirpc } from "birpc";
4
3
  //#region src/tsc/worker.ts
5
- createBirpc({ tscEmit }, {
6
- post: (data) => process.send(data),
7
- on: (fn) => process.on("message", fn)
4
+ process.on("message", (request) => {
5
+ let response;
6
+ try {
7
+ response = {
8
+ id: request.id,
9
+ result: tscEmit(request.options)
10
+ };
11
+ } catch (error) {
12
+ response = {
13
+ id: request.id,
14
+ error
15
+ };
16
+ }
17
+ process.send(response);
8
18
  });
9
19
  //#endregion
10
20
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
3
  "type": "module",
4
- "version": "0.27.0-beta.1",
4
+ "version": "0.27.0",
5
5
  "description": "A Rolldown plugin to generate and bundle dts files.",
6
6
  "author": "Kevin Deng <sxzz@sxzz.moe>",
7
7
  "license": "MIT",
@@ -62,7 +62,6 @@
62
62
  }
63
63
  },
64
64
  "dependencies": {
65
- "birpc": "^4.0.0",
66
65
  "dts-resolver": "^3.0.0",
67
66
  "get-tsconfig": "5.0.0-beta.5",
68
67
  "obug": "^2.1.3",
@@ -76,7 +75,7 @@
76
75
  "@sxzz/prettier-config": "^2.3.1",
77
76
  "@sxzz/test-utils": "^0.5.18",
78
77
  "@types/node": "^26.1.0",
79
- "@typescript/native-preview": "7.0.0-dev.20260704.1",
78
+ "@typescript/native-preview": "7.0.0-dev.20260705.1",
80
79
  "@volar/typescript": "^2.4.28",
81
80
  "@vue/language-core": "^3.3.6",
82
81
  "arktype": "^2.2.2",