rolldown-plugin-dts 0.16.6 → 0.16.8
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/{context-Digr9tkU.js → context-CzXq1eN7.js} +7 -3
- package/dist/{context-BafOW9LT.d.ts → context-DXNtAHtR.d.ts} +4 -4
- package/dist/filename.js +1 -1
- package/dist/{index-BJoOXlKM.d.ts → index-CxJisQQS.d.ts} +4 -3
- package/dist/index.js +24 -23
- package/dist/{tsc-CCjlVYkv.js → tsc-ExCTFf5T.js} +59 -57
- package/dist/tsc-context.d.ts +1 -1
- package/dist/tsc-context.js +1 -1
- package/dist/tsc-worker.d.ts +2 -2
- package/dist/tsc-worker.js +2 -2
- package/dist/tsc.d.ts +2 -2
- package/dist/tsc.js +2 -2
- package/package.json +5 -4
- /package/dist/{filename-Dd76wOJT.js → filename-DCSs6tgU.js} +0 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
3
7
|
//#region src/tsc/context.ts
|
|
4
|
-
const debug =
|
|
8
|
+
const debug = __require("debug")("rolldown-plugin-dts:tsc-context");
|
|
5
9
|
function createContext() {
|
|
6
10
|
return {
|
|
7
11
|
programs: [],
|
|
@@ -20,4 +24,4 @@ function invalidateContextFile(context, file) {
|
|
|
20
24
|
const globalContext = createContext();
|
|
21
25
|
|
|
22
26
|
//#endregion
|
|
23
|
-
export { createContext, globalContext, invalidateContextFile };
|
|
27
|
+
export { __require, createContext, globalContext, invalidateContextFile };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ts from "typescript";
|
|
2
2
|
|
|
3
3
|
//#region src/tsc/context.d.ts
|
|
4
4
|
interface ParsedProject {
|
|
5
5
|
tsconfigPath: string;
|
|
6
|
-
parsedConfig:
|
|
6
|
+
parsedConfig: ts.ParsedCommandLine;
|
|
7
7
|
}
|
|
8
8
|
type SourceFileToProjectMap = Map<string, ParsedProject>;
|
|
9
9
|
interface TscContext {
|
|
10
|
-
programs:
|
|
10
|
+
programs: ts.Program[];
|
|
11
11
|
files: Map<string, string>;
|
|
12
12
|
projects: Map<string, SourceFileToProjectMap>;
|
|
13
13
|
}
|
|
@@ -15,4 +15,4 @@ declare function createContext(): TscContext;
|
|
|
15
15
|
declare function invalidateContextFile(context: TscContext, file: string): void;
|
|
16
16
|
declare const globalContext: TscContext;
|
|
17
17
|
//#endregion
|
|
18
|
-
export { ParsedProject, SourceFileToProjectMap,
|
|
18
|
+
export { ParsedProject, SourceFileToProjectMap, TscContext, createContext, globalContext, invalidateContextFile };
|
package/dist/filename.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn } from "./filename-
|
|
1
|
+
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn } from "./filename-DCSs6tgU.js";
|
|
2
2
|
|
|
3
3
|
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TscContext } from "./context-DXNtAHtR.js";
|
|
2
2
|
import { TsConfigJson } from "get-tsconfig";
|
|
3
|
+
import ts from "typescript";
|
|
3
4
|
import { SourceMapInput } from "rolldown";
|
|
4
5
|
|
|
5
6
|
//#region src/tsc/types.d.ts
|
|
6
7
|
interface TscModule {
|
|
7
|
-
program:
|
|
8
|
-
file:
|
|
8
|
+
program: ts.Program;
|
|
9
|
+
file: ts.SourceFile;
|
|
9
10
|
}
|
|
10
11
|
interface TscOptions {
|
|
11
12
|
tsconfig?: string;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
import Debug from "debug";
|
|
1
|
+
import { __require, createContext, globalContext, invalidateContextFile } from "./context-CzXq1eN7.js";
|
|
2
|
+
import { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn } from "./filename-DCSs6tgU.js";
|
|
5
3
|
import MagicString from "magic-string";
|
|
6
|
-
import * as t from "@babel/types";
|
|
7
4
|
import { isDeclarationType, isTypeOf, resolveString } from "ast-kit";
|
|
8
5
|
import { fork, spawn } from "node:child_process";
|
|
9
6
|
import { existsSync } from "node:fs";
|
|
@@ -267,9 +264,9 @@ function walk(ast, { enter, leave }) {
|
|
|
267
264
|
|
|
268
265
|
//#endregion
|
|
269
266
|
//#region src/fake-js.ts
|
|
270
|
-
const
|
|
271
|
-
const { parse } =
|
|
272
|
-
const
|
|
267
|
+
const { generate } = __require("@babel/generator");
|
|
268
|
+
const { parse } = __require("@babel/parser");
|
|
269
|
+
const t = __require("@babel/types");
|
|
273
270
|
function createFakeJsPlugin({ sourcemap, cjsDefault }) {
|
|
274
271
|
let symbolIdx = 0;
|
|
275
272
|
const identifierMap = Object.create(null);
|
|
@@ -695,7 +692,8 @@ function inheritNodeComments(oldNode, newNode) {
|
|
|
695
692
|
|
|
696
693
|
//#endregion
|
|
697
694
|
//#region src/generate.ts
|
|
698
|
-
const
|
|
695
|
+
const Debug$1 = __require("debug");
|
|
696
|
+
const debug$1 = Debug$1("rolldown-plugin-dts:generate");
|
|
699
697
|
const WORKER_URL = "./tsc-worker.js";
|
|
700
698
|
const spawnAsync = (...args) => new Promise((resolve, reject) => {
|
|
701
699
|
const child = spawn(...args);
|
|
@@ -963,26 +961,15 @@ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = f
|
|
|
963
961
|
|
|
964
962
|
//#endregion
|
|
965
963
|
//#region src/resolver.ts
|
|
964
|
+
function isSourceFile(id) {
|
|
965
|
+
return RE_TS.test(id) || RE_VUE.test(id);
|
|
966
|
+
}
|
|
966
967
|
function createDtsResolvePlugin({ tsconfig, resolve }) {
|
|
967
|
-
const isSourceFile = (p) => RE_TS.test(p) || RE_VUE.test(p);
|
|
968
|
-
const shouldBundleNodeModule = (id) => {
|
|
969
|
-
if (typeof resolve === "boolean") return resolve;
|
|
970
|
-
return resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
|
|
971
|
-
};
|
|
972
968
|
const baseDtsResolver = createResolver({
|
|
973
969
|
tsconfig,
|
|
974
970
|
resolveNodeModules: !!resolve,
|
|
975
971
|
ResolverFactory
|
|
976
972
|
});
|
|
977
|
-
function resolveDtsPath(id, importer, rolldownResolution) {
|
|
978
|
-
let dtsPath = baseDtsResolver(id, importer);
|
|
979
|
-
if (dtsPath) dtsPath = path.normalize(dtsPath);
|
|
980
|
-
if (!dtsPath || !isSourceFile(dtsPath)) {
|
|
981
|
-
if (rolldownResolution && isFilePath(rolldownResolution.id) && isSourceFile(rolldownResolution.id) && !rolldownResolution.external) return rolldownResolution.id;
|
|
982
|
-
return null;
|
|
983
|
-
}
|
|
984
|
-
return dtsPath;
|
|
985
|
-
}
|
|
986
973
|
return {
|
|
987
974
|
name: "rolldown-plugin-dts:resolver",
|
|
988
975
|
resolveId: {
|
|
@@ -1007,6 +994,19 @@ function createDtsResolvePlugin({ tsconfig, resolve }) {
|
|
|
1007
994
|
}
|
|
1008
995
|
}
|
|
1009
996
|
};
|
|
997
|
+
function shouldBundleNodeModule(id) {
|
|
998
|
+
if (typeof resolve === "boolean") return resolve;
|
|
999
|
+
return resolve.some((pattern) => typeof pattern === "string" ? id === pattern : pattern.test(id));
|
|
1000
|
+
}
|
|
1001
|
+
function resolveDtsPath(id, importer, rolldownResolution) {
|
|
1002
|
+
let dtsPath = baseDtsResolver(id, importer);
|
|
1003
|
+
if (dtsPath) dtsPath = path.normalize(dtsPath);
|
|
1004
|
+
if (!dtsPath || !isSourceFile(dtsPath)) {
|
|
1005
|
+
if (rolldownResolution && isFilePath(rolldownResolution.id) && isSourceFile(rolldownResolution.id) && !rolldownResolution.external) return rolldownResolution.id;
|
|
1006
|
+
return null;
|
|
1007
|
+
}
|
|
1008
|
+
return dtsPath;
|
|
1009
|
+
}
|
|
1010
1010
|
}
|
|
1011
1011
|
function isFilePath(id) {
|
|
1012
1012
|
return id.startsWith(".") || path.isAbsolute(id);
|
|
@@ -1014,6 +1014,7 @@ function isFilePath(id) {
|
|
|
1014
1014
|
|
|
1015
1015
|
//#endregion
|
|
1016
1016
|
//#region src/index.ts
|
|
1017
|
+
const Debug = __require("debug");
|
|
1017
1018
|
const debug = Debug("rolldown-plugin-dts:options");
|
|
1018
1019
|
function dts(options = {}) {
|
|
1019
1020
|
debug("resolving dts options");
|
|
@@ -1,49 +1,44 @@
|
|
|
1
|
-
import { globalContext } from "./context-
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import Debug from "debug";
|
|
1
|
+
import { __require, globalContext } from "./context-CzXq1eN7.js";
|
|
4
2
|
import path from "node:path";
|
|
5
3
|
import { pathToFileURL } from "node:url";
|
|
6
4
|
|
|
7
|
-
//#region src/tsc/require-tsc.ts
|
|
8
|
-
const require$1 = createRequire(import.meta.url);
|
|
9
|
-
const ts = require$1("typescript");
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
5
|
//#region src/tsc/system.ts
|
|
13
|
-
const
|
|
6
|
+
const Debug$4 = __require("debug");
|
|
7
|
+
const ts$4 = __require("typescript");
|
|
8
|
+
const debug$3 = Debug$4("rolldown-plugin-dts:tsc-system");
|
|
14
9
|
/**
|
|
15
10
|
* A system that writes files to both memory and disk. It will try read files
|
|
16
11
|
* from memory firstly and fallback to disk if not found.
|
|
17
12
|
*/
|
|
18
13
|
function createFsSystem(files) {
|
|
19
14
|
return {
|
|
20
|
-
...ts.sys,
|
|
15
|
+
...ts$4.sys,
|
|
21
16
|
write(message) {
|
|
22
17
|
debug$3(message);
|
|
23
18
|
},
|
|
24
19
|
resolvePath(path$1) {
|
|
25
20
|
if (files.has(path$1)) return path$1;
|
|
26
|
-
return ts.sys.resolvePath(path$1);
|
|
21
|
+
return ts$4.sys.resolvePath(path$1);
|
|
27
22
|
},
|
|
28
23
|
directoryExists(directory) {
|
|
29
24
|
if (Array.from(files.keys()).some((path$1) => path$1.startsWith(directory))) return true;
|
|
30
|
-
return ts.sys.directoryExists(directory);
|
|
25
|
+
return ts$4.sys.directoryExists(directory);
|
|
31
26
|
},
|
|
32
27
|
fileExists(fileName) {
|
|
33
28
|
if (files.has(fileName)) return true;
|
|
34
|
-
return ts.sys.fileExists(fileName);
|
|
29
|
+
return ts$4.sys.fileExists(fileName);
|
|
35
30
|
},
|
|
36
31
|
readFile(fileName, ...args) {
|
|
37
32
|
if (files.has(fileName)) return files.get(fileName);
|
|
38
|
-
return ts.sys.readFile(fileName, ...args);
|
|
33
|
+
return ts$4.sys.readFile(fileName, ...args);
|
|
39
34
|
},
|
|
40
35
|
writeFile(path$1, data, ...args) {
|
|
41
36
|
files.set(path$1, data);
|
|
42
|
-
ts.sys.writeFile(path$1, data, ...args);
|
|
37
|
+
ts$4.sys.writeFile(path$1, data, ...args);
|
|
43
38
|
},
|
|
44
39
|
deleteFile(fileName, ...args) {
|
|
45
40
|
files.delete(fileName);
|
|
46
|
-
ts.sys.deleteFile?.(fileName, ...args);
|
|
41
|
+
ts$4.sys.deleteFile?.(fileName, ...args);
|
|
47
42
|
}
|
|
48
43
|
};
|
|
49
44
|
}
|
|
@@ -61,17 +56,18 @@ function createMemorySystem(files) {
|
|
|
61
56
|
|
|
62
57
|
//#endregion
|
|
63
58
|
//#region src/tsc/utils.ts
|
|
59
|
+
const ts$3 = __require("typescript");
|
|
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$3.sys.getCurrentDirectory(),
|
|
62
|
+
getNewLine: () => ts$3.sys.newLine,
|
|
63
|
+
getCanonicalFileName: ts$3.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
68
64
|
};
|
|
69
65
|
const stripPrivateFields = (ctx) => {
|
|
70
66
|
const visitor = (node) => {
|
|
71
|
-
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);
|
|
72
|
-
return ts.visitEachChild(node, visitor, ctx);
|
|
67
|
+
if (ts$3.isPropertySignature(node) && ts$3.isPrivateIdentifier(node.name)) return ctx.factory.updatePropertySignature(node, node.modifiers, ctx.factory.createStringLiteral(node.name.text), node.questionToken, node.type);
|
|
68
|
+
return ts$3.visitEachChild(node, visitor, ctx);
|
|
73
69
|
};
|
|
74
|
-
return (sourceFile) => ts.visitNode(sourceFile, visitor, ts.isSourceFile) ?? sourceFile;
|
|
70
|
+
return (sourceFile) => ts$3.visitNode(sourceFile, visitor, ts$3.isSourceFile) ?? sourceFile;
|
|
75
71
|
};
|
|
76
72
|
const customTransformers = { afterDeclarations: [stripPrivateFields] };
|
|
77
73
|
function setSourceMapRoot(map, originalFilePath, finalFilePath) {
|
|
@@ -84,7 +80,9 @@ function setSourceMapRoot(map, originalFilePath, finalFilePath) {
|
|
|
84
80
|
|
|
85
81
|
//#endregion
|
|
86
82
|
//#region src/tsc/emit-build.ts
|
|
87
|
-
const
|
|
83
|
+
const Debug$3 = __require("debug");
|
|
84
|
+
const ts$2 = __require("typescript");
|
|
85
|
+
const debug$2 = Debug$3("rolldown-plugin-dts:tsc-build");
|
|
88
86
|
function tscEmitBuild(tscOptions) {
|
|
89
87
|
const { id, tsconfig, incremental, context = globalContext, sourcemap } = tscOptions;
|
|
90
88
|
debug$2(`running tscEmitBuild id: ${id}, tsconfig: ${tsconfig}, incremental: ${incremental}`);
|
|
@@ -99,7 +97,7 @@ function tscEmitBuild(tscOptions) {
|
|
|
99
97
|
}
|
|
100
98
|
debug$2(`loaded project ${project.tsconfigPath} for ${id}`);
|
|
101
99
|
const ignoreCase = !fsSystem.useCaseSensitiveFileNames;
|
|
102
|
-
const outputFiles = ts.getOutputFileNames(project.parsedConfig, resolvedId, ignoreCase);
|
|
100
|
+
const outputFiles = ts$2.getOutputFileNames(project.parsedConfig, resolvedId, ignoreCase);
|
|
103
101
|
let code;
|
|
104
102
|
let map;
|
|
105
103
|
for (const outputFile of outputFiles) {
|
|
@@ -154,8 +152,8 @@ function buildProjects(fsSystem, tsconfig, force, sourcemap) {
|
|
|
154
152
|
debug$2(`start building projects for ${tsconfig}`);
|
|
155
153
|
const projects = collectProjectGraph(tsconfig, fsSystem, force, sourcemap);
|
|
156
154
|
debug$2("collected %d projects: %j", projects.length, projects.map((project) => project.tsconfigPath));
|
|
157
|
-
const host = ts.createSolutionBuilderHost(fsSystem, createProgramWithPatchedCompilerOptions);
|
|
158
|
-
const exitStatus = ts.createSolutionBuilder(host, [tsconfig], {
|
|
155
|
+
const host = ts$2.createSolutionBuilderHost(fsSystem, createProgramWithPatchedCompilerOptions);
|
|
156
|
+
const exitStatus = ts$2.createSolutionBuilder(host, [tsconfig], {
|
|
159
157
|
force,
|
|
160
158
|
verbose: true
|
|
161
159
|
}).build(void 0, void 0, void 0, (project) => {
|
|
@@ -190,19 +188,19 @@ function collectProjectGraph(rootTsconfigPath, fsSystem, force, sourcemap) {
|
|
|
190
188
|
tsconfigPath,
|
|
191
189
|
parsedConfig
|
|
192
190
|
});
|
|
193
|
-
for (const ref of parsedConfig.projectReferences ?? []) stack.push(ts.resolveProjectReferencePath(ref));
|
|
191
|
+
for (const ref of parsedConfig.projectReferences ?? []) stack.push(ts$2.resolveProjectReferencePath(ref));
|
|
194
192
|
}
|
|
195
193
|
return projects;
|
|
196
194
|
}
|
|
197
195
|
function parseTsconfig(tsconfigPath, fsSystem) {
|
|
198
196
|
const diagnostics = [];
|
|
199
|
-
const parsedConfig = ts.getParsedCommandLineOfConfigFile(tsconfigPath, void 0, {
|
|
197
|
+
const parsedConfig = ts$2.getParsedCommandLineOfConfigFile(tsconfigPath, void 0, {
|
|
200
198
|
...fsSystem,
|
|
201
199
|
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
|
|
202
200
|
diagnostics.push(diagnostic);
|
|
203
201
|
}
|
|
204
202
|
});
|
|
205
|
-
if (diagnostics.length) throw new Error(`[rolldown-plugin-dts] Unable to read ${tsconfigPath}: ${ts.formatDiagnostics(diagnostics, formatHost)}`);
|
|
203
|
+
if (diagnostics.length) throw new Error(`[rolldown-plugin-dts] Unable to read ${tsconfigPath}: ${ts$2.formatDiagnostics(diagnostics, formatHost)}`);
|
|
206
204
|
return parsedConfig;
|
|
207
205
|
}
|
|
208
206
|
function patchCompilerOptions(options, extraOptions) {
|
|
@@ -234,27 +232,27 @@ function patchCompilerOptions(options, extraOptions) {
|
|
|
234
232
|
return options;
|
|
235
233
|
}
|
|
236
234
|
const createProgramWithPatchedCompilerOptions = (rootNames, options, ...args) => {
|
|
237
|
-
return ts.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, patchCompilerOptions(options ?? {}, null), ...args);
|
|
235
|
+
return ts$2.createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, patchCompilerOptions(options ?? {}, null), ...args);
|
|
238
236
|
};
|
|
239
237
|
|
|
240
238
|
//#endregion
|
|
241
239
|
//#region src/tsc/volar.ts
|
|
242
|
-
const
|
|
240
|
+
const Debug$2 = __require("debug");
|
|
243
241
|
function loadVueLanguageTools() {
|
|
244
|
-
const debug$4 = Debug("rolldown-plugin-dts:vue");
|
|
242
|
+
const debug$4 = Debug$2("rolldown-plugin-dts:vue");
|
|
245
243
|
debug$4("loading vue language tools");
|
|
246
244
|
try {
|
|
247
|
-
const vueTscPath =
|
|
248
|
-
const { proxyCreateProgram } =
|
|
249
|
-
const vue =
|
|
250
|
-
const getLanguagePlugin = (ts$
|
|
245
|
+
const vueTscPath = __require.resolve("vue-tsc");
|
|
246
|
+
const { proxyCreateProgram } = __require(__require.resolve("@volar/typescript", { paths: [vueTscPath] }));
|
|
247
|
+
const vue = __require(__require.resolve("@vue/language-core", { paths: [vueTscPath] }));
|
|
248
|
+
const getLanguagePlugin = (ts$5, options) => {
|
|
251
249
|
const $rootDir = options.options.$rootDir;
|
|
252
250
|
const $configRaw = options.options.$configRaw;
|
|
253
|
-
const resolver = new vue.CompilerOptionsResolver(ts$
|
|
251
|
+
const resolver = new vue.CompilerOptionsResolver(ts$5.sys.fileExists);
|
|
254
252
|
resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
|
|
255
253
|
const vueOptions = resolver.build();
|
|
256
|
-
vue.writeGlobalTypes(vueOptions, ts$
|
|
257
|
-
return vue.createVueLanguagePlugin(ts$
|
|
254
|
+
vue.writeGlobalTypes(vueOptions, ts$5.sys.writeFile);
|
|
255
|
+
return vue.createVueLanguagePlugin(ts$5, options.options, vueOptions, (id) => id);
|
|
258
256
|
};
|
|
259
257
|
return {
|
|
260
258
|
proxyCreateProgram,
|
|
@@ -266,16 +264,16 @@ function loadVueLanguageTools() {
|
|
|
266
264
|
}
|
|
267
265
|
}
|
|
268
266
|
function loadTsMacro() {
|
|
269
|
-
const debug$4 = Debug("rolldown-plugin-dts:ts-macro");
|
|
267
|
+
const debug$4 = Debug$2("rolldown-plugin-dts:ts-macro");
|
|
270
268
|
debug$4("loading ts-macro language tools");
|
|
271
269
|
try {
|
|
272
|
-
const tsMacroPath =
|
|
273
|
-
const { proxyCreateProgram } =
|
|
274
|
-
const tsMacro =
|
|
275
|
-
const { getOptions } =
|
|
276
|
-
const getLanguagePlugin = (ts$
|
|
270
|
+
const tsMacroPath = __require.resolve("@ts-macro/tsc");
|
|
271
|
+
const { proxyCreateProgram } = __require(__require.resolve("@volar/typescript", { paths: [tsMacroPath] }));
|
|
272
|
+
const tsMacro = __require(__require.resolve("@ts-macro/language-plugin", { paths: [tsMacroPath] }));
|
|
273
|
+
const { getOptions } = __require(__require.resolve("@ts-macro/language-plugin/options", { paths: [tsMacroPath] }));
|
|
274
|
+
const getLanguagePlugin = (ts$5, options) => {
|
|
277
275
|
const $rootDir = options.options.$rootDir;
|
|
278
|
-
return tsMacro.getLanguagePlugins(ts$
|
|
276
|
+
return tsMacro.getLanguagePlugins(ts$5, options.options, getOptions(ts$5, $rootDir))[0];
|
|
279
277
|
};
|
|
280
278
|
return {
|
|
281
279
|
proxyCreateProgram,
|
|
@@ -286,22 +284,24 @@ function loadTsMacro() {
|
|
|
286
284
|
throw new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.");
|
|
287
285
|
}
|
|
288
286
|
}
|
|
289
|
-
function createProgramFactory(ts$
|
|
287
|
+
function createProgramFactory(ts$5, options) {
|
|
290
288
|
const vueLanguageTools = options.vue ? loadVueLanguageTools() : void 0;
|
|
291
289
|
const tsMacroLanguageTools = options.tsMacro ? loadTsMacro() : void 0;
|
|
292
290
|
const proxyCreateProgram = vueLanguageTools?.proxyCreateProgram || tsMacroLanguageTools?.proxyCreateProgram;
|
|
293
|
-
if (!proxyCreateProgram) return ts$
|
|
294
|
-
return proxyCreateProgram(ts$
|
|
291
|
+
if (!proxyCreateProgram) return ts$5.createProgram;
|
|
292
|
+
return proxyCreateProgram(ts$5, ts$5.createProgram, (ts$6, options$1) => {
|
|
295
293
|
const languagePlugins = [];
|
|
296
|
-
if (vueLanguageTools) languagePlugins.push(vueLanguageTools.getLanguagePlugin(ts$
|
|
297
|
-
if (tsMacroLanguageTools) languagePlugins.push(tsMacroLanguageTools.getLanguagePlugin(ts$
|
|
294
|
+
if (vueLanguageTools) languagePlugins.push(vueLanguageTools.getLanguagePlugin(ts$6, options$1));
|
|
295
|
+
if (tsMacroLanguageTools) languagePlugins.push(tsMacroLanguageTools.getLanguagePlugin(ts$6, options$1));
|
|
298
296
|
return { languagePlugins };
|
|
299
297
|
});
|
|
300
298
|
}
|
|
301
299
|
|
|
302
300
|
//#endregion
|
|
303
301
|
//#region src/tsc/emit-compiler.ts
|
|
304
|
-
const
|
|
302
|
+
const Debug$1 = __require("debug");
|
|
303
|
+
const ts$1 = __require("typescript");
|
|
304
|
+
const debug$1 = Debug$1("rolldown-plugin-dts:tsc-compiler");
|
|
305
305
|
const defaultCompilerOptions = {
|
|
306
306
|
declaration: true,
|
|
307
307
|
noEmit: false,
|
|
@@ -312,7 +312,7 @@ const defaultCompilerOptions = {
|
|
|
312
312
|
skipLibCheck: true,
|
|
313
313
|
target: 99,
|
|
314
314
|
resolveJsonModule: true,
|
|
315
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler
|
|
315
|
+
moduleResolution: ts$1.ModuleResolutionKind.Bundler
|
|
316
316
|
};
|
|
317
317
|
function createOrGetTsModule(options) {
|
|
318
318
|
const { id, entries, context = globalContext } = options;
|
|
@@ -337,7 +337,7 @@ function createOrGetTsModule(options) {
|
|
|
337
337
|
function createTsProgram({ entries, id, tsconfig, tsconfigRaw, vue, tsMacro, cwd, context = globalContext }) {
|
|
338
338
|
const fsSystem = createFsSystem(context.files);
|
|
339
339
|
const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
|
|
340
|
-
const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir);
|
|
340
|
+
const parsedConfig = ts$1.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir);
|
|
341
341
|
debug$1(`Creating program for root project: ${baseDir}`);
|
|
342
342
|
return createTsProgramFromParsedConfig({
|
|
343
343
|
parsedConfig,
|
|
@@ -357,8 +357,8 @@ function createTsProgramFromParsedConfig({ parsedConfig, fsSystem, baseDir, id,
|
|
|
357
357
|
$rootDir: baseDir
|
|
358
358
|
};
|
|
359
359
|
const rootNames = [...new Set([id, ...entries || parsedConfig.fileNames].map((f) => fsSystem.resolvePath(f)))];
|
|
360
|
-
const host = ts.createCompilerHost(compilerOptions, true);
|
|
361
|
-
const program = createProgramFactory(ts, {
|
|
360
|
+
const host = ts$1.createCompilerHost(compilerOptions, true);
|
|
361
|
+
const program = createProgramFactory(ts$1, {
|
|
362
362
|
vue,
|
|
363
363
|
tsMacro
|
|
364
364
|
})({
|
|
@@ -400,7 +400,7 @@ function tscEmitCompiler(tscOptions) {
|
|
|
400
400
|
dtsCode = code;
|
|
401
401
|
}
|
|
402
402
|
}, void 0, true, customTransformers, true);
|
|
403
|
-
if (emitSkipped && diagnostics.length) return { error: ts.formatDiagnostics(diagnostics, formatHost) };
|
|
403
|
+
if (emitSkipped && diagnostics.length) return { error: ts$1.formatDiagnostics(diagnostics, formatHost) };
|
|
404
404
|
if (!dtsCode && file.isDeclarationFile) {
|
|
405
405
|
debug$1("nothing was emitted. fallback to sourceFile text.");
|
|
406
406
|
dtsCode = file.getFullText();
|
|
@@ -413,6 +413,8 @@ function tscEmitCompiler(tscOptions) {
|
|
|
413
413
|
|
|
414
414
|
//#endregion
|
|
415
415
|
//#region src/tsc/index.ts
|
|
416
|
+
const Debug = __require("debug");
|
|
417
|
+
const ts = __require("typescript");
|
|
416
418
|
const debug = Debug("rolldown-plugin-dts:tsc");
|
|
417
419
|
debug(`loaded typescript: ${ts.version}`);
|
|
418
420
|
function tscEmit(tscOptions) {
|
package/dist/tsc-context.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ParsedProject, SourceFileToProjectMap, TscContext, createContext, globalContext, invalidateContextFile } from "./context-
|
|
1
|
+
import { ParsedProject, SourceFileToProjectMap, TscContext, createContext, globalContext, invalidateContextFile } from "./context-DXNtAHtR.js";
|
|
2
2
|
export { ParsedProject, SourceFileToProjectMap, TscContext, createContext, globalContext, invalidateContextFile };
|
package/dist/tsc-context.js
CHANGED
package/dist/tsc-worker.d.ts
CHANGED
package/dist/tsc-worker.js
CHANGED
package/dist/tsc.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./context-
|
|
2
|
-
import { TscModule, TscOptions, TscResult, tscEmit } from "./index-
|
|
1
|
+
import "./context-DXNtAHtR.js";
|
|
2
|
+
import { TscModule, TscOptions, TscResult, tscEmit } from "./index-CxJisQQS.js";
|
|
3
3
|
export { TscModule, TscOptions, TscResult, tscEmit };
|
package/dist/tsc.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-plugin-dts",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.8",
|
|
4
4
|
"description": "A Rolldown plugin to generate and bundle dts files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -78,19 +78,20 @@
|
|
|
78
78
|
"@types/babel__generator": "^7.27.0",
|
|
79
79
|
"@types/debug": "^4.1.12",
|
|
80
80
|
"@types/node": "^24.5.2",
|
|
81
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
81
|
+
"@typescript/native-preview": "7.0.0-dev.20250921.1",
|
|
82
82
|
"@volar/typescript": "^2.4.23",
|
|
83
83
|
"@vue/language-core": "^3.0.7",
|
|
84
84
|
"arktype": "^2.1.22",
|
|
85
85
|
"bumpp": "^10.2.3",
|
|
86
86
|
"diff": "^8.0.2",
|
|
87
|
-
"eslint": "^9.
|
|
87
|
+
"eslint": "^9.36.0",
|
|
88
88
|
"estree-walker": "^3.0.3",
|
|
89
89
|
"prettier": "^3.6.2",
|
|
90
90
|
"rolldown": "^1.0.0-beta.38",
|
|
91
|
+
"rolldown-plugin-require-cjs": "^0.1.4",
|
|
91
92
|
"rollup-plugin-dts": "^6.2.3",
|
|
92
93
|
"tinyglobby": "^0.2.15",
|
|
93
|
-
"tsdown": "^0.15.
|
|
94
|
+
"tsdown": "^0.15.4",
|
|
94
95
|
"typescript": "^5.9.2",
|
|
95
96
|
"vitest": "^3.2.4",
|
|
96
97
|
"vue": "^3.5.21",
|
|
File without changes
|