rolldown-plugin-dts 0.27.9 → 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 +673 -591
- 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-BVghLPtc.mjs → tsc-KtFHcISk.mjs} +46 -118
- 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 +12 -9
- package/dist/rolldown-runtime-CMgrfpPY.mjs +0 -5
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,47 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
3
|
-
import { t as __require } from "./rolldown-runtime-CMgrfpPY.mjs";
|
|
4
|
-
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";
|
|
5
2
|
import { globalContext } from "./tsc-context.mjs";
|
|
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
7
|
//#region src/tsc/system.ts
|
|
11
|
-
const debug$
|
|
8
|
+
const debug$3 = createDebug("rolldown-plugin-dts:tsc-system");
|
|
9
|
+
const ts$3 = requireTS();
|
|
12
10
|
/**
|
|
13
11
|
* A system that writes files to both memory and disk. It will try read files
|
|
14
12
|
* from memory firstly and fallback to disk if not found.
|
|
15
13
|
*/
|
|
16
14
|
function createFsSystem(files) {
|
|
17
15
|
return {
|
|
18
|
-
...ts.sys,
|
|
16
|
+
...ts$3.sys,
|
|
19
17
|
write(message) {
|
|
20
|
-
debug$
|
|
18
|
+
debug$3(message);
|
|
21
19
|
},
|
|
22
20
|
resolvePath(path) {
|
|
23
21
|
if (files.has(path)) return path;
|
|
24
|
-
return ts.sys.resolvePath(path);
|
|
22
|
+
return ts$3.sys.resolvePath(path);
|
|
25
23
|
},
|
|
26
24
|
directoryExists(directory) {
|
|
27
25
|
if (Array.from(files.keys()).some((path) => path.startsWith(directory))) return true;
|
|
28
|
-
return ts.sys.directoryExists(directory);
|
|
26
|
+
return ts$3.sys.directoryExists(directory);
|
|
29
27
|
},
|
|
30
28
|
fileExists(fileName) {
|
|
31
29
|
if (files.has(fileName)) return true;
|
|
32
|
-
return ts.sys.fileExists(fileName);
|
|
30
|
+
return ts$3.sys.fileExists(fileName);
|
|
33
31
|
},
|
|
34
32
|
readFile(fileName, ...args) {
|
|
35
33
|
if (files.has(fileName)) return files.get(fileName);
|
|
36
|
-
return ts.sys.readFile(fileName, ...args);
|
|
34
|
+
return ts$3.sys.readFile(fileName, ...args);
|
|
37
35
|
},
|
|
38
36
|
writeFile(path, data, ...args) {
|
|
39
37
|
files.set(path, data);
|
|
40
|
-
ts.sys.writeFile(path, data, ...args);
|
|
38
|
+
ts$3.sys.writeFile(path, data, ...args);
|
|
41
39
|
},
|
|
42
40
|
deleteFile(fileName, ...args) {
|
|
43
41
|
files.delete(fileName);
|
|
44
|
-
ts.sys.deleteFile?.(fileName, ...args);
|
|
42
|
+
ts$3.sys.deleteFile?.(fileName, ...args);
|
|
45
43
|
}
|
|
46
44
|
};
|
|
47
45
|
}
|
|
@@ -58,10 +56,11 @@ function createMemorySystem(files) {
|
|
|
58
56
|
}
|
|
59
57
|
//#endregion
|
|
60
58
|
//#region src/tsc/utils.ts
|
|
59
|
+
const ts$2 = requireTS();
|
|
61
60
|
const formatHost = {
|
|
62
|
-
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
|
|
63
|
-
getNewLine: () => ts.sys.newLine,
|
|
64
|
-
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()
|
|
65
64
|
};
|
|
66
65
|
const stripPrivateFields = (ctx) => {
|
|
67
66
|
const recurseCtx = {
|
|
@@ -72,10 +71,10 @@ const stripPrivateFields = (ctx) => {
|
|
|
72
71
|
endLexicalEnvironment: () => void 0
|
|
73
72
|
};
|
|
74
73
|
const visitor = (node) => {
|
|
75
|
-
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);
|
|
76
|
-
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);
|
|
77
76
|
};
|
|
78
|
-
return (sourceFile) => ts.visitNode(sourceFile, visitor, ts.isSourceFile) ?? sourceFile;
|
|
77
|
+
return (sourceFile) => ts$2.visitNode(sourceFile, visitor, ts$2.isSourceFile) ?? sourceFile;
|
|
79
78
|
};
|
|
80
79
|
const customTransformers = { afterDeclarations: [stripPrivateFields] };
|
|
81
80
|
function setSourceMapRoot(map, originalFilePath, finalFilePath) {
|
|
@@ -87,22 +86,23 @@ function setSourceMapRoot(map, originalFilePath, finalFilePath) {
|
|
|
87
86
|
}
|
|
88
87
|
//#endregion
|
|
89
88
|
//#region src/tsc/emit-build.ts
|
|
90
|
-
const
|
|
89
|
+
const ts$1 = requireTS();
|
|
90
|
+
const debug$2 = createDebug("rolldown-plugin-dts:tsc-build");
|
|
91
91
|
function tscEmitBuild(tscOptions) {
|
|
92
92
|
const { id, tsconfig, incremental, context = globalContext, sourcemap } = tscOptions;
|
|
93
|
-
debug$
|
|
93
|
+
debug$2(`running tscEmitBuild id: ${id}, tsconfig: ${tsconfig}, incremental: ${incremental}`);
|
|
94
94
|
if (!tsconfig) return { error: "[rolldown-plugin-dts] build mode requires a tsconfig path" };
|
|
95
95
|
const fsSystem = (incremental ? createFsSystem : createMemorySystem)(context.files);
|
|
96
96
|
const resolvedId = fsSystem.resolvePath(id);
|
|
97
|
-
if (resolvedId !== id) debug$
|
|
97
|
+
if (resolvedId !== id) debug$2(`resolved id from ${id} to ${resolvedId}`);
|
|
98
98
|
const project = getOrBuildProjects(context, fsSystem, tsconfig, !incremental, sourcemap).get(resolvedId);
|
|
99
99
|
if (!project) {
|
|
100
|
-
debug$
|
|
100
|
+
debug$2(`unable to locate a project containing ${resolvedId}`);
|
|
101
101
|
return { error: `Unable to locate ${id} from the given tsconfig file ${tsconfig}` };
|
|
102
102
|
}
|
|
103
|
-
debug$
|
|
103
|
+
debug$2(`loaded project ${project.tsconfigPath} for ${id}`);
|
|
104
104
|
const ignoreCase = !fsSystem.useCaseSensitiveFileNames;
|
|
105
|
-
const outputFiles = ts.getOutputFileNames(project.parsedConfig, resolvedId, ignoreCase);
|
|
105
|
+
const outputFiles = ts$1.getOutputFileNames(project.parsedConfig, resolvedId, ignoreCase);
|
|
106
106
|
let code;
|
|
107
107
|
let map;
|
|
108
108
|
for (const outputFile of outputFiles) {
|
|
@@ -130,20 +130,20 @@ function tscEmitBuild(tscOptions) {
|
|
|
130
130
|
map
|
|
131
131
|
};
|
|
132
132
|
if (incremental) {
|
|
133
|
-
debug$
|
|
133
|
+
debug$2(`incremental build failed`);
|
|
134
134
|
return tscEmitBuild({
|
|
135
135
|
...tscOptions,
|
|
136
136
|
incremental: false
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
debug$
|
|
139
|
+
debug$2(`unable to build .d.ts file for ${id}`);
|
|
140
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}` };
|
|
141
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` };
|
|
142
142
|
}
|
|
143
143
|
function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
|
|
144
144
|
let projectMap = context.projects.get(tsconfig);
|
|
145
145
|
if (projectMap) {
|
|
146
|
-
debug$
|
|
146
|
+
debug$2(`skip building projects for ${tsconfig}`);
|
|
147
147
|
return projectMap;
|
|
148
148
|
}
|
|
149
149
|
projectMap = buildProjects(fsSystem, tsconfig, force, sourcemap);
|
|
@@ -154,18 +154,18 @@ function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
|
|
|
154
154
|
* Use TypeScript compiler to build all projects referenced
|
|
155
155
|
*/
|
|
156
156
|
function buildProjects(fsSystem, tsconfig, force, sourcemap) {
|
|
157
|
-
debug$
|
|
157
|
+
debug$2(`start building projects for ${tsconfig}`);
|
|
158
158
|
const projects = collectProjectGraph(tsconfig, fsSystem, force, sourcemap);
|
|
159
|
-
debug$
|
|
160
|
-
const host = ts.createSolutionBuilderHost(fsSystem, createProgramWithPatchedCompilerOptions);
|
|
161
|
-
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], {
|
|
162
162
|
force,
|
|
163
163
|
verbose: true
|
|
164
164
|
}).build(void 0, void 0, void 0, (project) => {
|
|
165
|
-
debug$
|
|
165
|
+
debug$2(`transforming project ${project}`);
|
|
166
166
|
return customTransformers;
|
|
167
167
|
});
|
|
168
|
-
debug$
|
|
168
|
+
debug$2(`built solution for ${tsconfig} with exit status ${exitStatus}`);
|
|
169
169
|
const sourceFileToProjectMap = /* @__PURE__ */ new Map();
|
|
170
170
|
for (const project of projects) for (const fileName of project.parsedConfig.fileNames) sourceFileToProjectMap.set(fsSystem.resolvePath(fileName), project);
|
|
171
171
|
return sourceFileToProjectMap;
|
|
@@ -193,19 +193,19 @@ function collectProjectGraph(rootTsconfigPath, fsSystem, force, sourcemap) {
|
|
|
193
193
|
tsconfigPath,
|
|
194
194
|
parsedConfig
|
|
195
195
|
});
|
|
196
|
-
for (const ref of parsedConfig.projectReferences ?? []) stack.push(ts.resolveProjectReferencePath(ref));
|
|
196
|
+
for (const ref of parsedConfig.projectReferences ?? []) stack.push(ts$1.resolveProjectReferencePath(ref));
|
|
197
197
|
}
|
|
198
198
|
return projects;
|
|
199
199
|
}
|
|
200
200
|
function parseTsconfig(tsconfigPath, fsSystem) {
|
|
201
201
|
const diagnostics = [];
|
|
202
|
-
const parsedConfig = ts.getParsedCommandLineOfConfigFile(tsconfigPath, void 0, {
|
|
202
|
+
const parsedConfig = ts$1.getParsedCommandLineOfConfigFile(tsconfigPath, void 0, {
|
|
203
203
|
...fsSystem,
|
|
204
204
|
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
|
|
205
205
|
diagnostics.push(diagnostic);
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
|
-
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)}`);
|
|
209
209
|
return parsedConfig;
|
|
210
210
|
}
|
|
211
211
|
function patchCompilerOptions(options, extraOptions) {
|
|
@@ -237,75 +237,12 @@ function patchCompilerOptions(options, extraOptions) {
|
|
|
237
237
|
return options;
|
|
238
238
|
}
|
|
239
239
|
const createProgramWithPatchedCompilerOptions = (rootNames, options, ...args) => {
|
|
240
|
-
return ts.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, patchCompilerOptions(options ?? {}, null), ...args);
|
|
240
|
+
return ts$1.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, patchCompilerOptions(options ?? {}, null), ...args);
|
|
241
241
|
};
|
|
242
242
|
//#endregion
|
|
243
|
-
//#region src/tsc/volar.ts
|
|
244
|
-
const debug$2 = createDebug("rolldown-plugin-dts:volar");
|
|
245
|
-
function loadVueLanguageTools() {
|
|
246
|
-
debug$2("loading vue language tools");
|
|
247
|
-
try {
|
|
248
|
-
const vueTscPath = __require.resolve("vue-tsc");
|
|
249
|
-
return {
|
|
250
|
-
volarTs: __require(__require.resolve("@volar/typescript", { paths: [vueTscPath] })),
|
|
251
|
-
vue: __require(__require.resolve("@vue/language-core", { paths: [vueTscPath] }))
|
|
252
|
-
};
|
|
253
|
-
} catch (error) {
|
|
254
|
-
debug$2("vue language tools not found", error);
|
|
255
|
-
throw new Error("Failed to load vue language tools. Please manually install vue-tsc.", { cause: error });
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
function initVueLanguageTools() {
|
|
259
|
-
const { vue, volarTs: { proxyCreateProgram } } = loadVueLanguageTools();
|
|
260
|
-
const getLanguagePlugin = (ts, options) => {
|
|
261
|
-
const $rootDir = options.options.$rootDir;
|
|
262
|
-
const $configRaw = options.options.$configRaw;
|
|
263
|
-
const resolver = new vue.CompilerOptionsResolver(ts, ts.sys.readFile);
|
|
264
|
-
resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
|
|
265
|
-
const vueOptions = resolver.build();
|
|
266
|
-
return vue.createVueLanguagePlugin(ts, options.options, vueOptions, (id) => id);
|
|
267
|
-
};
|
|
268
|
-
return {
|
|
269
|
-
proxyCreateProgram,
|
|
270
|
-
getLanguagePlugin
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
function initTsMacro() {
|
|
274
|
-
const debug = createDebug("rolldown-plugin-dts:ts-macro");
|
|
275
|
-
debug("loading ts-macro language tools");
|
|
276
|
-
try {
|
|
277
|
-
const tsMacroPath = __require.resolve("@ts-macro/tsc");
|
|
278
|
-
const { proxyCreateProgram } = __require(__require.resolve("@volar/typescript", { paths: [tsMacroPath] }));
|
|
279
|
-
const tsMacro = __require(__require.resolve("@ts-macro/language-plugin", { paths: [tsMacroPath] }));
|
|
280
|
-
const { getOptions } = __require(__require.resolve("@ts-macro/language-plugin/options", { paths: [tsMacroPath] }));
|
|
281
|
-
const getLanguagePlugin = (ts, options) => {
|
|
282
|
-
const $rootDir = options.options.$rootDir;
|
|
283
|
-
return tsMacro.getLanguagePlugins(ts, options.options, getOptions(ts, $rootDir))[0];
|
|
284
|
-
};
|
|
285
|
-
return {
|
|
286
|
-
proxyCreateProgram,
|
|
287
|
-
getLanguagePlugin
|
|
288
|
-
};
|
|
289
|
-
} catch (error) {
|
|
290
|
-
debug("ts-macro language tools not found", error);
|
|
291
|
-
throw new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.", { cause: error });
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
function createProgramFactory(ts, options) {
|
|
295
|
-
const vueLanguageTools = options.vue ? initVueLanguageTools() : void 0;
|
|
296
|
-
const tsMacroLanguageTools = options.tsMacro ? initTsMacro() : void 0;
|
|
297
|
-
const proxyCreateProgram = vueLanguageTools?.proxyCreateProgram || tsMacroLanguageTools?.proxyCreateProgram;
|
|
298
|
-
if (!proxyCreateProgram) return ts.createProgram;
|
|
299
|
-
return proxyCreateProgram(ts, ts.createProgram, (ts, options) => {
|
|
300
|
-
const languagePlugins = [];
|
|
301
|
-
if (vueLanguageTools) languagePlugins.push(vueLanguageTools.getLanguagePlugin(ts, options));
|
|
302
|
-
if (tsMacroLanguageTools) languagePlugins.push(tsMacroLanguageTools.getLanguagePlugin(ts, options));
|
|
303
|
-
return { languagePlugins };
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
//#endregion
|
|
307
243
|
//#region src/tsc/emit-compiler.ts
|
|
308
244
|
const debug$1 = createDebug("rolldown-plugin-dts:tsc-compiler");
|
|
245
|
+
const ts = requireTS();
|
|
309
246
|
const defaultCompilerOptions = {
|
|
310
247
|
declaration: true,
|
|
311
248
|
noEmit: false,
|
|
@@ -338,14 +275,10 @@ function createOrGetTsModule(options) {
|
|
|
338
275
|
context.programs.push(module.program);
|
|
339
276
|
return module;
|
|
340
277
|
}
|
|
341
|
-
function createTsProgram({ entries, id, tsconfig, tsconfigRaw,
|
|
278
|
+
function createTsProgram({ entries, id, tsconfig, tsconfigRaw, volarContext, cwd, context = globalContext }) {
|
|
342
279
|
const fsSystem = createFsSystem(context.files);
|
|
343
280
|
const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
|
|
344
|
-
const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir, void 0, void 0, void 0,
|
|
345
|
-
extension: "vue",
|
|
346
|
-
isMixedContent: true,
|
|
347
|
-
scriptKind: ts.ScriptKind.Deferred
|
|
348
|
-
}] : void 0);
|
|
281
|
+
const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir, void 0, void 0, void 0, volarContext.getExtraFileExtensions());
|
|
349
282
|
debug$1(`creating program for root project: ${baseDir}`);
|
|
350
283
|
return createTsProgramFromParsedConfig({
|
|
351
284
|
parsedConfig,
|
|
@@ -353,24 +286,20 @@ function createTsProgram({ entries, id, tsconfig, tsconfigRaw, vue, tsMacro, cwd
|
|
|
353
286
|
baseDir,
|
|
354
287
|
id,
|
|
355
288
|
entries,
|
|
356
|
-
|
|
357
|
-
tsMacro
|
|
289
|
+
volarContext
|
|
358
290
|
});
|
|
359
291
|
}
|
|
360
|
-
function createTsProgramFromParsedConfig({ parsedConfig, fsSystem, baseDir, id, entries,
|
|
292
|
+
function createTsProgramFromParsedConfig({ parsedConfig, fsSystem, baseDir, id, entries, volarContext }) {
|
|
361
293
|
const compilerOptions = {
|
|
362
294
|
...defaultCompilerOptions,
|
|
363
295
|
...parsedConfig.options,
|
|
364
296
|
$configRaw: parsedConfig.raw,
|
|
365
297
|
$rootDir: baseDir,
|
|
366
|
-
...
|
|
298
|
+
...volarContext.plugins.length ? { allowNonTsExtensions: true } : void 0
|
|
367
299
|
};
|
|
368
300
|
const rootNames = [...new Set([id, ...entries || parsedConfig.fileNames].map((f) => fsSystem.resolvePath(f)))];
|
|
369
301
|
const host = ts.createCompilerHost(compilerOptions, true);
|
|
370
|
-
const program =
|
|
371
|
-
vue,
|
|
372
|
-
tsMacro
|
|
373
|
-
})({
|
|
302
|
+
const program = volarContext.getCreateProgram(ts)({
|
|
374
303
|
rootNames,
|
|
375
304
|
options: compilerOptions,
|
|
376
305
|
host,
|
|
@@ -425,7 +354,6 @@ function tscEmitCompiler(tscOptions) {
|
|
|
425
354
|
//#endregion
|
|
426
355
|
//#region src/tsc/index.ts
|
|
427
356
|
const debug = createDebug("rolldown-plugin-dts:tsc");
|
|
428
|
-
debug(`loaded typescript: ${ts.version}`);
|
|
429
357
|
function tscEmit(tscOptions) {
|
|
430
358
|
debug(`running tscEmit ${tscOptions.id}`);
|
|
431
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
|
-
"@ts-macro/tsc": "^0.3.6",
|
|
45
44
|
"@typescript/native-preview": "*",
|
|
45
|
+
"@volar/typescript": "~2.4.0",
|
|
46
46
|
"rolldown": "^1.0.0",
|
|
47
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",
|