rolldown-plugin-dts 0.23.2 → 0.24.0-beta.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.
package/README.md CHANGED
@@ -40,6 +40,18 @@ Configuration options for the plugin.
40
40
 
41
41
  ### General Options
42
42
 
43
+ #### `entry`
44
+
45
+ Glob pattern(s) to filter which files get `.d.ts` generation.
46
+
47
+ When specified, only files matching these patterns will emit `.d.ts` chunks — even if they are not Rolldown entry points. Supports negation patterns for exclusion. Patterns are matched against file paths relative to `cwd`.
48
+
49
+ ```ts
50
+ dts({
51
+ entry: ['src/**/*.ts', '!src/icons/**'],
52
+ })
53
+ ```
54
+
43
55
  #### `cwd`
44
56
 
45
57
  The directory in which the plugin will search for the `tsconfig.json` file.
@@ -1,6 +1,6 @@
1
1
  import { r as TscContext } from "./context-3rlTPR48.mjs";
2
2
  import { SourceMapInput } from "rolldown";
3
- import { TsConfigJson } from "get-tsconfig";
3
+ import { TsconfigJson } from "get-tsconfig";
4
4
  import ts from "typescript";
5
5
 
6
6
  //#region src/tsc/types.d.ts
@@ -10,7 +10,7 @@ interface TscModule {
10
10
  }
