rolldown-plugin-dts 0.21.5 → 0.21.7
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/{filename-Cqnsj8Gp.mjs → filename-7p2SFN0X.mjs} +1 -1
- package/dist/filename.mjs +1 -1
- package/dist/{index-C8o_kIRC.d.mts → index-DWPGYc3m.d.mts} +1 -1
- package/dist/index.mjs +63 -51
- package/dist/{tsc-DmkHlcNe.mjs → tsc-CITWkGSi.mjs} +26 -26
- package/dist/tsc-context.d.mts +1 -1
- package/dist/tsc-context.mjs +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/package.json +11 -11
- /package/dist/{context-EuY-ImLj.mjs → context-DoVwxr5H.mjs} +0 -0
- /package/dist/{context-CCPZT79j.d.mts → context-Dt8gPoCq.d.mts} +0 -0
- /package/dist/{resolver-CQnlAxJ7.mjs → resolver-o20sdYK5.mjs} +0 -0
|
@@ -11,7 +11,7 @@ function filename_js_to_dts(id) {
|
|
|
11
11
|
return id.replace(RE_JS, ".d.$1ts");
|
|
12
12
|
}
|
|
13
13
|
function filename_to_dts(id) {
|
|
14
|
-
return id.replace(RE_VUE, ".vue.ts").replace(RE_TS, ".d.$1ts").replace(RE_JS, ".d.$1ts").replace(RE_JSON, ".d.ts");
|
|
14
|
+
return id.replace(RE_VUE, ".vue.ts").replace(RE_TS, ".d.$1ts").replace(RE_JS, ".d.$1ts").replace(RE_JSON, ".json.d.ts");
|
|
15
15
|
}
|
|
16
16
|
function filename_dts_to(id, ext) {
|
|
17
17
|
return id.replace(RE_DTS, `.$1${ext}`);
|
package/dist/filename.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as RE_JSON, c as RE_VUE, 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_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-
|
|
1
|
+
import { a as RE_JSON, c as RE_VUE, 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_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-7p2SFN0X.mjs";
|
|
2
2
|
|
|
3
3
|
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as RE_JSON, c as RE_VUE, 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_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-
|
|
2
|
-
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-
|
|
1
|
+
import { a as RE_JSON, c as RE_VUE, 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_TS, t as RE_CSS, u as filename_js_to_dts } from "./filename-7p2SFN0X.mjs";
|
|
2
|
+
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-DoVwxr5H.mjs";
|
|
3
3
|
import { createDebug } from "obug";
|
|
4
4
|
import { generate } from "@babel/generator";
|
|
5
5
|
import { parse } from "@babel/parser";
|
|
@@ -122,14 +122,15 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
122
122
|
const appendStmts = [];
|
|
123
123
|
const namespaceStmts = /* @__PURE__ */ new Map();
|
|
124
124
|
for (const [i, stmt] of program.body.entries()) {
|
|
125
|
-
const setStmt = (stmt
|
|
125
|
+
const setStmt = (stmt) => program.body[i] = stmt;
|
|
126
126
|
if (rewriteImportExport(stmt, setStmt, typeOnlyIds)) continue;
|
|
127
127
|
const sideEffect = stmt.type === "TSModuleDeclaration" && stmt.kind !== "namespace";
|
|
128
|
+
if (sideEffect && stmt.id.type === "StringLiteral" && stmt.id.value[0] === ".") this.warn(`\`declare module ${JSON.stringify(stmt.id.value)}\` will be kept as-is in the output. Relative module declaration may cause unexpected issues. Found in ${id}.`);
|
|
128
129
|
if (sideEffect && id.endsWith(".vue.d.ts") && code.slice(stmt.start, stmt.end).includes("__VLS_")) continue;
|
|
129
130
|
const isDefaultExport = stmt.type === "ExportDefaultDeclaration";
|
|
130
131
|
const isExportDecl = isTypeOf(stmt, ["ExportNamedDeclaration", "ExportDefaultDeclaration"]) && !!stmt.declaration;
|
|
131
132
|
const decl = isExportDecl ? stmt.declaration : stmt;
|
|
132
|
-
const setDecl = isExportDecl ? (decl
|
|
133
|
+
const setDecl = isExportDecl ? (decl) => stmt.declaration = decl : setStmt;
|
|
133
134
|
if (decl.type !== "TSDeclareFunction" && !isDeclarationType(decl)) continue;
|
|
134
135
|
if (isTypeOf(decl, [
|
|
135
136
|
"TSEnumDeclaration",
|
|
@@ -140,10 +141,12 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
140
141
|
"VariableDeclaration"
|
|
141
142
|
])) decl.declare = true;
|
|
142
143
|
const bindings = [];
|
|
143
|
-
if (decl.type === "VariableDeclaration") bindings.push(...decl.declarations.map((decl
|
|
144
|
+
if (decl.type === "VariableDeclaration") bindings.push(...decl.declarations.map((decl) => decl.id));
|
|
144
145
|
else if ("id" in decl && decl.id) {
|
|
145
146
|
let binding = decl.id;
|
|
147
|
+
if (binding.type === "TSQualifiedName") binding = getIdFromTSEntityName(binding);
|
|
146
148
|
binding = sideEffect ? t.identifier(`_${getIdentifierIndex("")}`) : binding;
|
|
149
|
+
if (binding.type !== "Identifier") throw new Error(`Unexpected ${binding.type} declaration id`);
|
|
147
150
|
bindings.push(binding);
|
|
148
151
|
} else {
|
|
149
152
|
const binding = t.identifier("export_default");
|
|
@@ -239,9 +242,9 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
239
242
|
const [declarationIdNode, depsFn, children] = node.declarations[0].init.elements;
|
|
240
243
|
const declarationId = declarationIdNode.value;
|
|
241
244
|
const declaration = getDeclaration(declarationId);
|
|
242
|
-
walkAST(declaration.decl, { enter(node
|
|
243
|
-
if (node
|
|
244
|
-
delete node
|
|
245
|
+
walkAST(declaration.decl, { enter(node) {
|
|
246
|
+
if (node.type === "CommentBlock") return;
|
|
247
|
+
delete node.loc;
|
|
245
248
|
} });
|
|
246
249
|
for (const [i, decl] of node.declarations.entries()) {
|
|
247
250
|
const transformedBinding = {
|
|
@@ -257,8 +260,17 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
257
260
|
for (const originalTypeParam of declaration.params[i].typeParams) originalTypeParam.name = transformedName;
|
|
258
261
|
}
|
|
259
262
|
const transformedDeps = depsFn.body.elements;
|
|
260
|
-
for (const [i, originalDep] of declaration.deps.entries())
|
|
261
|
-
|
|
263
|
+
for (const [i, originalDep] of declaration.deps.entries()) {
|
|
264
|
+
let transformedDep = transformedDeps[i];
|
|
265
|
+
if (transformedDep.type === "UnaryExpression" && transformedDep.operator === "void") transformedDep = {
|
|
266
|
+
...t.identifier("undefined"),
|
|
267
|
+
loc: transformedDep.loc,
|
|
268
|
+
start: transformedDep.start,
|
|
269
|
+
end: transformedDep.end
|
|
270
|
+
};
|
|
271
|
+
if (originalDep.replace) originalDep.replace(transformedDep);
|
|
272
|
+
else Object.assign(originalDep, transformedDep);
|
|
273
|
+
}
|
|
262
274
|
return inheritNodeComments(node, declaration.decl);
|
|
263
275
|
}).filter((node) => !!node);
|
|
264
276
|
if (program.body.length === 0) return "export { };";
|
|
@@ -268,9 +280,9 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
268
280
|
const preserveComments = commentsMap.get(id);
|
|
269
281
|
if (preserveComments) {
|
|
270
282
|
preserveComments.forEach((c) => {
|
|
271
|
-
const id
|
|
272
|
-
if (commentsValue.has(id
|
|
273
|
-
commentsValue.add(id
|
|
283
|
+
const id = c.type + c.value;
|
|
284
|
+
if (commentsValue.has(id)) return;
|
|
285
|
+
commentsValue.add(id);
|
|
274
286
|
comments.add(c);
|
|
275
287
|
});
|
|
276
288
|
commentsMap.delete(id);
|
|
@@ -309,8 +321,8 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
309
321
|
*/
|
|
310
322
|
function collectParams(node) {
|
|
311
323
|
const typeParams = [];
|
|
312
|
-
walkAST(node, { leave(node
|
|
313
|
-
if ("typeParameters" in node
|
|
324
|
+
walkAST(node, { leave(node) {
|
|
325
|
+
if ("typeParameters" in node && node.typeParameters?.type === "TSTypeParameterDeclaration") typeParams.push(...node.typeParameters.params.map((param) => param.name));
|
|
314
326
|
} });
|
|
315
327
|
const paramMap = /* @__PURE__ */ new Map();
|
|
316
328
|
for (const typeParam of typeParams) {
|
|
@@ -319,9 +331,9 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
319
331
|
if (group) group.push(typeParam);
|
|
320
332
|
else paramMap.set(name, [typeParam]);
|
|
321
333
|
}
|
|
322
|
-
return Array.from(paramMap.entries()).map(([name, typeParams
|
|
334
|
+
return Array.from(paramMap.entries()).map(([name, typeParams]) => ({
|
|
323
335
|
name,
|
|
324
|
-
typeParams
|
|
336
|
+
typeParams
|
|
325
337
|
}));
|
|
326
338
|
}
|
|
327
339
|
function collectDependencies(node, namespaceStmts, children) {
|
|
@@ -329,63 +341,63 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
329
341
|
const seen = /* @__PURE__ */ new Set();
|
|
330
342
|
const inferredStack = [];
|
|
331
343
|
let currentInferred = /* @__PURE__ */ new Set();
|
|
332
|
-
function isInferred(node
|
|
333
|
-
return node
|
|
344
|
+
function isInferred(node) {
|
|
345
|
+
return node.type === "Identifier" && currentInferred.has(node.name);
|
|
334
346
|
}
|
|
335
347
|
walkAST(node, {
|
|
336
|
-
enter(node
|
|
337
|
-
if (node
|
|
338
|
-
const inferred = collectInferredNames(node
|
|
348
|
+
enter(node) {
|
|
349
|
+
if (node.type === "TSConditionalType") {
|
|
350
|
+
const inferred = collectInferredNames(node.extendsType);
|
|
339
351
|
inferredStack.push(inferred);
|
|
340
352
|
}
|
|
341
353
|
},
|
|
342
|
-
leave(node
|
|
343
|
-
if (node
|
|
354
|
+
leave(node, parent) {
|
|
355
|
+
if (node.type === "TSConditionalType") inferredStack.pop();
|
|
344
356
|
else if (parent?.type === "TSConditionalType") {
|
|
345
|
-
const trueBranch = parent.trueType === node
|
|
357
|
+
const trueBranch = parent.trueType === node;
|
|
346
358
|
currentInferred = new Set((trueBranch ? inferredStack : inferredStack.slice(0, -1)).flat());
|
|
347
359
|
} else currentInferred = /* @__PURE__ */ new Set();
|
|
348
|
-
if (node
|
|
349
|
-
for (const specifier of node
|
|
350
|
-
} else if (node
|
|
351
|
-
else if (node
|
|
352
|
-
if (node
|
|
353
|
-
if (node
|
|
360
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
361
|
+
for (const specifier of node.specifiers) if (specifier.type === "ExportSpecifier") addDependency(specifier.local);
|
|
362
|
+
} else if (node.type === "TSInterfaceDeclaration" && node.extends) for (const heritage of node.extends || []) addDependency(heritage.expression);
|
|
363
|
+
else if (node.type === "ClassDeclaration") {
|
|
364
|
+
if (node.superClass) addDependency(node.superClass);
|
|
365
|
+
if (node.implements) for (const implement of node.implements) {
|
|
354
366
|
if (implement.type === "ClassImplements") throw new Error("Unexpected Flow syntax");
|
|
355
367
|
addDependency(implement.expression);
|
|
356
368
|
}
|
|
357
|
-
} else if (isTypeOf(node
|
|
369
|
+
} else if (isTypeOf(node, [
|
|
358
370
|
"ObjectMethod",
|
|
359
371
|
"ObjectProperty",
|
|
360
372
|
"ClassProperty",
|
|
361
373
|
"TSPropertySignature",
|
|
362
374
|
"TSDeclareMethod"
|
|
363
375
|
])) {
|
|
364
|
-
if (node
|
|
365
|
-
if ("value" in node
|
|
366
|
-
} else switch (node
|
|
376
|
+
if (node.computed && isReferenceId(node.key)) addDependency(node.key);
|
|
377
|
+
if ("value" in node && isReferenceId(node.value)) addDependency(node.value);
|
|
378
|
+
} else switch (node.type) {
|
|
367
379
|
case "TSTypeReference":
|
|
368
|
-
addDependency(TSEntityNameToRuntime(node
|
|
380
|
+
addDependency(TSEntityNameToRuntime(node.typeName));
|
|
369
381
|
break;
|
|
370
382
|
case "TSTypeQuery":
|
|
371
|
-
if (seen.has(node
|
|
372
|
-
if (node
|
|
373
|
-
addDependency(TSEntityNameToRuntime(node
|
|
383
|
+
if (seen.has(node.exprName)) return;
|
|
384
|
+
if (node.exprName.type === "TSImportType") break;
|
|
385
|
+
addDependency(TSEntityNameToRuntime(node.exprName));
|
|
374
386
|
break;
|
|
375
387
|
case "TSImportType": {
|
|
376
|
-
seen.add(node
|
|
377
|
-
const { source, qualifier } = node
|
|
378
|
-
addDependency(importNamespace(node
|
|
388
|
+
seen.add(node);
|
|
389
|
+
const { source, qualifier } = node;
|
|
390
|
+
addDependency(importNamespace(node, qualifier, source, namespaceStmts));
|
|
379
391
|
break;
|
|
380
392
|
}
|
|
381
393
|
}
|
|
382
|
-
if (parent && !deps.has(node
|
|
394
|
+
if (parent && !deps.has(node) && isChildSymbol(node, parent)) children.add(node);
|
|
383
395
|
}
|
|
384
396
|
});
|
|
385
397
|
return Array.from(deps);
|
|
386
|
-
function addDependency(node
|
|
387
|
-
if (isThisExpression(node
|
|
388
|
-
deps.add(node
|
|
398
|
+
function addDependency(node) {
|
|
399
|
+
if (isThisExpression(node) || isInferred(node)) return;
|
|
400
|
+
deps.add(node);
|
|
389
401
|
}
|
|
390
402
|
}
|
|
391
403
|
function importNamespace(node, imported, source, namespaceStmts) {
|
|
@@ -422,8 +434,8 @@ function isChildSymbol(node, parent) {
|
|
|
422
434
|
}
|
|
423
435
|
function collectInferredNames(node) {
|
|
424
436
|
const inferred = [];
|
|
425
|
-
walkAST(node, { enter(node
|
|
426
|
-
if (node
|
|
437
|
+
walkAST(node, { enter(node) {
|
|
438
|
+
if (node.type === "TSInferType" && node.typeParameter) inferred.push(node.typeParameter.name.name);
|
|
427
439
|
} });
|
|
428
440
|
return inferred;
|
|
429
441
|
}
|
|
@@ -912,8 +924,8 @@ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = f
|
|
|
912
924
|
else if (typeof tsgo === "object" && tsgo.enabled === false) tsgo = false;
|
|
913
925
|
let resolvedTsconfig;
|
|
914
926
|
if (tsconfig === true || tsconfig == null) {
|
|
915
|
-
const { config, path
|
|
916
|
-
tsconfig = path
|
|
927
|
+
const { config, path } = getTsconfig(cwd) || {};
|
|
928
|
+
tsconfig = path;
|
|
917
929
|
resolvedTsconfig = config;
|
|
918
930
|
} else if (typeof tsconfig === "string") {
|
|
919
931
|
tsconfig = path.resolve(cwd || process.cwd(), tsconfig);
|
|
@@ -1034,7 +1046,7 @@ function createDtsResolvePlugin({ cwd, tsconfig, tsconfigRaw, resolver, sideEffe
|
|
|
1034
1046
|
async function resolveDtsPath(id, importer, rolldownResolution) {
|
|
1035
1047
|
let dtsPath;
|
|
1036
1048
|
if (resolver === "tsc") {
|
|
1037
|
-
const { tscResolve } = await import("./resolver-
|
|
1049
|
+
const { tscResolve } = await import("./resolver-o20sdYK5.mjs");
|
|
1038
1050
|
dtsPath = tscResolve(id, importer, cwd, tsconfig, tsconfigRaw);
|
|
1039
1051
|
} else dtsPath = baseDtsResolver(id, importer);
|
|
1040
1052
|
debug$1("Using %s for dts import: %O -> %O", resolver, id, dtsPath);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const __cjs_require = globalThis.process.getBuiltinModule("module").createRequire(import.meta.url);
|
|
2
|
-
import { n as RE_DTS, r as RE_DTS_MAP } from "./filename-
|
|
3
|
-
import { n as globalContext } from "./context-
|
|
2
|
+
import { n as RE_DTS, r as RE_DTS_MAP } from "./filename-7p2SFN0X.mjs";
|
|
3
|
+
import { n as globalContext } from "./context-DoVwxr5H.mjs";
|
|
4
4
|
const {
|
|
5
5
|
createRequire
|
|
6
6
|
} = globalThis.process.getBuiltinModule("node:module");
|
|
@@ -27,12 +27,12 @@ function createFsSystem(files) {
|
|
|
27
27
|
write(message) {
|
|
28
28
|
debug$4(message);
|
|
29
29
|
},
|
|
30
|
-
resolvePath(path
|
|
31
|
-
if (files.has(path
|
|
32
|
-
return ts.sys.resolvePath(path
|
|
30
|
+
resolvePath(path) {
|
|
31
|
+
if (files.has(path)) return path;
|
|
32
|
+
return ts.sys.resolvePath(path);
|
|
33
33
|
},
|
|
34
34
|
directoryExists(directory) {
|
|
35
|
-
if (Array.from(files.keys()).some((path
|
|
35
|
+
if (Array.from(files.keys()).some((path) => path.startsWith(directory))) return true;
|
|
36
36
|
return ts.sys.directoryExists(directory);
|
|
37
37
|
},
|
|
38
38
|
fileExists(fileName) {
|
|
@@ -43,9 +43,9 @@ function createFsSystem(files) {
|
|
|
43
43
|
if (files.has(fileName)) return files.get(fileName);
|
|
44
44
|
return ts.sys.readFile(fileName, ...args);
|
|
45
45
|
},
|
|
46
|
-
writeFile(path
|
|
47
|
-
files.set(path
|
|
48
|
-
ts.sys.writeFile(path
|
|
46
|
+
writeFile(path, data, ...args) {
|
|
47
|
+
files.set(path, data);
|
|
48
|
+
ts.sys.writeFile(path, data, ...args);
|
|
49
49
|
},
|
|
50
50
|
deleteFile(fileName, ...args) {
|
|
51
51
|
files.delete(fileName);
|
|
@@ -56,8 +56,8 @@ function createFsSystem(files) {
|
|
|
56
56
|
function createMemorySystem(files) {
|
|
57
57
|
return {
|
|
58
58
|
...createFsSystem(files),
|
|
59
|
-
writeFile(path
|
|
60
|
-
files.set(path
|
|
59
|
+
writeFile(path, data) {
|
|
60
|
+
files.set(path, data);
|
|
61
61
|
},
|
|
62
62
|
deleteFile(fileName) {
|
|
63
63
|
files.delete(fileName);
|
|
@@ -260,13 +260,13 @@ function loadVueLanguageTools() {
|
|
|
260
260
|
}
|
|
261
261
|
function initVueLanguageTools() {
|
|
262
262
|
const { vue, volarTs: { proxyCreateProgram } } = loadVueLanguageTools();
|
|
263
|
-
const getLanguagePlugin = (ts
|
|
263
|
+
const getLanguagePlugin = (ts, options) => {
|
|
264
264
|
const $rootDir = options.options.$rootDir;
|
|
265
265
|
const $configRaw = options.options.$configRaw;
|
|
266
|
-
const resolver = new vue.CompilerOptionsResolver(ts
|
|
266
|
+
const resolver = new vue.CompilerOptionsResolver(ts, ts.sys.readFile);
|
|
267
267
|
resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
|
|
268
268
|
const vueOptions = resolver.build();
|
|
269
|
-
return vue.createVueLanguagePlugin(ts
|
|
269
|
+
return vue.createVueLanguagePlugin(ts, options.options, vueOptions, (id) => id);
|
|
270
270
|
};
|
|
271
271
|
return {
|
|
272
272
|
proxyCreateProgram,
|
|
@@ -274,35 +274,35 @@ function initVueLanguageTools() {
|
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
276
|
function initTsMacro() {
|
|
277
|
-
const debug
|
|
278
|
-
debug
|
|
277
|
+
const debug = createDebug("rolldown-plugin-dts:ts-macro");
|
|
278
|
+
debug("loading ts-macro language tools");
|
|
279
279
|
try {
|
|
280
280
|
const tsMacroPath = __require.resolve("@ts-macro/tsc");
|
|
281
281
|
const { proxyCreateProgram } = __require(__require.resolve("@volar/typescript", { paths: [tsMacroPath] }));
|
|
282
282
|
const tsMacro = __require(__require.resolve("@ts-macro/language-plugin", { paths: [tsMacroPath] }));
|
|
283
283
|
const { getOptions } = __require(__require.resolve("@ts-macro/language-plugin/options", { paths: [tsMacroPath] }));
|
|
284
|
-
const getLanguagePlugin = (ts
|
|
284
|
+
const getLanguagePlugin = (ts, options) => {
|
|
285
285
|
const $rootDir = options.options.$rootDir;
|
|
286
|
-
return tsMacro.getLanguagePlugins(ts
|
|
286
|
+
return tsMacro.getLanguagePlugins(ts, options.options, getOptions(ts, $rootDir))[0];
|
|
287
287
|
};
|
|
288
288
|
return {
|
|
289
289
|
proxyCreateProgram,
|
|
290
290
|
getLanguagePlugin
|
|
291
291
|
};
|
|
292
292
|
} catch (error) {
|
|
293
|
-
debug
|
|
293
|
+
debug("ts-macro language tools not found", error);
|
|
294
294
|
throw new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.");
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
function createProgramFactory(ts
|
|
297
|
+
function createProgramFactory(ts, options) {
|
|
298
298
|
const vueLanguageTools = options.vue ? initVueLanguageTools() : void 0;
|
|
299
299
|
const tsMacroLanguageTools = options.tsMacro ? initTsMacro() : void 0;
|
|
300
300
|
const proxyCreateProgram = vueLanguageTools?.proxyCreateProgram || tsMacroLanguageTools?.proxyCreateProgram;
|
|
301
|
-
if (!proxyCreateProgram) return ts
|
|
302
|
-
return proxyCreateProgram(ts
|
|
301
|
+
if (!proxyCreateProgram) return ts.createProgram;
|
|
302
|
+
return proxyCreateProgram(ts, ts.createProgram, (ts, options) => {
|
|
303
303
|
const languagePlugins = [];
|
|
304
|
-
if (vueLanguageTools) languagePlugins.push(vueLanguageTools.getLanguagePlugin(ts
|
|
305
|
-
if (tsMacroLanguageTools) languagePlugins.push(tsMacroLanguageTools.getLanguagePlugin(ts
|
|
304
|
+
if (vueLanguageTools) languagePlugins.push(vueLanguageTools.getLanguagePlugin(ts, options));
|
|
305
|
+
if (tsMacroLanguageTools) languagePlugins.push(tsMacroLanguageTools.getLanguagePlugin(ts, options));
|
|
306
306
|
return { languagePlugins };
|
|
307
307
|
});
|
|
308
308
|
}
|
|
@@ -324,8 +324,8 @@ const defaultCompilerOptions = {
|
|
|
324
324
|
};
|
|
325
325
|
function createOrGetTsModule(options) {
|
|
326
326
|
const { id, entries, context = globalContext } = options;
|
|
327
|
-
const program = context.programs.find((program
|
|
328
|
-
const roots = program
|
|
327
|
+
const program = context.programs.find((program) => {
|
|
328
|
+
const roots = program.getRootFileNames();
|
|
329
329
|
if (entries) return entries.every((entry) => roots.includes(entry));
|
|
330
330
|
return roots.includes(id);
|
|
331
331
|
});
|
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-Dt8gPoCq.mjs";
|
|
2
2
|
export { ParsedProject, SourceFileToProjectMap, TscContext, createContext, globalContext, invalidateContextFile };
|
package/dist/tsc-context.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-
|
|
1
|
+
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-DoVwxr5H.mjs";
|
|
2
2
|
|
|
3
3
|
export { 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-DWPGYc3m.mjs";
|
|
2
2
|
export { TscModule, TscOptions, TscResult, tscEmit };
|
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.7",
|
|
5
5
|
"description": "A Rolldown plugin to generate and bundle dts files.",
|
|
6
6
|
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -73,31 +73,31 @@
|
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@jridgewell/source-map": "^0.3.11",
|
|
76
|
-
"@sxzz/eslint-config": "^7.5.
|
|
76
|
+
"@sxzz/eslint-config": "^7.5.1",
|
|
77
77
|
"@sxzz/prettier-config": "^2.2.6",
|
|
78
78
|
"@sxzz/test-utils": "^0.5.15",
|
|
79
|
-
"@types/node": "^25.0.
|
|
80
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
79
|
+
"@types/node": "^25.0.10",
|
|
80
|
+
"@typescript/native-preview": "7.0.0-dev.20260126.1",
|
|
81
81
|
"@volar/typescript": "^2.4.27",
|
|
82
|
-
"@vue/language-core": "^3.2.
|
|
82
|
+
"@vue/language-core": "^3.2.4",
|
|
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.8.
|
|
88
|
-
"rolldown": "^1.0.0-
|
|
87
|
+
"prettier": "^3.8.1",
|
|
88
|
+
"rolldown": "^1.0.0-rc.1",
|
|
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.
|
|
93
|
+
"tsdown": "^0.20.1",
|
|
94
94
|
"typescript": "^5.9.3",
|
|
95
|
-
"vitest": "^4.0.
|
|
95
|
+
"vitest": "^4.0.18",
|
|
96
96
|
"vue": "^3.5.27",
|
|
97
|
-
"vue-tsc": "^3.2.
|
|
97
|
+
"vue-tsc": "^3.2.4"
|
|
98
98
|
},
|
|
99
99
|
"resolutions": {
|
|
100
|
-
"rolldown": "^1.0.0-
|
|
100
|
+
"rolldown": "^1.0.0-rc.1"
|
|
101
101
|
},
|
|
102
102
|
"prettier": "@sxzz/prettier-config",
|
|
103
103
|
"scripts": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|