rolldown-plugin-dts 0.27.0-beta.1 → 0.27.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.
- package/dist/index.mjs +40 -12
- package/dist/tsc-worker.d.mts +11 -6
- package/dist/tsc-worker.mjs +14 -4
- package/package.json +6 -7
package/dist/index.mjs
CHANGED
|
@@ -646,7 +646,7 @@ function isReferenceId(node) {
|
|
|
646
646
|
return is.oneOf(node, ["Identifier", "MemberExpression"]);
|
|
647
647
|
}
|
|
648
648
|
function isHelperImport(node) {
|
|
649
|
-
return node.type === "ImportDeclaration" && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.imported.type === "Identifier" && ["__exportAll", "__reExport"].includes(spec.local.name));
|
|
649
|
+
return node.type === "ImportDeclaration" && node.specifiers.length && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.imported.type === "Identifier" && ["__exportAll", "__reExport"].includes(spec.local.name));
|
|
650
650
|
}
|
|
651
651
|
/**
|
|
652
652
|
* patch `.d.ts` suffix in import source to `.js`
|
|
@@ -836,8 +836,7 @@ function createGeneratePlugin({ entry, tsconfig, tsconfigRaw, build, incremental
|
|
|
836
836
|
* ])
|
|
837
837
|
*/
|
|
838
838
|
const inputAliasMap = /* @__PURE__ */ new Map();
|
|
839
|
-
let
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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, {
|
package/dist/tsc-worker.d.mts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as TscResult, r as TscOptions } from "./index-Pfhuikcq.mjs";
|
|
2
2
|
//#region src/tsc/worker.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
13
|
+
export { WorkerRequest, WorkerResponse };
|
package/dist/tsc-worker.mjs
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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.
|
|
4
|
+
"version": "0.27.1",
|
|
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,13 +62,12 @@
|
|
|
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",
|
|
69
|
-
"yuku-ast": "^0.1.
|
|
70
|
-
"yuku-codegen": "^0.5.
|
|
71
|
-
"yuku-parser": "^0.5.
|
|
68
|
+
"yuku-ast": "^0.1.7",
|
|
69
|
+
"yuku-codegen": "^0.5.44",
|
|
70
|
+
"yuku-parser": "^0.5.44"
|
|
72
71
|
},
|
|
73
72
|
"devDependencies": {
|
|
74
73
|
"@jridgewell/source-map": "^0.3.11",
|
|
@@ -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.
|
|
78
|
+
"@typescript/native-preview": "7.0.0-dev.20260706.1",
|
|
80
79
|
"@volar/typescript": "^2.4.28",
|
|
81
80
|
"@vue/language-core": "^3.3.6",
|
|
82
81
|
"arktype": "^2.2.2",
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
"tsdown": "^0.22.3",
|
|
91
90
|
"tsnapi": "^1.0.0",
|
|
92
91
|
"typescript": "^6.0.3",
|
|
93
|
-
"vitest": "^4.1.
|
|
92
|
+
"vitest": "^4.1.10",
|
|
94
93
|
"vue": "^3.5.39",
|
|
95
94
|
"vue-tsc": "^3.3.6",
|
|
96
95
|
"zod": "^4.4.3"
|