11
11
  interface TscOptions {
12
12
  tsconfig?: string;
13
- tsconfigRaw: TsConfigJson;
13
+ tsconfigRaw: TsconfigJson;
14
14
  cwd: string;
15
15
  build: boolean;
16
16
  incremental: boolean;
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from "rolldown";
2
2
  import { IsolatedDeclarationsOptions } from "rolldown/experimental";
3
- import { TsConfigJson } from "get-tsconfig";
3
+ import { TsconfigJson } from "get-tsconfig";
4
4
 
5
5
  //#region src/options.d.ts
6
6
  interface GeneralOptions {
@@ -48,13 +48,13 @@ interface GeneralOptions {
48
48
  *
49
49
  * @see https://www.typescriptlang.org/tsconfig
50
50
  */
51
- tsconfigRaw?: Omit<TsConfigJson, "compilerOptions">;
51
+ tsconfigRaw?: Omit<TsconfigJson, "compilerOptions">;
52
52
  /**
53
53
  * Override the `compilerOptions` specified in `tsconfig.json`.
54
54
  *
55
55
  * @see https://www.typescriptlang.org/tsconfig/#compilerOptions
56
56
  */
57
- compilerOptions?: TsConfigJson.CompilerOptions;
57
+ compilerOptions?: TsconfigJson.CompilerOptions;
58
58
  /**
59
59
  * If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
60
60
  */
@@ -205,7 +205,7 @@ type OptionsResolved = Overwrite<Required<Omit<Options, "compilerOptions">>, {
205
205
  entry?: string[];
206
206
  tsconfig?: string;
207
207
  oxc: IsolatedDeclarationsOptions | false;
208
- tsconfigRaw: TsConfigJson;
208
+ tsconfigRaw: TsconfigJson;
209
209
  tsgo: Omit<TsgoOptions, "enabled"> | false;
210
210
  }>;
211
211
  declare function resolveOptions({
package/dist/index.mjs CHANGED
@@ -7,7 +7,6 @@ import { importerId, include } from "rolldown/filter";
7
7
  import { generate } from "@babel/generator";
8
8
  import { isIdentifierName } from "@babel/helper-validator-identifier";
9
9
  import { parse } from "@babel/parser";
10
- import * as t from "@babel/types";
11
10
  import { isDeclarationType, isIdentifierOf, isTypeOf, resolveString, walkAST } from "ast-kit";
12
11
  import { fork, spawn } from "node:child_process";
13
12
  import { existsSync } from "node:fs";
@@ -17,7 +16,7 @@ const picomatch = __cjs_require("picomatch");
17
16
  import { ResolverFactory, isolatedDeclarationSync } from "rolldown/experimental";
18
17
  import { tmpdir } from "node:os";
19
18
  import process from "node:process";
20
- import { getTsconfig, parseTsconfig } from "get-tsconfig";
19
+ import { getTsconfig, readTsconfig } from "get-tsconfig";
21
20
  import { createResolver } from "dts-resolver";
22
21
  //#region src/dts-input.ts
23
22
  function createDtsInputPlugin({ sideEffects }) {
@@ -141,11 +140,17 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
141
140
  else if ("id" in decl && decl.id) {
142
141
  let binding = decl.id;
143
142
  if (binding.type === "TSQualifiedName") binding = getIdFromTSEntityName(binding);
144
- binding = sideEffect ? t.identifier(`_${getIdentifierIndex(identifierMap, "")}`) : binding;
143
+ binding = sideEffect ? {
144
+ type: "Identifier",
145
+ name: `_${getIdentifierIndex(identifierMap, "")}`
146
+ } : binding;
145
147
  if (binding.type !== "Identifier") throw new Error(`Unexpected ${binding.type} declaration id`);
146
148
  bindings.push(binding);
147
149
  } else {
148
- const binding = t.identifier("export_default");
150
+ const binding = {
151
+ type: "Identifier",
152
+ name: "export_default"
153
+ };
149
154
  bindings.push(binding);
150
155
  decl.id = binding;
151
156
  }
@@ -154,23 +159,48 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
154
159
  const deps = collectDependencies(decl, namespaceStmts, childrenSet, identifierMap);
155
160
  const children = Array.from(childrenSet).filter((child) => bindings.every((b) => child !== b));
156
161
  if (decl !== stmt) decl.leadingComments = stmt.leadingComments;
157
- const declarationId = registerDeclaration({
158
- decl,
159
- deps,
160
- bindings,
161
- params,
162
- children
163
- });
164
- const declarationIdNode = t.numericLiteral(declarationId);
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
- })));
173
- const sideEffectNode = sideEffect && t.callExpression(t.identifier("sideEffect"), [bindings[0]]);
162
+ const declarationIdNode = {
163
+ type: "NumericLiteral",
164
+ value: registerDeclaration({
165
+ decl,
166
+ deps,
167
+ bindings,
168
+ params,
169
+ children
170
+ })
171
+ };
172
+ const depsBody = {
173
+ type: "ArrayExpression",
174
+ elements: deps
175
+ };
176
+ const depsNode = {
177
+ type: "ArrowFunctionExpression",
178
+ params: params.map(({ name }) => ({
179
+ type: "Identifier",
180
+ name
181
+ })),
182
+ body: depsBody,
183
+ async: false,
184
+ expression: true
185
+ };
186
+ const childrenNode = {
187
+ type: "ArrayExpression",
188
+ elements: children.map((node) => ({
189
+ type: "StringLiteral",
190
+ value: "",
191
+ start: node.start,
192
+ end: node.end,
193
+ loc: node.loc
194
+ }))
195
+ };
196
+ const sideEffectNode = sideEffect && {
197
+ type: "CallExpression",
198
+ callee: {
199
+ type: "Identifier",
200
+ name: "sideEffect"
201
+ },
202
+ arguments: [bindings[0]]
203
+ };
174
204
  const runtimeArrayNode = runtimeBindingArrayExpression([
175
205
  declarationIdNode,
176
206
  depsNode,
@@ -196,11 +226,34 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
196
226
  }))]
197
227
  };
198
228
  if (isDefaultExport) {
199
- appendStmts.push(t.exportNamedDeclaration(null, [t.exportSpecifier(bindings[0], t.identifier("default"))]));
229
+ appendStmts.push({
230
+ type: "ExportNamedDeclaration",
231
+ declaration: null,
232
+ specifiers: [{
233
+ type: "ExportSpecifier",
234
+ local: bindings[0],
235
+ exported: {
236
+ type: "Identifier",
237
+ name: "default"
238
+ }
239
+ }],
240
+ source: null,
241
+ attributes: null
242
+ });
200
243
  setStmt(runtimeAssignment);
201
244
  } else setDecl(runtimeAssignment);
202
245
  }
