rolldown-plugin-dts 0.27.8 → 0.27.10
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/README.md +18 -1
- package/dist/{context-CcXGRVeM.d.mts → context-CxNQgl9o.d.mts} +3 -3
- package/dist/{filename-BR9JpwkC.mjs → filename-BrNNypc2.mjs} +4 -4
- package/dist/{index-Pfhuikcq.d.mts → index-DVUThtUr.d.mts} +4 -4
- package/dist/index.d.mts +18 -9
- package/dist/index.mjs +645 -555
- package/dist/internal.d.mts +3 -3
- package/dist/internal.mjs +2 -2
- package/dist/load-tsc-BKULZsrs.mjs +18 -0
- package/dist/{resolver-DtsKFXi2.mjs → resolver-cwLsPb2o.mjs} +2 -3
- package/dist/{tsc-C-tN4xGx.mjs → tsc-KtFHcISk.mjs} +46 -121
- package/dist/tsc-context.d.mts +1 -1
- package/dist/tsc-worker.d.mts +1 -1
- package/dist/tsc-worker.mjs +1 -1
- package/dist/tsc.d.mts +1 -1
- package/dist/tsc.mjs +1 -1
- package/dist/volar-ynbQeQZt.d.mts +20 -0
- package/package.json +14 -11
package/dist/internal.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as VolarContext } from "./volar-ynbQeQZt.mjs";
|
|
1
2
|
import { ChunkFileNamesFunction, PreRenderedChunk } from "rolldown";
|
|
2
3
|
import { readTsconfig } from "get-tsconfig";
|
|
3
4
|
//#region src/filename.d.ts
|
|
@@ -7,13 +8,12 @@ declare const RE_DTS: RegExp;
|
|
|
7
8
|
declare const RE_DTS_MAP: RegExp;
|
|
8
9
|
declare const RE_NODE_MODULES: RegExp;
|
|
9
10
|
declare const RE_CSS: RegExp;
|
|
10
|
-
declare const RE_VUE: RegExp;
|
|
11
11
|
declare const RE_JSON: RegExp;
|
|
12
12
|
declare const RE_ROLLDOWN_RUNTIME: RegExp;
|
|
13
13
|
declare function filename_js_to_dts(id: string): string;
|
|
14
|
-
declare function filename_to_dts(id: string): string;
|
|
14
|
+
declare function filename_to_dts(id: string, volarContext?: VolarContext): string;
|
|
15
15
|
declare function filename_dts_to(id: string, ext: "js" | "ts"): string;
|
|
16
16
|
declare function resolveTemplateFn(fn: string | ChunkFileNamesFunction, chunk: PreRenderedChunk): string;
|
|
17
17
|
declare function replaceTemplateName(template: string, name: string): string;
|
|
18
18
|
//#endregion
|
|
19
|
-
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS,
|
|
19
|
+
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS, filename_dts_to, filename_js_to_dts, filename_to_dts, readTsconfig, replaceTemplateName, resolveTemplateFn };
|
package/dist/internal.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as RE_JSON, c as RE_TS, d as
|
|
1
|
+
import { a as RE_JSON, c as RE_TS, d as filename_to_dts, f as replaceTemplateName, i as RE_JS, l as filename_dts_to, n as RE_DTS, o as RE_NODE_MODULES, p as resolveTemplateFn, r as RE_DTS_MAP, s as RE_ROLLDOWN_RUNTIME, t as RE_CSS, u as filename_js_to_dts } from "./filename-BrNNypc2.mjs";
|
|
2
2
|
import { readTsconfig } from "get-tsconfig";
|
|
3
|
-
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS,
|
|
3
|
+
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS, filename_dts_to, filename_js_to_dts, filename_to_dts, readTsconfig, replaceTemplateName, resolveTemplateFn };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { createDebug } from "obug";
|
|
3
|
+
//#region src/tsc/load-tsc.ts
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const debug = createDebug("rolldown-plugin-dts:load-tsc");
|
|
6
|
+
let _ts;
|
|
7
|
+
function requireTS(message = "") {
|
|
8
|
+
if (_ts) return _ts;
|
|
9
|
+
try {
|
|
10
|
+
_ts = require("typescript");
|
|
11
|
+
if (debug.enabled) debug(`loaded TypeScript version ${_ts.version} from ${require.resolve("typescript")}`);
|
|
12
|
+
return _ts;
|
|
13
|
+
} catch (cause) {
|
|
14
|
+
throw new Error(`TypeScript is not installed. You should install \`typescript\` package. ${message}`, { cause });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { requireTS as t };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
1
|
+
import { t as requireTS } from "./load-tsc-BKULZsrs.mjs";
|
|
3
2
|
import { createDebug } from "obug";
|
|
4
3
|
import path from "node:path";
|
|
5
|
-
const ts = __cjs_require("typescript");
|
|
6
4
|
//#region src/tsc/resolver.ts
|
|
7
5
|
const debug = createDebug("rolldown-plugin-dts:tsc-resolver");
|
|
6
|
+
const ts = requireTS();
|
|
8
7
|
function tscResolve(id, importer, cwd, tsconfig, tsconfigRaw, reference) {
|
|
9
8
|
const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
|
|
10
9
|
const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, ts.sys, baseDir);
|
|
@@ -1,50 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
3
|
-
import { n as RE_DTS, r as RE_DTS_MAP } from "./filename-BR9JpwkC.mjs";
|
|
1
|
+
import { n as RE_DTS, r as RE_DTS_MAP } from "./filename-BrNNypc2.mjs";
|
|
4
2
|
import { globalContext } from "./tsc-context.mjs";
|
|
5
|
-
import {
|
|
3
|
+
import { t as requireTS } from "./load-tsc-BKULZsrs.mjs";
|
|
6
4
|
import { createDebug } from "obug";
|
|
7
5
|
import path from "node:path";
|
|
8
|
-
const ts = __cjs_require("typescript");
|
|
9
6
|
import { pathToFileURL } from "node:url";
|
|
10
|
-
//#region \0rolldown/runtime.js
|
|
11
|
-
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
12
|
-
//#endregion
|
|
13
7
|
//#region src/tsc/system.ts
|
|
14
|
-
const debug$
|
|
8
|
+
const debug$3 = createDebug("rolldown-plugin-dts:tsc-system");
|
|
9
|
+
const ts$3 = requireTS();
|
|
15
10
|
/**
|
|
16
11
|
* A system that writes files to both memory and disk. It will try read files
|
|
17
12
|
* from memory firstly and fallback to disk if not found.
|
|
18
13
|
*/
|
|
19
14
|
function createFsSystem(files) {
|
|
20
15
|
return {
|
|
21
|
-
...ts.sys,
|
|
16
|
+
...ts$3.sys,
|
|
22
17
|
write(message) {
|
|
23
|
-
debug$
|
|
18
|
+
debug$3(message);
|
|
24
19
|
},
|
|
25
20
|
resolvePath(path) {
|
|
26
21
|
if (files.has(path)) return path;
|
|
27
|
-
return ts.sys.resolvePath(path);
|
|
22
|
+
return ts$3.sys.resolvePath(path);
|
|
28
23
|
},
|
|
29
24
|
directoryExists(directory) {
|
|
30
25
|
if (Array.from(files.keys()).some((path) => path.startsWith(directory))) return true;
|
|
31
|
-
return ts.sys.directoryExists(directory);
|
|
26
|
+
return ts$3.sys.directoryExists(directory);
|
|
32
27
|
},
|
|
33
28
|
fileExists(fileName) {
|
|
34
29
|
if (files.has(fileName)) return true;
|
|
35
|
-
return ts.sys.fileExists(fileName);
|
|
30
|
+
return ts$3.sys.fileExists(fileName);
|
|
36
31
|
},
|
|
37
32
|
readFile(fileName, ...args) {
|
|
38
33
|
if (files.has(fileName)) return files.get(fileName);
|
|
39
|
-
return ts.sys.readFile(fileName, ...args);
|
|
34
|
+
return ts$3.sys.readFile(fileName, ...args);
|
|
40
35
|
},
|
|
41
36
|
writeFile(path, data, ...args) {
|
|
42
37
|
files.set(path, data);
|
|
43
|
-
ts.sys.writeFile(path, data, ...args);
|
|
38
|
+
ts$3.sys.writeFile(path, data, ...args);
|
|
44
39
|
},
|
|
45
40
|
deleteFile(fileName, ...args) {
|
|
46
41
|
files.delete(fileName);
|
|
47
|
-
ts.sys.deleteFile?.(fileName, ...args);
|
|
42
|
+
ts$3.sys.deleteFile?.(fileName, ...args);
|
|
48
43
|
}
|
|
49
44
|
};
|
|
50
45
|
}
|
|
@@ -61,10 +56,11 @@ function createMemorySystem(files) {
|
|
|
61
56
|
}
|
|
62
57
|
//#endregion
|
|
63
58
|
//#region src/tsc/utils.ts
|
|
59
|
+
const ts$2 = requireTS();
|
|
64
60
|
const formatHost = {
|
|
65
|
-
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
|
|
66
|
-
getNewLine: () => ts.sys.newLine,
|
|
67
|
-
getCanonicalFileName: ts.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
61
|
+
getCurrentDirectory: () => ts$2.sys.getCurrentDirectory(),
|
|
62
|
+
getNewLine: () => ts$2.sys.newLine,
|
|
63
|
+
getCanonicalFileName: ts$2.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
68
64
|
};
|
|
69
65
|
const stripPrivateFields = (ctx) => {
|
|
70
66
|
const recurseCtx = {
|
|
@@ -75,10 +71,10 @@ const stripPrivateFields = (ctx) => {
|
|
|
75
71
|
endLexicalEnvironment: () => void 0
|
|
76
72
|
};
|
|
77
73
|
const visitor = (node) => {
|
|
78
|
-
if (ts.isPropertySignature(node) && ts.isPrivateIdentifier(node.name)) return ctx.factory.updatePropertySignature(node, node.modifiers, ctx.factory.createStringLiteral(node.name.text), node.questionToken, node.type);
|
|
79
|
-
return ts.visitEachChild(node, visitor, recurseCtx);
|
|
74
|
+
if (ts$2.isPropertySignature(node) && ts$2.isPrivateIdentifier(node.name)) return ctx.factory.updatePropertySignature(node, node.modifiers, ctx.factory.createStringLiteral(node.name.text), node.questionToken, node.type);
|
|
75
|
+
return ts$2.visitEachChild(node, visitor, recurseCtx);
|
|
80
76
|
};
|
|
81
|
-
return (sourceFile) => ts.visitNode(sourceFile, visitor, ts.isSourceFile) ?? sourceFile;
|
|
77
|
+
return (sourceFile) => ts$2.visitNode(sourceFile, visitor, ts$2.isSourceFile) ?? sourceFile;
|
|
82
78
|
};
|
|
83
79
|
const customTransformers = { afterDeclarations: [stripPrivateFields] };
|
|
84
80
|
function setSourceMapRoot(map, originalFilePath, finalFilePath) {
|
|
@@ -90,22 +86,23 @@ function setSourceMapRoot(map, originalFilePath, finalFilePath) {
|
|
|
90
86
|
}
|
|
91
87
|
//#endregion
|
|
92
88
|
//#region src/tsc/emit-build.ts
|
|
93
|
-
const
|
|
89
|
+
const ts$1 = requireTS();
|
|
90
|
+
const debug$2 = createDebug("rolldown-plugin-dts:tsc-build");
|
|
94
91
|
function tscEmitBuild(tscOptions) {
|
|
95
92
|
const { id, tsconfig, incremental, context = globalContext, sourcemap } = tscOptions;
|
|
96
|
-
debug$
|
|
93
|
+
debug$2(`running tscEmitBuild id: ${id}, tsconfig: ${tsconfig}, incremental: ${incremental}`);
|
|
97
94
|
if (!tsconfig) return { error: "[rolldown-plugin-dts] build mode requires a tsconfig path" };
|
|
98
95
|
const fsSystem = (incremental ? createFsSystem : createMemorySystem)(context.files);
|
|
99
96
|
const resolvedId = fsSystem.resolvePath(id);
|
|
100
|
-
if (resolvedId !== id) debug$
|
|
97
|
+
if (resolvedId !== id) debug$2(`resolved id from ${id} to ${resolvedId}`);
|
|
101
98
|
const project = getOrBuildProjects(context, fsSystem, tsconfig, !incremental, sourcemap).get(resolvedId);
|
|
102
99
|
if (!project) {
|
|
103
|
-
debug$
|
|
100
|
+
debug$2(`unable to locate a project containing ${resolvedId}`);
|
|
104
101
|
return { error: `Unable to locate ${id} from the given tsconfig file ${tsconfig}` };
|
|
105
102
|
}
|
|
106
|
-
debug$
|
|
103
|
+
debug$2(`loaded project ${project.tsconfigPath} for ${id}`);
|
|
107
104
|
const ignoreCase = !fsSystem.useCaseSensitiveFileNames;
|
|
108
|
-
const outputFiles = ts.getOutputFileNames(project.parsedConfig, resolvedId, ignoreCase);
|
|
105
|
+
const outputFiles = ts$1.getOutputFileNames(project.parsedConfig, resolvedId, ignoreCase);
|
|
109
106
|
let code;
|
|
110
107
|
let map;
|
|
111
108
|
for (const outputFile of outputFiles) {
|
|
@@ -133,20 +130,20 @@ function tscEmitBuild(tscOptions) {
|
|
|
133
130
|
map
|
|
134
131
|
};
|
|
135
132
|
if (incremental) {
|
|
136
|
-
debug$
|
|
133
|
+
debug$2(`incremental build failed`);
|
|
137
134
|
return tscEmitBuild({
|
|
138
135
|
...tscOptions,
|
|
139
136
|
incremental: false
|
|
140
137
|
});
|
|
141
138
|
}
|
|
142
|
-
debug$
|
|
139
|
+
debug$2(`unable to build .d.ts file for ${id}`);
|
|
143
140
|
if (project.parsedConfig.options.declaration !== true) return { error: `Unable to build .d.ts file for ${id}; Make sure the "declaration" option is set to true in ${project.tsconfigPath}` };
|
|
144
141
|
return { error: `Unable to build .d.ts file for ${id}; This seems like a bug of rolldown-plugin-dts. Please report this issue to https://github.com/sxzz/rolldown-plugin-dts/issues` };
|
|
145
142
|
}
|
|
146
143
|
function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
|
|
147
144
|
let projectMap = context.projects.get(tsconfig);
|
|
148
145
|
if (projectMap) {
|
|
149
|
-
debug$
|
|
146
|
+
debug$2(`skip building projects for ${tsconfig}`);
|
|
150
147
|
return projectMap;
|
|
151
148
|
}
|
|
152
149
|
projectMap = buildProjects(fsSystem, tsconfig, force, sourcemap);
|
|
@@ -157,18 +154,18 @@ function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
|
|
|
157
154
|
* Use TypeScript compiler to build all projects referenced
|
|
158
155
|
*/
|
|
159
156
|
function buildProjects(fsSystem, tsconfig, force, sourcemap) {
|
|
160
|
-
debug$
|
|
157
|
+
debug$2(`start building projects for ${tsconfig}`);
|
|
161
158
|
const projects = collectProjectGraph(tsconfig, fsSystem, force, sourcemap);
|
|
162
|
-
debug$
|
|
163
|
-
const host = ts.createSolutionBuilderHost(fsSystem, createProgramWithPatchedCompilerOptions);
|
|
164
|
-
const exitStatus = ts.createSolutionBuilder(host, [tsconfig], {
|
|
159
|
+
debug$2("collected %d projects: %j", projects.length, projects.map((project) => project.tsconfigPath));
|
|
160
|
+
const host = ts$1.createSolutionBuilderHost(fsSystem, createProgramWithPatchedCompilerOptions);
|
|
161
|
+
const exitStatus = ts$1.createSolutionBuilder(host, [tsconfig], {
|
|
165
162
|
force,
|
|
166
163
|
verbose: true
|
|
167
164
|
}).build(void 0, void 0, void 0, (project) => {
|
|
168
|
-
debug$
|
|
165
|
+
debug$2(`transforming project ${project}`);
|
|
169
166
|
return customTransformers;
|
|
170
167
|
});
|
|
171
|
-
debug$
|
|
168
|
+
debug$2(`built solution for ${tsconfig} with exit status ${exitStatus}`);
|
|
172
169
|
const sourceFileToProjectMap = /* @__PURE__ */ new Map();
|
|
173
170
|
for (const project of projects) for (const fileName of project.parsedConfig.fileNames) sourceFileToProjectMap.set(fsSystem.resolvePath(fileName), project);
|
|
174
171
|
return sourceFileToProjectMap;
|
|
@@ -196,19 +193,19 @@ function collectProjectGraph(rootTsconfigPath, fsSystem, force, sourcemap) {
|
|
|
196
193
|
tsconfigPath,
|
|
197
194
|
parsedConfig
|
|
198
195
|
});
|
|
199
|
-
for (const ref of parsedConfig.projectReferences ?? []) stack.push(ts.resolveProjectReferencePath(ref));
|
|
196
|
+
for (const ref of parsedConfig.projectReferences ?? []) stack.push(ts$1.resolveProjectReferencePath(ref));
|
|
200
197
|
}
|
|
201
198
|
return projects;
|
|
202
199
|
}
|
|
203
200
|
function parseTsconfig(tsconfigPath, fsSystem) {
|
|
204
201
|
const diagnostics = [];
|
|
205
|
-
const parsedConfig = ts.getParsedCommandLineOfConfigFile(tsconfigPath, void 0, {
|
|
202
|
+
const parsedConfig = ts$1.getParsedCommandLineOfConfigFile(tsconfigPath, void 0, {
|
|
206
203
|
...fsSystem,
|
|
207
204
|
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
|
|
208
205
|
diagnostics.push(diagnostic);
|
|
209
206
|
}
|
|
210
207
|
});
|
|
211
|
-
if (diagnostics.length) throw new Error(`[rolldown-plugin-dts] Unable to read ${tsconfigPath}: ${ts.formatDiagnostics(diagnostics, formatHost)}`);
|
|
208
|
+
if (diagnostics.length) throw new Error(`[rolldown-plugin-dts] Unable to read ${tsconfigPath}: ${ts$1.formatDiagnostics(diagnostics, formatHost)}`);
|
|
212
209
|
return parsedConfig;
|
|
213
210
|
}
|
|
214
211
|
function patchCompilerOptions(options, extraOptions) {
|
|
@@ -240,75 +237,12 @@ function patchCompilerOptions(options, extraOptions) {
|
|
|
240
237
|
return options;
|
|
241
238
|
}
|
|
242
239
|
const createProgramWithPatchedCompilerOptions = (rootNames, options, ...args) => {
|
|
243
|
-
return ts.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, patchCompilerOptions(options ?? {}, null), ...args);
|
|
240
|
+
return ts$1.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, patchCompilerOptions(options ?? {}, null), ...args);
|
|
244
241
|
};
|
|
245
242
|
//#endregion
|
|
246
|
-
//#region src/tsc/volar.ts
|
|
247
|
-
const debug$2 = createDebug("rolldown-plugin-dts:volar");
|
|
248
|
-
function loadVueLanguageTools() {
|
|
249
|
-
debug$2("loading vue language tools");
|
|
250
|
-
try {
|
|
251
|
-
const vueTscPath = __require.resolve("vue-tsc");
|
|
252
|
-
return {
|
|
253
|
-
volarTs: __require(__require.resolve("@volar/typescript", { paths: [vueTscPath] })),
|
|
254
|
-
vue: __require(__require.resolve("@vue/language-core", { paths: [vueTscPath] }))
|
|
255
|
-
};
|
|
256
|
-
} catch (error) {
|
|
257
|
-
debug$2("vue language tools not found", error);
|
|
258
|
-
throw new Error("Failed to load vue language tools. Please manually install vue-tsc.", { cause: error });
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
function initVueLanguageTools() {
|
|
262
|
-
const { vue, volarTs: { proxyCreateProgram } } = loadVueLanguageTools();
|
|
263
|
-
const getLanguagePlugin = (ts, options) => {
|
|
264
|
-
const $rootDir = options.options.$rootDir;
|
|
265
|
-
const $configRaw = options.options.$configRaw;
|
|
266
|
-
const resolver = new vue.CompilerOptionsResolver(ts, ts.sys.readFile);
|
|
267
|
-
resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
|
|
268
|
-
const vueOptions = resolver.build();
|
|
269
|
-
return vue.createVueLanguagePlugin(ts, options.options, vueOptions, (id) => id);
|
|
270
|
-
};
|
|
271
|
-
return {
|
|
272
|
-
proxyCreateProgram,
|
|
273
|
-
getLanguagePlugin
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function initTsMacro() {
|
|
277
|
-
const debug = createDebug("rolldown-plugin-dts:ts-macro");
|
|
278
|
-
debug("loading ts-macro language tools");
|
|
279
|
-
try {
|
|
280
|
-
const tsMacroPath = __require.resolve("@ts-macro/tsc");
|
|
281
|
-
const { proxyCreateProgram } = __require(__require.resolve("@volar/typescript", { paths: [tsMacroPath] }));
|
|
282
|
-
const tsMacro = __require(__require.resolve("@ts-macro/language-plugin", { paths: [tsMacroPath] }));
|
|
283
|
-
const { getOptions } = __require(__require.resolve("@ts-macro/language-plugin/options", { paths: [tsMacroPath] }));
|
|
284
|
-
const getLanguagePlugin = (ts, options) => {
|
|
285
|
-
const $rootDir = options.options.$rootDir;
|
|
286
|
-
return tsMacro.getLanguagePlugins(ts, options.options, getOptions(ts, $rootDir))[0];
|
|
287
|
-
};
|
|
288
|
-
return {
|
|
289
|
-
proxyCreateProgram,
|
|
290
|
-
getLanguagePlugin
|
|
291
|
-
};
|
|
292
|
-
} catch (error) {
|
|
293
|
-
debug("ts-macro language tools not found", error);
|
|
294
|
-
throw new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.", { cause: error });
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
function createProgramFactory(ts, options) {
|
|
298
|
-
const vueLanguageTools = options.vue ? initVueLanguageTools() : void 0;
|
|
299
|
-
const tsMacroLanguageTools = options.tsMacro ? initTsMacro() : void 0;
|
|
300
|
-
const proxyCreateProgram = vueLanguageTools?.proxyCreateProgram || tsMacroLanguageTools?.proxyCreateProgram;
|
|
301
|
-
if (!proxyCreateProgram) return ts.createProgram;
|
|
302
|
-
return proxyCreateProgram(ts, ts.createProgram, (ts, options) => {
|
|
303
|
-
const languagePlugins = [];
|
|
304
|
-
if (vueLanguageTools) languagePlugins.push(vueLanguageTools.getLanguagePlugin(ts, options));
|
|
305
|
-
if (tsMacroLanguageTools) languagePlugins.push(tsMacroLanguageTools.getLanguagePlugin(ts, options));
|
|
306
|
-
return { languagePlugins };
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
//#endregion
|
|
310
243
|
//#region src/tsc/emit-compiler.ts
|
|
311
244
|
const debug$1 = createDebug("rolldown-plugin-dts:tsc-compiler");
|
|
245
|
+
const ts = requireTS();
|
|
312
246
|
const defaultCompilerOptions = {
|
|
313
247
|
declaration: true,
|
|
314
248
|
noEmit: false,
|
|
@@ -341,14 +275,10 @@ function createOrGetTsModule(options) {
|
|
|
341
275
|
context.programs.push(module.program);
|
|
342
276
|
return module;
|
|
343
277
|
}
|
|
344
|
-
function createTsProgram({ entries, id, tsconfig, tsconfigRaw,
|
|
278
|
+
function createTsProgram({ entries, id, tsconfig, tsconfigRaw, volarContext, cwd, context = globalContext }) {
|
|
345
279
|
const fsSystem = createFsSystem(context.files);
|
|
346
280
|
const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
|
|
347
|
-
const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir, void 0, void 0, void 0,
|
|
348
|
-
extension: "vue",
|
|
349
|
-
isMixedContent: true,
|
|
350
|
-
scriptKind: ts.ScriptKind.Deferred
|
|
351
|
-
}] : void 0);
|
|
281
|
+
const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir, void 0, void 0, void 0, volarContext.getExtraFileExtensions());
|
|
352
282
|
debug$1(`creating program for root project: ${baseDir}`);
|
|
353
283
|
return createTsProgramFromParsedConfig({
|
|
354
284
|
parsedConfig,
|
|
@@ -356,24 +286,20 @@ function createTsProgram({ entries, id, tsconfig, tsconfigRaw, vue, tsMacro, cwd
|
|
|
356
286
|
baseDir,
|
|
357
287
|
id,
|
|
358
288
|
entries,
|
|
359
|
-
|
|
360
|
-
tsMacro
|
|
289
|
+
volarContext
|
|
361
290
|
});
|
|
362
291
|
}
|
|
363
|
-
function createTsProgramFromParsedConfig({ parsedConfig, fsSystem, baseDir, id, entries,
|
|
292
|
+
function createTsProgramFromParsedConfig({ parsedConfig, fsSystem, baseDir, id, entries, volarContext }) {
|
|
364
293
|
const compilerOptions = {
|
|
365
294
|
...defaultCompilerOptions,
|
|
366
295
|
...parsedConfig.options,
|
|
367
296
|
$configRaw: parsedConfig.raw,
|
|
368
297
|
$rootDir: baseDir,
|
|
369
|
-
...
|
|
298
|
+
...volarContext.plugins.length ? { allowNonTsExtensions: true } : void 0
|
|
370
299
|
};
|
|
371
300
|
const rootNames = [...new Set([id, ...entries || parsedConfig.fileNames].map((f) => fsSystem.resolvePath(f)))];
|
|
372
301
|
const host = ts.createCompilerHost(compilerOptions, true);
|
|
373
|
-
const program =
|
|
374
|
-
vue,
|
|
375
|
-
tsMacro
|
|
376
|
-
})({
|
|
302
|
+
const program = volarContext.getCreateProgram(ts)({
|
|
377
303
|
rootNames,
|
|
378
304
|
options: compilerOptions,
|
|
379
305
|
host,
|
|
@@ -428,7 +354,6 @@ function tscEmitCompiler(tscOptions) {
|
|
|
428
354
|
//#endregion
|
|
429
355
|
//#region src/tsc/index.ts
|
|
430
356
|
const debug = createDebug("rolldown-plugin-dts:tsc");
|
|
431
|
-
debug(`loaded typescript: ${ts.version}`);
|
|
432
357
|
function tscEmit(tscOptions) {
|
|
433
358
|
debug(`running tscEmit ${tscOptions.id}`);
|
|
434
359
|
if (tscOptions.build) return tscEmitBuild(tscOptions);
|
package/dist/tsc-context.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as globalContext, i as createContext, n as SourceFileToProjectMap, o as invalidateContextFile, r as TscContext, t as ParsedProject } from "./context-
|
|
1
|
+
import { a as globalContext, i as createContext, n as SourceFileToProjectMap, o as invalidateContextFile, r as TscContext, t as ParsedProject } from "./context-CxNQgl9o.mjs";
|
|
2
2
|
export { ParsedProject, SourceFileToProjectMap, TscContext, createContext, globalContext, invalidateContextFile };
|
package/dist/tsc-worker.d.mts
CHANGED
package/dist/tsc-worker.mjs
CHANGED
package/dist/tsc.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-
|
|
1
|
+
import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-DVUThtUr.mjs";
|
|
2
2
|
export { type TscModule, type TscOptions, type TscResult, tscEmit };
|
package/dist/tsc.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as tscEmit } from "./tsc-
|
|
1
|
+
import { t as tscEmit } from "./tsc-KtFHcISk.mjs";
|
|
2
2
|
export { tscEmit };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FileExtensionInfo } from "typescript";
|
|
2
|
+
//#region src/volar.d.ts
|
|
3
|
+
interface VolarPlugin {
|
|
4
|
+
extensionPatterns: RegExp[];
|
|
5
|
+
tsFileExtensionInfos: FileExtensionInfo[];
|
|
6
|
+
volarTypeScript: typeof import("@volar/typescript");
|
|
7
|
+
create: Parameters<(typeof import("@volar/typescript"))["proxyCreateProgram"]>[2];
|
|
8
|
+
toTsFilename?: (id: string) => string;
|
|
9
|
+
}
|
|
10
|
+
declare class VolarContext {
|
|
11
|
+
plugins: VolarPlugin[];
|
|
12
|
+
patterns: RegExp[];
|
|
13
|
+
constructor(plugins: VolarPlugin[]);
|
|
14
|
+
isVolarFile(id: string): boolean;
|
|
15
|
+
getExtraFileExtensions(): FileExtensionInfo[] | undefined;
|
|
16
|
+
getCreateProgram(ts: typeof import("typescript")): typeof import("typescript").createProgram;
|
|
17
|
+
toTsFilename(id: string): string;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { VolarPlugin as n, VolarContext as t };
|
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.10",
|
|
5
5
|
"description": "A Rolldown plugin to generate and bundle dts files.",
|
|
6
6
|
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
"node": "^22.18.0 || >=24.11.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@typescript
|
|
44
|
+
"@typescript/native-preview": "*",
|
|
45
|
+
"@volar/typescript": "~2.4.0",
|
|
46
46
|
"rolldown": "^1.0.0",
|
|
47
|
-
"typescript": "^5.0.0 || ^6.0.0 ||
|
|
47
|
+
"typescript": "^5.0.0 || ^6.0.0 || ~7.0.0",
|
|
48
48
|
"vue-tsc": "~3.2.0 || ~3.3.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
|
-
"@
|
|
51
|
+
"@typescript/native-preview": {
|
|
52
52
|
"optional": true
|
|
53
53
|
},
|
|
54
|
-
"@typescript
|
|
54
|
+
"@volar/typescript": {
|
|
55
55
|
"optional": true
|
|
56
56
|
},
|
|
57
57
|
"typescript": {
|
|
@@ -62,18 +62,21 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
+
"@astrojs/ts-plugin": "^1.10.10",
|
|
65
66
|
"dts-resolver": "^3.0.0",
|
|
66
67
|
"get-tsconfig": "5.0.0-beta.5",
|
|
67
68
|
"obug": "^2.1.3",
|
|
68
69
|
"yuku-ast": "^0.1.7",
|
|
69
|
-
"yuku-codegen": "^0.6.
|
|
70
|
-
"yuku-parser": "^0.6.
|
|
70
|
+
"yuku-codegen": "^0.6.3",
|
|
71
|
+
"yuku-parser": "^0.6.3"
|
|
71
72
|
},
|
|
72
73
|
"devDependencies": {
|
|
73
74
|
"@jridgewell/source-map": "^0.3.11",
|
|
74
75
|
"@sxzz/eslint-config": "^8.2.1",
|
|
75
76
|
"@sxzz/prettier-config": "^2.3.1",
|
|
76
77
|
"@sxzz/test-utils": "^0.5.18",
|
|
78
|
+
"@ts-macro/language-plugin": "^0.3.7",
|
|
79
|
+
"@ts-macro/tsc": "^0.3.7",
|
|
77
80
|
"@types/node": "^26.1.1",
|
|
78
81
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
79
82
|
"@volar/typescript": "^2.4.28",
|
|
@@ -83,10 +86,10 @@
|
|
|
83
86
|
"diff": "^9.0.0",
|
|
84
87
|
"eslint": "^10.7.0",
|
|
85
88
|
"prettier": "^3.9.5",
|
|
86
|
-
"rolldown": "^1.
|
|
87
|
-
"rolldown-plugin-require-cjs": "^0.4.1",
|
|
89
|
+
"rolldown": "^1.2.0",
|
|
88
90
|
"rollup-plugin-dts": "^6.4.1",
|
|
89
|
-
"
|
|
91
|
+
"ts-macro": "^0.3.7",
|
|
92
|
+
"tsdown": "^0.22.8",
|
|
90
93
|
"tsnapi": "^1.0.0",
|
|
91
94
|
"typescript": "^6.0.3",
|
|
92
95
|
"vitest": "^4.1.10",
|