rolldown-plugin-dts 0.21.2 → 0.21.3
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 +1 -1
- package/dist/index.d.mts +20 -2
- package/dist/index.mjs +100 -67
- package/package.json +8 -8
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -162,18 +162,36 @@ interface Options extends GeneralOptions, TscOptions {
|
|
|
162
162
|
/**
|
|
163
163
|
* **[Experimental]** Enables DTS generation using `tsgo`.
|
|
164
164
|
*
|
|
165
|
-
* To use this option, make sure `@typescript/native-preview` is installed as a dependency
|
|
165
|
+
* To use this option, make sure `@typescript/native-preview` is installed as a dependency,
|
|
166
|
+
* or provide a custom path to the `tsgo` binary using the `path` option.
|
|
166
167
|
*
|
|
167
168
|
* **Note:** This option is not yet recommended for production environments.
|
|
168
169
|
* `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
|
|
170
|
+
*
|
|
171
|
+
*
|
|
172
|
+
* ```ts
|
|
173
|
+
* // Use tsgo from `@typescript/native-preview` dependency
|
|
174
|
+
* tsgo: true
|
|
175
|
+
*
|
|
176
|
+
* // Use custom tsgo path (e.g., managed by Nix)
|
|
177
|
+
* tsgo: { path: '/path/to/tsgo' }
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
tsgo?: boolean | TsgoOptions;
|
|
181
|
+
}
|
|
182
|
+
interface TsgoOptions {
|
|
183
|
+
enabled?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Custom path to the `tsgo` binary.
|
|
169
186
|
*/
|
|
170
|
-
|
|
187
|
+
path?: string;
|
|
171
188
|
}
|
|
172
189
|
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
173
190
|
type OptionsResolved = Overwrite<Required<Omit<Options, "compilerOptions">>, {
|
|
174
191
|
tsconfig?: string;
|
|
175
192
|
oxc: IsolatedDeclarationsOptions | false;
|
|
176
193
|
tsconfigRaw: TsConfigJson;
|
|
194
|
+
tsgo: Omit<TsgoOptions, "enabled"> | false;
|
|
177
195
|
}>;
|
|
178
196
|
declare function resolveOptions({
|
|
179
197
|
cwd,
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
const __cjs_require = globalThis.process.getBuiltinModule("module").createRequire(import.meta.url);
|
|
2
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-Cqnsj8Gp.mjs";
|
|
3
2
|
import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-EuY-ImLj.mjs";
|
|
4
3
|
import { createDebug } from "obug";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
parse
|
|
10
|
-
} = __cjs_require("@babel/parser");
|
|
11
|
-
const t = __cjs_require("@babel/types");
|
|
4
|
+
import { generate } from "@babel/generator";
|
|
5
|
+
import { parse } from "@babel/parser";
|
|
6
|
+
import * as t from "@babel/types";
|
|
12
7
|
import { isDeclarationType, isIdentifierOf, isTypeOf, resolveString, walkAST } from "ast-kit";
|
|
13
8
|
const {
|
|
14
9
|
fork,
|
|
@@ -69,9 +64,9 @@ function createDtsInputPlugin({ sideEffects }) {
|
|
|
69
64
|
//#endregion
|
|
70
65
|
//#region src/fake-js.ts
|
|
71
66
|
function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
72
|
-
let
|
|
67
|
+
let declarationIdx = 0;
|
|
73
68
|
const identifierMap = Object.create(null);
|
|
74
|
-
const
|
|
69
|
+
const declarationMap = /* @__PURE__ */ new Map();
|
|
75
70
|
const commentsMap = /* @__PURE__ */ new Map();
|
|
76
71
|
const typeOnlyMap = /* @__PURE__ */ new Map();
|
|
77
72
|
return {
|
|
@@ -131,9 +126,9 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
131
126
|
const sideEffect = stmt.type === "TSModuleDeclaration" && stmt.kind !== "namespace";
|
|
132
127
|
if (sideEffect && id.endsWith(".vue.d.ts") && code.slice(stmt.start, stmt.end).includes("__VLS_")) continue;
|
|
133
128
|
const isDefaultExport = stmt.type === "ExportDefaultDeclaration";
|
|
134
|
-
const
|
|
135
|
-
const decl =
|
|
136
|
-
const setDecl =
|
|
129
|
+
const isExportDecl = isTypeOf(stmt, ["ExportNamedDeclaration", "ExportDefaultDeclaration"]) && !!stmt.declaration;
|
|
130
|
+
const decl = isExportDecl ? stmt.declaration : stmt;
|
|
131
|
+
const setDecl = isExportDecl ? (decl$1) => stmt.declaration = decl$1 : setStmt;
|
|
137
132
|
if (decl.type !== "TSDeclareFunction" && !isDeclarationType(decl)) continue;
|
|
138
133
|
if (isTypeOf(decl, [
|
|
139
134
|
"TSEnumDeclaration",
|
|
@@ -155,22 +150,33 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
155
150
|
decl.id = binding;
|
|
156
151
|
}
|
|
157
152
|
const params = collectParams(decl);
|
|
158
|
-
const
|
|
153
|
+
const childrenSet = /* @__PURE__ */ new Set();
|
|
154
|
+
const deps = collectDependencies(decl, namespaceStmts, childrenSet);
|
|
155
|
+
const children = Array.from(childrenSet).filter((child) => bindings.every((b) => child !== b));
|
|
159
156
|
if (decl !== stmt) decl.leadingComments = stmt.leadingComments;
|
|
160
|
-
const
|
|
157
|
+
const declarationId = registerDeclaration({
|
|
161
158
|
decl,
|
|
162
159
|
deps,
|
|
163
160
|
bindings,
|
|
164
|
-
params
|
|
161
|
+
params,
|
|
162
|
+
children
|
|
165
163
|
});
|
|
166
|
-
const
|
|
164
|
+
const declarationIdNode = t.numericLiteral(declarationId);
|
|
167
165
|
const depsNode = t.arrowFunctionExpression(params.map(({ name }) => t.identifier(name)), t.arrayExpression(deps));
|
|
166
|
+
const childrenNode = t.arrayExpression(children.map((node) => ({
|
|
167
|
+
type: "StringLiteral",
|
|
168
|
+
value: "",
|
|
169
|
+
start: node.start,
|
|
170
|
+
end: node.end,
|
|
171
|
+
loc: node.loc
|
|
172
|
+
})));
|
|
168
173
|
const sideEffectNode = sideEffect && t.callExpression(t.identifier("sideEffect"), [bindings[0]]);
|
|
169
|
-
const runtimeArrayNode = runtimeBindingArrayExpression(
|
|
170
|
-
|
|
174
|
+
const runtimeArrayNode = runtimeBindingArrayExpression([
|
|
175
|
+
declarationIdNode,
|
|
171
176
|
depsNode,
|
|
172
|
-
|
|
173
|
-
|
|
177
|
+
childrenNode,
|
|
178
|
+
...sideEffectNode ? [sideEffectNode] : []
|
|
179
|
+
]);
|
|
174
180
|
const runtimeAssignment = {
|
|
175
181
|
type: "VariableDeclaration",
|
|
176
182
|
kind: "var",
|
|
@@ -201,11 +207,15 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
201
207
|
...appendStmts
|
|
202
208
|
];
|
|
203
209
|
typeOnlyMap.set(id, typeOnlyIds);
|
|
204
|
-
|
|
210
|
+
const result = generate(file, {
|
|
205
211
|
comments: false,
|
|
206
212
|
sourceMaps: sourcemap,
|
|
207
213
|
sourceFileName: id
|
|
208
214
|
});
|
|
215
|
+
return {
|
|
216
|
+
code: result.code,
|
|
217
|
+
map: result.map
|
|
218
|
+
};
|
|
209
219
|
}
|
|
210
220
|
function renderChunk(code, chunk) {
|
|
211
221
|
if (!RE_DTS.test(chunk.fileName)) return;
|
|
@@ -225,31 +235,29 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
225
235
|
if (newNode || newNode === false) return newNode;
|
|
226
236
|
if (node.type !== "VariableDeclaration") return node;
|
|
227
237
|
if (!isRuntimeBindingVariableDeclaration(node)) return null;
|
|
228
|
-
const [
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
walkAST(
|
|
238
|
+
const [declarationIdNode, depsFn, children] = node.declarations[0].init.elements;
|
|
239
|
+
const declarationId = declarationIdNode.value;
|
|
240
|
+
const declaration = getDeclaration(declarationId);
|
|
241
|
+
walkAST(declaration.decl, { enter(node$1) {
|
|
232
242
|
delete node$1.loc;
|
|
233
243
|
} });
|
|
234
244
|
for (const [i, decl] of node.declarations.entries()) {
|
|
235
245
|
const transformedBinding = {
|
|
236
246
|
...decl.id,
|
|
237
|
-
typeAnnotation:
|
|
247
|
+
typeAnnotation: declaration.bindings[i].typeAnnotation
|
|
238
248
|
};
|
|
239
|
-
overwriteNode(
|
|
249
|
+
overwriteNode(declaration.bindings[i], transformedBinding);
|
|
240
250
|
}
|
|
251
|
+
for (const [i, child] of children.elements.entries()) Object.assign(declaration.children[i], { loc: child.loc });
|
|
241
252
|
const transformedParams = depsFn.params;
|
|
242
253
|
for (const [i, transformedParam] of transformedParams.entries()) {
|
|
243
254
|
const transformedName = transformedParam.name;
|
|
244
|
-
for (const originalTypeParam of
|
|
255
|
+
for (const originalTypeParam of declaration.params[i].typeParams) originalTypeParam.name = transformedName;
|
|
245
256
|
}
|
|
246
257
|
const transformedDeps = depsFn.body.elements;
|
|
247
|
-
for (
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
else Object.assign(originalDep, transformedDeps[i]);
|
|
251
|
-
}
|
|
252
|
-
return inheritNodeComments(node, original.decl);
|
|
258
|
+
for (const [i, originalDep] of declaration.deps.entries()) if (originalDep.replace) originalDep.replace(transformedDeps[i]);
|
|
259
|
+
else Object.assign(originalDep, transformedDeps[i]);
|
|
260
|
+
return inheritNodeComments(node, declaration.decl);
|
|
253
261
|
}).filter((node) => !!node);
|
|
254
262
|
if (program.body.length === 0) return "export { };";
|
|
255
263
|
const comments = /* @__PURE__ */ new Set();
|
|
@@ -270,23 +278,27 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
270
278
|
program.body[0].leadingComments ||= [];
|
|
271
279
|
program.body[0].leadingComments.unshift(...comments);
|
|
272
280
|
}
|
|
273
|
-
|
|
281
|
+
const result = generate(file, {
|
|
274
282
|
comments: true,
|
|
275
283
|
sourceMaps: sourcemap,
|
|
276
284
|
sourceFileName: chunk.fileName
|
|
277
285
|
});
|
|
286
|
+
return {
|
|
287
|
+
code: result.code,
|
|
288
|
+
map: result.map
|
|
289
|
+
};
|
|
278
290
|
}
|
|
279
291
|
function getIdentifierIndex(name) {
|
|
280
292
|
if (name in identifierMap) return identifierMap[name]++;
|
|
281
293
|
return identifierMap[name] = 0;
|
|
282
294
|
}
|
|
283
|
-
function
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
return
|
|
295
|
+
function registerDeclaration(info) {
|
|
296
|
+
const declarationId = declarationIdx++;
|
|
297
|
+
declarationMap.set(declarationId, info);
|
|
298
|
+
return declarationId;
|
|
287
299
|
}
|
|
288
|
-
function
|
|
289
|
-
return
|
|
300
|
+
function getDeclaration(declarationId) {
|
|
301
|
+
return declarationMap.get(declarationId);
|
|
290
302
|
}
|
|
291
303
|
/**
|
|
292
304
|
* Collects all TSTypeParameter nodes from the given node and groups them by
|
|
@@ -297,7 +309,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
297
309
|
function collectParams(node) {
|
|
298
310
|
const typeParams = [];
|
|
299
311
|
walkAST(node, { leave(node$1) {
|
|
300
|
-
if ("typeParameters" in node$1 && node$1.typeParameters?.type === "TSTypeParameterDeclaration") typeParams.push(...node$1.typeParameters.params);
|
|
312
|
+
if ("typeParameters" in node$1 && node$1.typeParameters?.type === "TSTypeParameterDeclaration") typeParams.push(...node$1.typeParameters.params.map((param) => param.name));
|
|
301
313
|
} });
|
|
302
314
|
const paramMap = /* @__PURE__ */ new Map();
|
|
303
315
|
for (const typeParam of typeParams) {
|
|
@@ -311,7 +323,7 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
311
323
|
typeParams: typeParams$1
|
|
312
324
|
}));
|
|
313
325
|
}
|
|
314
|
-
function collectDependencies(node, namespaceStmts) {
|
|
326
|
+
function collectDependencies(node, namespaceStmts, children) {
|
|
315
327
|
const deps = /* @__PURE__ */ new Set();
|
|
316
328
|
const seen = /* @__PURE__ */ new Set();
|
|
317
329
|
const inferredStack = [];
|
|
@@ -334,10 +346,13 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
334
346
|
} else currentInferred = /* @__PURE__ */ new Set();
|
|
335
347
|
if (node$1.type === "ExportNamedDeclaration") {
|
|
336
348
|
for (const specifier of node$1.specifiers) if (specifier.type === "ExportSpecifier") addDependency(specifier.local);
|
|
337
|
-
} else if (node$1.type === "TSInterfaceDeclaration" && node$1.extends) for (const heritage of node$1.extends || []) addDependency(
|
|
349
|
+
} else if (node$1.type === "TSInterfaceDeclaration" && node$1.extends) for (const heritage of node$1.extends || []) addDependency(heritage.expression);
|
|
338
350
|
else if (node$1.type === "ClassDeclaration") {
|
|
339
351
|
if (node$1.superClass) addDependency(node$1.superClass);
|
|
340
|
-
if (node$1.implements) for (const implement of node$1.implements)
|
|
352
|
+
if (node$1.implements) for (const implement of node$1.implements) {
|
|
353
|
+
if (implement.type === "ClassImplements") throw new Error("Unexpected Flow syntax");
|
|
354
|
+
addDependency(implement.expression);
|
|
355
|
+
}
|
|
341
356
|
} else if (isTypeOf(node$1, [
|
|
342
357
|
"ObjectMethod",
|
|
343
358
|
"ObjectProperty",
|
|
@@ -358,12 +373,12 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
358
373
|
break;
|
|
359
374
|
case "TSImportType": {
|
|
360
375
|
seen.add(node$1);
|
|
361
|
-
const source = node$1
|
|
362
|
-
|
|
363
|
-
addDependency(importNamespace(node$1, imported, source, namespaceStmts));
|
|
376
|
+
const { source, qualifier } = node$1;
|
|
377
|
+
addDependency(importNamespace(node$1, qualifier, source, namespaceStmts));
|
|
364
378
|
break;
|
|
365
379
|
}
|
|
366
380
|
}
|
|
381
|
+
if (parent && !deps.has(node$1) && isChildSymbol(node$1, parent)) children.add(node$1);
|
|
367
382
|
}
|
|
368
383
|
});
|
|
369
384
|
return Array.from(deps);
|
|
@@ -382,12 +397,13 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
382
397
|
});
|
|
383
398
|
if (imported) {
|
|
384
399
|
const importedLeft = getIdFromTSEntityName(imported);
|
|
400
|
+
if (imported.type === "ThisExpression" || importedLeft.type === "ThisExpression") throw new Error("Cannot import `this` from module.");
|
|
385
401
|
overwriteNode(importedLeft, t.tsQualifiedName(local, { ...importedLeft }));
|
|
386
402
|
local = imported;
|
|
387
403
|
}
|
|
388
404
|
let replacement = node;
|
|
389
|
-
if (node.
|
|
390
|
-
overwriteNode(node, t.tsTypeReference(local, node.
|
|
405
|
+
if (node.typeArguments) {
|
|
406
|
+
overwriteNode(node, t.tsTypeReference(local, node.typeArguments));
|
|
391
407
|
replacement = local;
|
|
392
408
|
} else overwriteNode(node, local);
|
|
393
409
|
return {
|
|
@@ -398,10 +414,15 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
|
|
|
398
414
|
};
|
|
399
415
|
}
|
|
400
416
|
}
|
|
417
|
+
function isChildSymbol(node, parent) {
|
|
418
|
+
if (node.type === "Identifier") return true;
|
|
419
|
+
if (isTypeOf(parent, ["TSPropertySignature", "TSMethodSignature"]) && parent.key === node) return true;
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
401
422
|
function collectInferredNames(node) {
|
|
402
423
|
const inferred = [];
|
|
403
424
|
walkAST(node, { enter(node$1) {
|
|
404
|
-
if (node$1.type === "TSInferType" && node$1.typeParameter) inferred.push(node$1.typeParameter.name);
|
|
425
|
+
if (node$1.type === "TSInferType" && node$1.typeParameter) inferred.push(node$1.typeParameter.name.name);
|
|
405
426
|
} });
|
|
406
427
|
return inferred;
|
|
407
428
|
}
|
|
@@ -413,34 +434,34 @@ function collectReferenceDirectives(comment, negative = false) {
|
|
|
413
434
|
* Check if the given node is a {@link RuntimeBindingVariableDeclration}
|
|
414
435
|
*/
|
|
415
436
|
function isRuntimeBindingVariableDeclaration(node) {
|
|
416
|
-
return
|
|
437
|
+
return node?.type === "VariableDeclaration" && node.declarations.length > 0 && node.declarations[0].type === "VariableDeclarator" && isRuntimeBindingArrayExpression(node.declarations[0].init);
|
|
417
438
|
}
|
|
418
439
|
/**
|
|
419
440
|
* Check if the given node is a {@link RuntimeBindingArrayExpression}
|
|
420
441
|
*/
|
|
421
442
|
function isRuntimeBindingArrayExpression(node) {
|
|
422
|
-
return
|
|
423
|
-
}
|
|
424
|
-
function runtimeBindingArrayExpression(elements) {
|
|
425
|
-
return t.arrayExpression(elements);
|
|
443
|
+
return node?.type === "ArrayExpression" && isRuntimeBindingArrayElements(node.elements);
|
|
426
444
|
}
|
|
427
445
|
/**
|
|
428
446
|
* Check if the given array is a {@link RuntimeBindingArrayElements}
|
|
429
447
|
*/
|
|
430
448
|
function isRuntimeBindingArrayElements(elements) {
|
|
431
|
-
const [
|
|
432
|
-
return
|
|
449
|
+
const [declarationId, deps, children, effect] = elements;
|
|
450
|
+
return declarationId?.type === "NumericLiteral" && deps?.type === "ArrowFunctionExpression" && children?.type === "ArrayExpression" && (!effect || effect.type === "CallExpression");
|
|
451
|
+
}
|
|
452
|
+
function runtimeBindingArrayExpression(elements) {
|
|
453
|
+
return t.arrayExpression(elements);
|
|
433
454
|
}
|
|
434
455
|
function isThisExpression(node) {
|
|
435
|
-
return isIdentifierOf(node, "this") || node.type === "MemberExpression" && isThisExpression(node.object);
|
|
456
|
+
return isIdentifierOf(node, "this") || node.type === "ThisExpression" || node.type === "MemberExpression" && isThisExpression(node.object);
|
|
436
457
|
}
|
|
437
458
|
function TSEntityNameToRuntime(node) {
|
|
438
|
-
if (node.type === "Identifier") return node;
|
|
459
|
+
if (node.type === "Identifier" || node.type === "ThisExpression") return node;
|
|
439
460
|
const left = TSEntityNameToRuntime(node.left);
|
|
440
461
|
return Object.assign(node, t.memberExpression(left, node.right));
|
|
441
462
|
}
|
|
442
463
|
function getIdFromTSEntityName(node) {
|
|
443
|
-
if (node.type === "Identifier") return node;
|
|
464
|
+
if (node.type === "Identifier" || node.type === "ThisExpression") return node;
|
|
444
465
|
return getIdFromTSEntityName(node.left);
|
|
445
466
|
}
|
|
446
467
|
function isReferenceId(node) {
|
|
@@ -612,11 +633,21 @@ const spawnAsync = (...args) => new Promise((resolve, reject) => {
|
|
|
612
633
|
child.on("close", () => resolve());
|
|
613
634
|
child.on("error", (error) => reject(error));
|
|
614
635
|
});
|
|
615
|
-
async function
|
|
616
|
-
debug$3("[tsgo] rootDir", rootDir);
|
|
636
|
+
async function getTsgoPathFromNodeModules() {
|
|
617
637
|
const tsgoPkg = import.meta.resolve("@typescript/native-preview/package.json");
|
|
618
638
|
const { default: getExePath } = await import(new URL("lib/getExePath.js", tsgoPkg).href);
|
|
619
|
-
|
|
639
|
+
return getExePath();
|
|
640
|
+
}
|
|
641
|
+
async function runTsgo(rootDir, tsconfig, sourcemap, tsgoPath) {
|
|
642
|
+
debug$3("[tsgo] rootDir", rootDir);
|
|
643
|
+
let tsgo;
|
|
644
|
+
if (tsgoPath) {
|
|
645
|
+
tsgo = tsgoPath;
|
|
646
|
+
debug$3("[tsgo] using custom path", tsgo);
|
|
647
|
+
} else {
|
|
648
|
+
tsgo = await getTsgoPathFromNodeModules();
|
|
649
|
+
debug$3("[tsgo] using tsgo from node_modules", tsgo);
|
|
650
|
+
}
|
|
620
651
|
const tsgoDist = await mkdtemp(path.join(tmpdir(), "rolldown-plugin-dts-"));
|
|
621
652
|
debug$3("[tsgo] tsgoDist", tsgoDist);
|
|
622
653
|
const args = [
|
|
@@ -662,7 +693,7 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd,
|
|
|
662
693
|
return {
|
|
663
694
|
name: "rolldown-plugin-dts:generate",
|
|
664
695
|
async buildStart(options) {
|
|
665
|
-
if (tsgo) tsgoDist = await runTsgo(rootDir, tsconfig, sourcemap);
|
|
696
|
+
if (tsgo) tsgoDist = await runTsgo(rootDir, tsconfig, sourcemap, tsgo.path);
|
|
666
697
|
else if (!oxc) if (parallel) {
|
|
667
698
|
childProcess = fork(new URL(WORKER_URL, import.meta.url), { stdio: "inherit" });
|
|
668
699
|
rpc = (await import("birpc")).createBirpc({}, {
|
|
@@ -800,7 +831,7 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd,
|
|
|
800
831
|
dtsCode = result.code;
|
|
801
832
|
map = result.map;
|
|
802
833
|
if (dtsCode && RE_JSON.test(id)) if (dtsCode.includes("declare const _exports")) {
|
|
803
|
-
if (dtsCode.includes("declare const _exports: {")) {
|
|
834
|
+
if (dtsCode.includes("declare const _exports: {") && !dtsCode.includes("\n}[];")) {
|
|
804
835
|
const exports = collectJsonExports(dtsCode);
|
|
805
836
|
let i = 0;
|
|
806
837
|
dtsCode += exports.map((e) => {
|
|
@@ -876,6 +907,8 @@ function collectJsonExports(code) {
|
|
|
876
907
|
//#region src/options.ts
|
|
877
908
|
let warnedTsgo = false;
|
|
878
909
|
function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = false, tsconfig, tsconfigRaw: overriddenTsconfigRaw = {}, compilerOptions = {}, sourcemap, resolver = "oxc", cjsDefault = false, sideEffects = false, build = false, incremental = false, vue = false, tsMacro = false, parallel = false, eager = false, newContext = false, emitJs, oxc, tsgo = false }) {
|
|
910
|
+
if (tsgo === true) tsgo = {};
|
|
911
|
+
else if (typeof tsgo === "object" && tsgo.enabled === false) tsgo = false;
|
|
879
912
|
let resolvedTsconfig;
|
|
880
913
|
if (tsconfig === true || tsconfig == null) {
|
|
881
914
|
const { config, path: path$1 } = getTsconfig(cwd) || {};
|
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.3",
|
|
5
5
|
"description": "A Rolldown plugin to generate and bundle dts files.",
|
|
6
6
|
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -62,22 +62,22 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@babel/generator": "
|
|
66
|
-
"@babel/parser": "
|
|
67
|
-
"@babel/types": "
|
|
68
|
-
"ast-kit": "^
|
|
65
|
+
"@babel/generator": "8.0.0-beta.4",
|
|
66
|
+
"@babel/parser": "8.0.0-beta.4",
|
|
67
|
+
"@babel/types": "8.0.0-beta.4",
|
|
68
|
+
"ast-kit": "^3.0.0-beta.1",
|
|
69
69
|
"birpc": "^4.0.0",
|
|
70
70
|
"dts-resolver": "^2.1.3",
|
|
71
71
|
"get-tsconfig": "^4.13.0",
|
|
72
72
|
"obug": "^2.1.1"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
+
"@jridgewell/source-map": "^0.3.11",
|
|
75
76
|
"@sxzz/eslint-config": "^7.4.5",
|
|
76
77
|
"@sxzz/prettier-config": "^2.2.6",
|
|
77
78
|
"@sxzz/test-utils": "^0.5.15",
|
|
78
|
-
"@types/
|
|
79
|
-
"@
|
|
80
|
-
"@typescript/native-preview": "7.0.0-dev.20260115.1",
|
|
79
|
+
"@types/node": "^25.0.9",
|
|
80
|
+
"@typescript/native-preview": "7.0.0-dev.20260118.1",
|
|
81
81
|
"@volar/typescript": "^2.4.27",
|
|
82
82
|
"@vue/language-core": "^3.2.2",
|
|
83
83
|
"arktype": "^2.1.29",
|