203
- if (sideEffects) appendStmts.push(t.expressionStatement(t.callExpression(t.identifier("sideEffect"), [])));
246
+ if (sideEffects) appendStmts.push({
247
+ type: "ExpressionStatement",
248
+ expression: {
249
+ type: "CallExpression",
250
+ callee: {
251
+ type: "Identifier",
252
+ name: "sideEffect"
253
+ },
254
+ arguments: []
255
+ }
256
+ });
204
257
  program.body = [
205
258
  ...Array.from(namespaceStmts.values()).map(({ stmt }) => stmt),
206
259
  ...program.body,
@@ -264,7 +317,8 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
264
317
  for (const [i, originalDep] of declaration.deps.entries()) {
265
318
  let transformedDep = transformedDeps[i];
266
319
  if (transformedDep.type === "UnaryExpression" && transformedDep.operator === "void") transformedDep = {
267
- ...t.identifier("undefined"),
320
+ type: "Identifier",
321
+ name: "undefined",
268
322
  loc: transformedDep.loc,
269
323
  start: transformedDep.start,
270
324
  end: transformedDep.end
@@ -324,7 +378,10 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
324
378
  function collectParams(node) {
325
379
  const typeParams = [];
326
380
  walkAST(node, { leave(node) {
327
- if ("typeParameters" in node && node.typeParameters?.type === "TSTypeParameterDeclaration") typeParams.push(...node.typeParameters.params.map(({ name }) => typeof name === "string" ? t.identifier(name) : name));
381
+ if ("typeParameters" in node && node.typeParameters?.type === "TSTypeParameterDeclaration") typeParams.push(...node.typeParameters.params.map(({ name }) => typeof name === "string" ? {
382
+ type: "Identifier",
383
+ name
384
+ } : name));
328
385
  } });
329
386
  const paramMap = /* @__PURE__ */ new Map();
330
387
  for (const typeParam of typeParams) {
@@ -404,22 +461,40 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
404
461
  }
405
462
  function importNamespace(node, imported, source, namespaceStmts, identifierMap) {
406
463
  const sourceText = source.value.replaceAll(/\W/g, "_");
407
- const localName = `_$${isIdentifierName(source.value) ? source.value : `${sourceText}${getIdentifierIndex(identifierMap, sourceText)}`}`;
408
- let local = t.identifier(localName);
464
+ let local = {
465
+ type: "Identifier",
466
+ name: `_$${isIdentifierName(source.value) ? source.value : `${sourceText}${getIdentifierIndex(identifierMap, sourceText)}`}`
467
+ };
409
468
  if (namespaceStmts.has(source.value)) local = namespaceStmts.get(source.value).local;
410
469
  else namespaceStmts.set(source.value, {
411
- stmt: t.importDeclaration([t.importNamespaceSpecifier(local)], source),
470
+ stmt: {
471
+ type: "ImportDeclaration",
472
+ specifiers: [{
473
+ type: "ImportNamespaceSpecifier",
474
+ local
475
+ }],
476
+ source,
477
+ attributes: null
478
+ },
412
479
  local
413
480
  });
414
481
  if (imported) {
415
482
  const importedLeft = getIdFromTSEntityName(imported);
416
483
  if (imported.type === "ThisExpression" || importedLeft.type === "ThisExpression") throw new Error("Cannot import `this` from module.");
417
- overwriteNode(importedLeft, t.tsQualifiedName(local, { ...importedLeft }));
484
+ overwriteNode(importedLeft, {
485
+ type: "TSQualifiedName",
486
+ left: local,
487
+ right: { ...importedLeft }
488
+ });
418
489
  local = imported;
419
490
  }
420
491
  let replacement = node;
421
492
  if (node.typeArguments) {
422
- overwriteNode(node, t.tsTypeReference(local, node.typeArguments));
493
+ overwriteNode(node, {
494
+ type: "TSTypeReference",
495
+ typeName: local,
496
+ typeArguments: node.typeArguments
497
+ });
423
498
  replacement = local;
424
499
  } else overwriteNode(node, local);
425
500
  return {
@@ -466,7 +541,10 @@ function isRuntimeBindingArrayElements(elements) {
466
541
  return declarationId?.type === "NumericLiteral" && deps?.type === "ArrowFunctionExpression" && children?.type === "ArrayExpression" && (!effect || effect.type === "CallExpression");
467
542
  }
468
543
  function runtimeBindingArrayExpression(elements) {
469
- return t.arrayExpression(elements);
544
+ return {
545
+ type: "ArrayExpression",
546
+ elements
547
+ };
470
548
  }
471
549
  function isThisExpression(node) {
472
550
  return isIdentifierOf(node, "this") || node.type === "ThisExpression" || node.type === "MemberExpression" && isThisExpression(node.object);
@@ -477,7 +555,12 @@ function isInfer(node) {
477
555
  function TSEntityNameToRuntime(node) {
478
556
  if (node.type === "Identifier" || node.type === "ThisExpression") return node;
479
557
  const left = TSEntityNameToRuntime(node.left);
480
- return Object.assign(node, t.memberExpression(left, node.right));
558
+ return Object.assign(node, {
559
+ type: "MemberExpression",
560
+ object: left,
561
+ property: node.right,
562
+ computed: false
563
+ });
481
564
  }
482
565
  function getIdFromTSEntityName(node) {
483
566
  if (node.type === "Identifier" || node.type === "ThisExpression") return node;
@@ -537,9 +620,11 @@ function patchTsNamespace(nodes) {
537
620
  body: [{
538
621
  type: "ExportNamedDeclaration",
539
622
  specifiers: exports.properties.filter((property) => property.type === "ObjectProperty").map((property) => {
540
- const local = property.value.body;
541
- const exported = property.key;
542
- return t.exportSpecifier(local, exported);
623
+ return {
624
+ type: "ExportSpecifier",
625
+ local: property.value.body,
626
+ exported: property.key
627
+ };
543
628
  }),
544
629
  source: null,
545
630
  declaration: null
@@ -628,7 +713,10 @@ function rewriteImportExport(node, set, typeOnlyIds) {
628
713
  specifiers: [{
629
714
  type: "ExportSpecifier",
630
715
  local: node.declaration,
631
- exported: t.identifier("default")
716
+ exported: {
717
+ type: "Identifier",
718
+ name: "default"
719
+ }
632
720
  }]
633
721
  });
634
722
  return true;
@@ -942,7 +1030,7 @@ function resolveOptions({ entry, cwd = process.cwd(), dtsInput = false, emitDtsO
942
1030
  resolvedTsconfig = config;
943
1031
  } else if (typeof tsconfig === "string") {
944
1032
  tsconfig = path.resolve(cwd || process.cwd(), tsconfig);
945
- resolvedTsconfig = parseTsconfig(tsconfig);
1033
+ resolvedTsconfig = readTsconfig(tsconfig).config;
946
1034
  } else tsconfig = void 0;
947
1035
  compilerOptions = {
948
1036
  ...resolvedTsconfig?.compilerOptions,
@@ -1,5 +1,5 @@
1
1
  import { ChunkFileNamesFunction, PreRenderedChunk } from "rolldown";
2
- import { parseTsconfig } from "get-tsconfig";
2
+ import { readTsconfig } from "get-tsconfig";
3
3
 
4
4
  //#region src/filename.d.ts
5
5
  declare const RE_JS: RegExp;
@@ -17,4 +17,4 @@ declare function filename_dts_to(id: string, ext: "js" | "ts"): string;
17
17
  declare function resolveTemplateFn(fn: string | ChunkFileNamesFunction, chunk: PreRenderedChunk): string;
18
18
  declare function replaceTemplateName(template: string, name: string): string;
19
19
  //#endregion
20
- export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, parseTsconfig, replaceTemplateName, resolveTemplateFn };
20
+ export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, readTsconfig, replaceTemplateName, resolveTemplateFn };
package/dist/internal.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import { a as RE_JSON, c as RE_TS, d as filename_js_to_dts, f as filename_to_dts, i as RE_JS, l as RE_VUE, m as resolveTemplateFn, n as RE_DTS, o as RE_NODE_MODULES, p as replaceTemplateName, r as RE_DTS_MAP, s as RE_ROLLDOWN_RUNTIME, t as RE_CSS, u as filename_dts_to } from "./filename-DQnUJlio.mjs";
2
- import { parseTsconfig } from "get-tsconfig";
3
- export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_ROLLDOWN_RUNTIME, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, parseTsconfig, replaceTemplateName, resolveTemplateFn };
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, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, readTsconfig, replaceTemplateName, resolveTemplateFn };
@@ -1,4 +1,4 @@
1
- import { t as tscEmit } from "./index-DAUYR4Qd.mjs";
1
+ import { t as tscEmit } from "./index-CJhxyVA1.mjs";
2
2
 
3
3
  //#region src/tsc/worker.d.ts
4
4
  declare const functions: {
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-DAUYR4Qd.mjs";
1
+ import { i as TscResult, n as TscModule, r as TscOptions, t as tscEmit } from "./index-CJhxyVA1.mjs";
2
2
  export { TscModule, TscOptions, TscResult, tscEmit };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
3
  "type": "module",
4
- "version": "0.23.2",
4
+ "version": "0.24.0-beta.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",
@@ -38,13 +38,13 @@
38
38
  "access": "public"
39
39
  },
40
40
  "engines": {
41
- "node": ">=20.19.0"
41
+ "node": ">=22.18.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@ts-macro/tsc": "^0.3.6",
45
45
  "@typescript/native-preview": ">=7.0.0-dev.20260325.1",
46
46
  "rolldown": "^1.0.0-rc.12",
47
- "typescript": "^5.0.0 || ^6.0.0",
47
+ "typescript": "^6.0.0",
48
48
  "vue-tsc": "~3.2.0"
49
49
  },
50
50
  "peerDependenciesMeta": {
@@ -62,46 +62,43 @@
62
62
  }
63
63
  },
64
64
  "dependencies": {
65
- "@babel/generator": "8.0.0-rc.3",
66
- "@babel/helper-validator-identifier": "8.0.0-rc.3",
67
- "@babel/parser": "8.0.0-rc.3",
68
- "@babel/types": "8.0.0-rc.3",
65
+ "@babel/generator": "8.0.0-rc.4",
66
+ "@babel/helper-validator-identifier": "8.0.0-rc.4",
67
+ "@babel/parser": "8.0.0-rc.4",
69
68
  "ast-kit": "^3.0.0-beta.1",
70
69
  "birpc": "^4.0.0",
71
70
  "dts-resolver": "^2.1.3",
72
- "get-tsconfig": "^4.13.7",
71
+ "get-tsconfig": "^5.0.0-beta.5",
73
72
  "obug": "^2.1.1",
74
73
  "picomatch": "^4.0.4"
75
74
  },
76
75
  "devDependencies": {
76
+ "@babel/types": "^8.0.0-rc.4",
77
77
  "@jridgewell/source-map": "^0.3.11",
78
- "@sxzz/eslint-config": "^7.8.4",
78
+ "@sxzz/eslint-config": "^8.0.0",
79
79
  "@sxzz/prettier-config": "^2.3.1",
80
- "@sxzz/test-utils": "^0.5.16",
81
- "@types/node": "^25.5.0",
82
- "@types/picomatch": "^4.0.2",
83
- "@typescript/native-preview": "7.0.0-dev.20260328.1",
80
+ "@sxzz/test-utils": "^0.5.18",
81
+ "@types/node": "^25.6.0",
82
+ "@types/picomatch": "^4.0.3",
83
+ "@typescript/native-preview": "7.0.0-dev.20260430.1",
84
84
  "@volar/typescript": "^2.4.28",
85
- "@vue/language-core": "^3.2.6",
85
+ "@vue/language-core": "^3.2.7",
86
86
  "arktype": "^2.2.0",
87
87
  "bumpp": "^11.0.1",
88
- "diff": "^8.0.4",
89
- "eslint": "^10.1.0",
90
- "prettier": "^3.8.1",
91
- "rolldown": "^1.0.0-rc.12",
92
- "rolldown-plugin-dts-snapshot": "^0.4.0",
88
+ "diff": "^9.0.0",
89
+ "eslint": "^10.2.1",
90
+ "prettier": "^3.8.3",
91
+ "rolldown": "^1.0.0-rc.18",
93
92
  "rolldown-plugin-require-cjs": "^0.4.0",
94
93
  "rollup-plugin-dts": "^6.4.1",
95
- "tinyglobby": "^0.2.15",
96
- "tsdown": "^0.21.6",
97
- "typescript": "^6.0.2",
98
- "vitest": "^4.1.2",
99
- "vue": "^3.5.31",
100
- "vue-tsc": "^3.2.6",
101
- "zod": "^4.3.6"
102
- },
103
- "resolutions": {
104
- "rolldown": "^1.0.0-rc.12"
94
+ "tinyglobby": "^0.2.16",
95
+ "tsdown": "^0.22.0-beta.2",
96
+ "tsnapi": "^0.3.2",
97
+ "typescript": "^6.0.3",
98
+ "vitest": "^4.1.5",
99
+ "vue": "^3.5.33",
100
+ "vue-tsc": "^3.2.7",
101
+ "zod": "^4.4.1"
105
102
  },
106
103
  "prettier": "@sxzz/prettier-config",
107
104
  "scripts": {