rolldown-plugin-dts 0.25.2 → 0.26.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 +30 -14
- package/package.json +21 -21
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { parse } from "@babel/parser";
|
|
|
8
8
|
import { isDeclarationType, isIdentifierOf, isTypeOf, resolveString, walkAST, walkASTAsync } from "ast-kit";
|
|
9
9
|
import { fork, spawn } from "node:child_process";
|
|
10
10
|
import { existsSync } from "node:fs";
|
|
11
|
-
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
11
|
+
import { access, mkdtemp, readFile, rm } from "node:fs/promises";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
import { ResolverFactory, isolatedDeclarationSync } from "rolldown/experimental";
|
|
14
14
|
import { tmpdir } from "node:os";
|
|
@@ -930,7 +930,19 @@ async function runTsgo(rootDir, tsconfig, sourcemap, tsgoPath) {
|
|
|
930
930
|
];
|
|
931
931
|
debug$3("[tsgo] args %o", args);
|
|
932
932
|
await spawnAsync(tsgo, args, { stdio: "inherit" });
|
|
933
|
-
return
|
|
933
|
+
return {
|
|
934
|
+
path: tsgoDist,
|
|
935
|
+
async dispose() {
|
|
936
|
+
if (debug$3.enabled) debug$3("[tsgo] skip cleanup of tsgoDist", tsgoDist);
|
|
937
|
+
else {
|
|
938
|
+
debug$3("[tsgo] disposing tsgoDist", tsgoDist);
|
|
939
|
+
await rm(tsgoDist, {
|
|
940
|
+
recursive: true,
|
|
941
|
+
force: true
|
|
942
|
+
}).catch(() => {});
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
};
|
|
934
946
|
}
|
|
935
947
|
//#endregion
|
|
936
948
|
//#region src/generate.ts
|
|
@@ -955,12 +967,12 @@ function createGeneratePlugin({ entry, tsconfig, tsconfigRaw, build, incremental
|
|
|
955
967
|
let rpc;
|
|
956
968
|
let tscModule;
|
|
957
969
|
let tscContext;
|
|
958
|
-
let
|
|
970
|
+
let tsgoContext;
|
|
959
971
|
const rootDir = tsconfig ? path.dirname(tsconfig) : cwd;
|
|
960
972
|
return {
|
|
961
973
|
name: "rolldown-plugin-dts:generate",
|
|
962
974
|
async buildStart(options) {
|
|
963
|
-
if (tsgo)
|
|
975
|
+
if (tsgo) tsgoContext = await runTsgo(rootDir, tsconfig, sourcemap, tsgo.path);
|
|
964
976
|
else if (!oxc) if (parallel) {
|
|
965
977
|
childProcess = fork(new URL(WORKER_URL, import.meta.url), { stdio: "inherit" });
|
|
966
978
|
rpc = (await import("birpc")).createBirpc({}, {
|
|
@@ -1016,14 +1028,16 @@ function createGeneratePlugin({ entry, tsconfig, tsconfigRaw, build, incremental
|
|
|
1016
1028
|
]
|
|
1017
1029
|
} },
|
|
1018
1030
|
handler(code, id) {
|
|
1019
|
-
|
|
1031
|
+
const jsFile = RE_JS.test(id);
|
|
1032
|
+
if (!jsFile || emitJs) {
|
|
1020
1033
|
const mod = this.getModuleInfo(id);
|
|
1021
1034
|
const isEntry = entryMatcher ? entryMatcher(path.relative(cwd, id)) : !!mod?.isEntry;
|
|
1022
1035
|
const dtsId = filename_to_dts(id);
|
|
1023
1036
|
dtsMap.set(dtsId, {
|
|
1024
1037
|
code,
|
|
1025
1038
|
id,
|
|
1026
|
-
isEntry
|
|
1039
|
+
isEntry,
|
|
1040
|
+
jsFile
|
|
1027
1041
|
});
|
|
1028
1042
|
debug$2("register dts source: %s", id);
|
|
1029
1043
|
if (isEntry) {
|
|
@@ -1047,14 +1061,19 @@ function createGeneratePlugin({ entry, tsconfig, tsconfigRaw, build, incremental
|
|
|
1047
1061
|
exclude: [RE_NODE_MODULES]
|
|
1048
1062
|
} },
|
|
1049
1063
|
async handler(dtsId) {
|
|
1050
|
-
|
|
1051
|
-
|
|
1064
|
+
const module = dtsMap.get(dtsId);
|
|
1065
|
+
if (!module) return;
|
|
1066
|
+
const { code, id, jsFile } = module;
|
|
1067
|
+
if (jsFile && await access(dtsId).then(() => true).catch(() => false)) {
|
|
1068
|
+
debug$2("dts file already exists for %s, skipping generation", id);
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1052
1071
|
let dtsCode;
|
|
1053
1072
|
let map;
|
|
1054
1073
|
debug$2("generate dts %s from %s", dtsId, id);
|
|
1055
1074
|
if (tsgo) {
|
|
1056
1075
|
if (RE_VUE.test(id)) throw new Error("tsgo does not support Vue files.");
|
|
1057
|
-
const dtsPath = path.resolve(
|
|
1076
|
+
const dtsPath = path.resolve(tsgoContext.path, path.relative(path.resolve(rootDir), filename_to_dts(id)));
|
|
1058
1077
|
if (!existsSync(dtsPath)) {
|
|
1059
1078
|
debug$2("[tsgo]", dtsPath, "is missing");
|
|
1060
1079
|
throw new Error(`tsgo did not generate dts file for ${id}, please check your tsconfig.`);
|
|
@@ -1132,11 +1151,8 @@ export { __json_default_export as default }`;
|
|
|
1132
1151
|
} : void 0,
|
|
1133
1152
|
async buildEnd() {
|
|
1134
1153
|
childProcess?.kill();
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
force: true
|
|
1138
|
-
}).catch(() => {});
|
|
1139
|
-
tsgoDist = void 0;
|
|
1154
|
+
await tsgoContext?.dispose();
|
|
1155
|
+
tsgoContext = void 0;
|
|
1140
1156
|
if (newContext) tscContext = void 0;
|
|
1141
1157
|
},
|
|
1142
1158
|
watchChange(id) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-plugin-dts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.26.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",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
|
-
"node": "^22.18.0 || >=24.
|
|
41
|
+
"node": "^22.18.0 || >=24.11.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@ts-macro/tsc": "^0.3.6",
|
|
45
45
|
"@typescript/native-preview": ">=7.0.0-dev.20260325.1",
|
|
46
46
|
"rolldown": "^1.0.0",
|
|
47
47
|
"typescript": "^5.0.0 || ^6.0.0",
|
|
48
|
-
"vue-tsc": "~3.2.0"
|
|
48
|
+
"vue-tsc": "~3.2.0 || ~3.3.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"@ts-macro/tsc": {
|
|
@@ -62,39 +62,39 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@babel/generator": "8.0.0
|
|
66
|
-
"@babel/helper-validator-identifier": "8.0.0
|
|
67
|
-
"@babel/parser": "8.0.0
|
|
68
|
-
"ast-kit": "^3.0.0
|
|
65
|
+
"@babel/generator": "^8.0.0",
|
|
66
|
+
"@babel/helper-validator-identifier": "^8.0.0",
|
|
67
|
+
"@babel/parser": "^8.0.0",
|
|
68
|
+
"ast-kit": "^3.0.0",
|
|
69
69
|
"birpc": "^4.0.0",
|
|
70
70
|
"dts-resolver": "^3.0.0",
|
|
71
71
|
"get-tsconfig": "5.0.0-beta.5",
|
|
72
|
-
"obug": "^2.1.
|
|
72
|
+
"obug": "^2.1.3"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@babel/types": "^8.0.0
|
|
75
|
+
"@babel/types": "^8.0.0",
|
|
76
76
|
"@jridgewell/source-map": "^0.3.11",
|
|
77
|
-
"@sxzz/eslint-config": "^8.
|
|
77
|
+
"@sxzz/eslint-config": "^8.2.0",
|
|
78
78
|
"@sxzz/prettier-config": "^2.3.1",
|
|
79
79
|
"@sxzz/test-utils": "^0.5.18",
|
|
80
|
-
"@types/node": "^25.9.
|
|
81
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
80
|
+
"@types/node": "^25.9.3",
|
|
81
|
+
"@typescript/native-preview": "7.0.0-dev.20260616.1",
|
|
82
82
|
"@volar/typescript": "^2.4.28",
|
|
83
|
-
"@vue/language-core": "^3.3.
|
|
83
|
+
"@vue/language-core": "^3.3.5",
|
|
84
84
|
"arktype": "^2.2.0",
|
|
85
85
|
"bumpp": "^11.1.0",
|
|
86
86
|
"diff": "^9.0.0",
|
|
87
|
-
"eslint": "^10.
|
|
88
|
-
"prettier": "^3.8.
|
|
89
|
-
"rolldown": "^1.
|
|
90
|
-
"rolldown-plugin-require-cjs": "^0.4.
|
|
87
|
+
"eslint": "^10.5.0",
|
|
88
|
+
"prettier": "^3.8.4",
|
|
89
|
+
"rolldown": "^1.1.1",
|
|
90
|
+
"rolldown-plugin-require-cjs": "^0.4.1",
|
|
91
91
|
"rollup-plugin-dts": "^6.4.1",
|
|
92
|
-
"tsdown": "^0.22.
|
|
92
|
+
"tsdown": "^0.22.2",
|
|
93
93
|
"tsnapi": "^0.3.3",
|
|
94
94
|
"typescript": "^6.0.3",
|
|
95
|
-
"vitest": "^4.1.
|
|
96
|
-
"vue": "^3.5.
|
|
97
|
-
"vue-tsc": "^3.3.
|
|
95
|
+
"vitest": "^4.1.9",
|
|
96
|
+
"vue": "^3.5.38",
|
|
97
|
+
"vue-tsc": "^3.3.5",
|
|
98
98
|
"zod": "^4.4.3"
|
|
99
99
|
},
|
|
100
100
|
"prettier": "@sxzz/prettier-config",
|