rolldown-plugin-dts 0.21.1 → 0.21.2
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.
|
@@ -16,7 +16,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/tsc/system.ts
|
|
19
|
-
const debug$
|
|
19
|
+
const debug$4 = createDebug("rolldown-plugin-dts:tsc-system");
|
|
20
20
|
/**
|
|
21
21
|
* A system that writes files to both memory and disk. It will try read files
|
|
22
22
|
* from memory firstly and fallback to disk if not found.
|
|
@@ -25,7 +25,7 @@ function createFsSystem(files) {
|
|
|
25
25
|
return {
|
|
26
26
|
...ts.sys,
|
|
27
27
|
write(message) {
|
|
28
|
-
debug$
|
|
28
|
+
debug$4(message);
|
|
29
29
|
},
|
|
30
30
|
resolvePath(path$1) {
|
|
31
31
|
if (files.has(path$1)) return path$1;
|
|
@@ -90,20 +90,20 @@ function setSourceMapRoot(map, originalFilePath, finalFilePath) {
|
|
|
90
90
|
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region src/tsc/emit-build.ts
|
|
93
|
-
const debug$
|
|
93
|
+
const debug$3 = createDebug("rolldown-plugin-dts:tsc-build");
|
|
94
94
|
function tscEmitBuild(tscOptions) {
|
|
95
95
|
const { id, tsconfig, incremental, context = globalContext, sourcemap } = tscOptions;
|
|
96
|
-
debug$
|
|
96
|
+
debug$3(`running tscEmitBuild id: ${id}, tsconfig: ${tsconfig}, incremental: ${incremental}`);
|
|
97
97
|
if (!tsconfig) return { error: "[rolldown-plugin-dts] build mode requires a tsconfig path" };
|
|
98
98
|
const fsSystem = (incremental ? createFsSystem : createMemorySystem)(context.files);
|
|
99
99
|
const resolvedId = fsSystem.resolvePath(id);
|
|
100
|
-
if (resolvedId !== id) debug$
|
|
100
|
+
if (resolvedId !== id) debug$3(`resolved id from ${id} to ${resolvedId}`);
|
|
101
101
|
const project = getOrBuildProjects(context, fsSystem, tsconfig, !incremental, sourcemap).get(resolvedId);
|
|
102
102
|
if (!project) {
|
|
103
|
-
debug$
|
|
103
|
+
debug$3(`unable to locate a project containing ${resolvedId}`);
|
|
104
104
|
return { error: `Unable to locate ${id} from the given tsconfig file ${tsconfig}` };
|
|
105
105
|
}
|
|
106
|
-
debug$
|
|
106
|
+
debug$3(`loaded project ${project.tsconfigPath} for ${id}`);
|
|
107
107
|
const ignoreCase = !fsSystem.useCaseSensitiveFileNames;
|
|
108
108
|
const outputFiles = ts.getOutputFileNames(project.parsedConfig, resolvedId, ignoreCase);
|
|
109
109
|
let code;
|
|
@@ -133,20 +133,20 @@ function tscEmitBuild(tscOptions) {
|
|
|
133
133
|
map
|
|
134
134
|
};
|
|
135
135
|
if (incremental) {
|
|
136
|
-
debug$
|
|
136
|
+
debug$3(`incremental build failed`);
|
|
137
137
|
return tscEmitBuild({
|
|
138
138
|
...tscOptions,
|
|
139
139
|
incremental: false
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
-
debug$
|
|
142
|
+
debug$3(`unable to build .d.ts file for ${id}`);
|
|
143
143
|
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
144
|
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
145
|
}
|
|
146
146
|
function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
|
|
147
147
|
let projectMap = context.projects.get(tsconfig);
|
|
148
148
|
if (projectMap) {
|
|
149
|
-
debug$
|
|
149
|
+
debug$3(`skip building projects for ${tsconfig}`);
|
|
150
150
|
return projectMap;
|
|
151
151
|
}
|
|
152
152
|
projectMap = buildProjects(fsSystem, tsconfig, force, sourcemap);
|
|
@@ -157,15 +157,15 @@ function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
|
|
|
157
157
|
* Use TypeScript compiler to build all projects referenced
|
|
158
158
|
*/
|
|
159
159
|
function buildProjects(fsSystem, tsconfig, force, sourcemap) {
|
|
160
|
-
debug$
|
|
160
|
+
debug$3(`start building projects for ${tsconfig}`);
|
|
161
161
|
const projects = collectProjectGraph(tsconfig, fsSystem, force, sourcemap);
|
|
162
|
-
debug$
|
|
162
|
+
debug$3("collected %d projects: %j", projects.length, projects.map((project) => project.tsconfigPath));
|
|
163
163
|
const host = ts.createSolutionBuilderHost(fsSystem, createProgramWithPatchedCompilerOptions);
|
|
164
|
-
debug$
|
|
164
|
+
debug$3(`built solution for ${tsconfig} with exit status ${ts.createSolutionBuilder(host, [tsconfig], {
|
|
165
165
|
force,
|
|
166
166
|
verbose: true
|
|
167
167
|
}).build(void 0, void 0, void 0, (project) => {
|
|
168
|
-
debug$
|
|
168
|
+
debug$3(`transforming project ${project}`);
|
|
169
169
|
return customTransformers;
|
|
170
170
|
})}`);
|
|
171
171
|
const sourceFileToProjectMap = /* @__PURE__ */ new Map();
|
|
@@ -244,33 +244,38 @@ const createProgramWithPatchedCompilerOptions = (rootNames, options, ...args) =>
|
|
|
244
244
|
|
|
245
245
|
//#endregion
|
|
246
246
|
//#region src/tsc/volar.ts
|
|
247
|
+
const debug$2 = createDebug("rolldown-plugin-dts:volar");
|
|
247
248
|
function loadVueLanguageTools() {
|
|
248
|
-
|
|
249
|
-
debug$4("loading vue language tools");
|
|
249
|
+
debug$2("loading vue language tools");
|
|
250
250
|
try {
|
|
251
251
|
const vueTscPath = __require.resolve("vue-tsc");
|
|
252
|
-
const { proxyCreateProgram } = __require(__require.resolve("@volar/typescript", { paths: [vueTscPath] }));
|
|
253
|
-
const vue = __require(__require.resolve("@vue/language-core", { paths: [vueTscPath] }));
|
|
254
|
-
const getLanguagePlugin = (ts$1, options) => {
|
|
255
|
-
const $rootDir = options.options.$rootDir;
|
|
256
|
-
const $configRaw = options.options.$configRaw;
|
|
257
|
-
const resolver = new vue.CompilerOptionsResolver(ts$1, ts$1.sys.readFile);
|
|
258
|
-
resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
|
|
259
|
-
const vueOptions = resolver.build();
|
|
260
|
-
return vue.createVueLanguagePlugin(ts$1, options.options, vueOptions, (id) => id);
|
|
261
|
-
};
|
|
262
252
|
return {
|
|
263
|
-
|
|
264
|
-
|
|
253
|
+
volarTs: __require(__require.resolve("@volar/typescript", { paths: [vueTscPath] })),
|
|
254
|
+
vue: __require(__require.resolve("@vue/language-core", { paths: [vueTscPath] }))
|
|
265
255
|
};
|
|
266
256
|
} catch (error) {
|
|
267
|
-
debug$
|
|
257
|
+
debug$2("vue language tools not found", error);
|
|
268
258
|
throw new Error("Failed to load vue language tools. Please manually install vue-tsc.");
|
|
269
259
|
}
|
|
270
260
|
}
|
|
271
|
-
function
|
|
272
|
-
const
|
|
273
|
-
|
|
261
|
+
function initVueLanguageTools() {
|
|
262
|
+
const { vue, volarTs: { proxyCreateProgram } } = loadVueLanguageTools();
|
|
263
|
+
const getLanguagePlugin = (ts$1, options) => {
|
|
264
|
+
const $rootDir = options.options.$rootDir;
|
|
265
|
+
const $configRaw = options.options.$configRaw;
|
|
266
|
+
const resolver = new vue.CompilerOptionsResolver(ts$1, ts$1.sys.readFile);
|
|
267
|
+
resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
|
|
268
|
+
const vueOptions = resolver.build();
|
|
269
|
+
return vue.createVueLanguagePlugin(ts$1, options.options, vueOptions, (id) => id);
|
|
270
|
+
};
|
|
271
|
+
return {
|
|
272
|
+
proxyCreateProgram,
|
|
273
|
+
getLanguagePlugin
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function initTsMacro() {
|
|
277
|
+
const debug$5 = createDebug("rolldown-plugin-dts:ts-macro");
|
|
278
|
+
debug$5("loading ts-macro language tools");
|
|
274
279
|
try {
|
|
275
280
|
const tsMacroPath = __require.resolve("@ts-macro/tsc");
|
|
276
281
|
const { proxyCreateProgram } = __require(__require.resolve("@volar/typescript", { paths: [tsMacroPath] }));
|
|
@@ -285,13 +290,13 @@ function loadTsMacro() {
|
|
|
285
290
|
getLanguagePlugin
|
|
286
291
|
};
|
|
287
292
|
} catch (error) {
|
|
288
|
-
debug$
|
|
293
|
+
debug$5("ts-macro language tools not found", error);
|
|
289
294
|
throw new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.");
|
|
290
295
|
}
|
|
291
296
|
}
|
|
292
297
|
function createProgramFactory(ts$1, options) {
|
|
293
|
-
const vueLanguageTools = options.vue ?
|
|
294
|
-
const tsMacroLanguageTools = options.tsMacro ?
|
|
298
|
+
const vueLanguageTools = options.vue ? initVueLanguageTools() : void 0;
|
|
299
|
+
const tsMacroLanguageTools = options.tsMacro ? initTsMacro() : void 0;
|
|
295
300
|
const proxyCreateProgram = vueLanguageTools?.proxyCreateProgram || tsMacroLanguageTools?.proxyCreateProgram;
|
|
296
301
|
if (!proxyCreateProgram) return ts$1.createProgram;
|
|
297
302
|
return proxyCreateProgram(ts$1, ts$1.createProgram, (ts$2, options$1) => {
|
|
@@ -340,7 +345,11 @@ function createOrGetTsModule(options) {
|
|
|
340
345
|
function createTsProgram({ entries, id, tsconfig, tsconfigRaw, vue, tsMacro, cwd, context = globalContext }) {
|
|
341
346
|
const fsSystem = createFsSystem(context.files);
|
|
342
347
|
const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
|
|
343
|
-
const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir
|
|
348
|
+
const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir, void 0, void 0, void 0, vue ? [{
|
|
349
|
+
extension: "vue",
|
|
350
|
+
isMixedContent: true,
|
|
351
|
+
scriptKind: ts.ScriptKind.Deferred
|
|
352
|
+
}] : void 0);
|
|
344
353
|
debug$1(`creating program for root project: ${baseDir}`);
|
|
345
354
|
return createTsProgramFromParsedConfig({
|
|
346
355
|
parsedConfig,
|
package/dist/tsc-worker.mjs
CHANGED
package/dist/tsc.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-plugin-dts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.21.
|
|
4
|
+
"version": "0.21.2",
|
|
5
5
|
"description": "A Rolldown plugin to generate and bundle dts files.",
|
|
6
6
|
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -77,20 +77,20 @@
|
|
|
77
77
|
"@sxzz/test-utils": "^0.5.15",
|
|
78
78
|
"@types/babel__generator": "^7.27.0",
|
|
79
79
|
"@types/node": "^25.0.8",
|
|
80
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
80
|
+
"@typescript/native-preview": "7.0.0-dev.20260115.1",
|
|
81
81
|
"@volar/typescript": "^2.4.27",
|
|
82
82
|
"@vue/language-core": "^3.2.2",
|
|
83
83
|
"arktype": "^2.1.29",
|
|
84
84
|
"bumpp": "^10.4.0",
|
|
85
85
|
"diff": "^8.0.3",
|
|
86
86
|
"eslint": "^9.39.2",
|
|
87
|
-
"prettier": "^3.
|
|
87
|
+
"prettier": "^3.8.0",
|
|
88
88
|
"rolldown": "^1.0.0-beta.60",
|
|
89
89
|
"rolldown-plugin-dts-snapshot": "^0.3.2",
|
|
90
90
|
"rolldown-plugin-require-cjs": "^0.3.3",
|
|
91
91
|
"rollup-plugin-dts": "^6.3.0",
|
|
92
92
|
"tinyglobby": "^0.2.15",
|
|
93
|
-
"tsdown": "^0.20.0-beta.
|
|
93
|
+
"tsdown": "^0.20.0-beta.3",
|
|
94
94
|
"typescript": "^5.9.3",
|
|
95
95
|
"vitest": "^4.0.17",
|
|
96
96
|
"vue": "^3.5.26",
|