rolldown-plugin-dts 0.21.4 → 0.21.6

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.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-Cqnsj8Gp.mjs";
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-DhMOFFZT.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 };
@@ -1,4 +1,4 @@
1
- import { r as TscContext } from "./context-CCPZT79j.mjs";
1
+ import { r as TscContext } from "./context-Dt8gPoCq.mjs";
2
2
  import { TsConfigJson } from "get-tsconfig";
3
3
  import ts from "typescript";
4
4
  import { SourceMapInput } from "rolldown";
package/dist/index.d.mts CHANGED
@@ -5,185 +5,185 @@ import { Plugin } from "rolldown";
5
5
  //#region src/options.d.ts
6
6
  interface GeneralOptions {
7
7
  /**
8
- * The directory in which the plugin will search for the `tsconfig.json` file.
9
- */
8
+ * The directory in which the plugin will search for the `tsconfig.json` file.
9
+ */
10
10
  cwd?: string;
11
11
  /**
12
- * Set to `true` if your entry files are `.d.ts` files instead of `.ts` files.
13
- *
14
- * When enabled, the plugin will skip generating a `.d.ts` file for the entry point.
15
- */
12
+ * Set to `true` if your entry files are `.d.ts` files instead of `.ts` files.
13
+ *
14
+ * When enabled, the plugin will skip generating a `.d.ts` file for the entry point.
15
+ */
16
16
  dtsInput?: boolean;
17
17
  /**
18
- * If `true`, the plugin will emit only `.d.ts` files and remove all other output chunks.
19
- *
20
- * This is especially useful when generating `.d.ts` files for the CommonJS format as part of a separate build step.
21
- */
18
+ * If `true`, the plugin will emit only `.d.ts` files and remove all other output chunks.
19
+ *
20
+ * This is especially useful when generating `.d.ts` files for the CommonJS format as part of a separate build step.
21
+ */
22
22
  emitDtsOnly?: boolean;
23
23
  /**
24
- * The path to the `tsconfig.json` file.
25
- *
26
- * If set to `false`, the plugin will ignore any `tsconfig.json` file.
27
- * You can still specify `compilerOptions` directly in the options.
28
- *
29
- * @default 'tsconfig.json'
30
- */
24
+ * The path to the `tsconfig.json` file.
25
+ *
26
+ * If set to `false`, the plugin will ignore any `tsconfig.json` file.
27
+ * You can still specify `compilerOptions` directly in the options.
28
+ *
29
+ * @default 'tsconfig.json'
30
+ */
31
31
  tsconfig?: string | boolean;
32
32
  /**
33
- * Pass a raw `tsconfig.json` object directly to the plugin.
34
- *
35
- * @see https://www.typescriptlang.org/tsconfig
36
- */
33
+ * Pass a raw `tsconfig.json` object directly to the plugin.
34
+ *
35
+ * @see https://www.typescriptlang.org/tsconfig
36
+ */
37
37
  tsconfigRaw?: Omit<TsConfigJson, "compilerOptions">;
38
38
  /**
39
- * Override the `compilerOptions` specified in `tsconfig.json`.
40
- *
41
- * @see https://www.typescriptlang.org/tsconfig/#compilerOptions
42
- */
39
+ * Override the `compilerOptions` specified in `tsconfig.json`.
40
+ *
41
+ * @see https://www.typescriptlang.org/tsconfig/#compilerOptions
42
+ */
43
43
  compilerOptions?: TsConfigJson.CompilerOptions;
44
44
  /**
45
- * If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
46
- */
45
+ * If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
46
+ */
47
47
  sourcemap?: boolean;
48
48
  /**
49
- * Specifies a resolver to resolve type definitions, especially for `node_modules`.
50
- *
51
- * - `'oxc'`: Uses Oxc's module resolution, which is faster and more efficient.
52
- * - `'tsc'`: Uses TypeScript's native module resolution, which may be more compatible with complex setups, but slower.
53
- *
54
- * @default 'oxc'
55
- */
49
+ * Specifies a resolver to resolve type definitions, especially for `node_modules`.
50
+ *
51
+ * - `'oxc'`: Uses Oxc's module resolution, which is faster and more efficient.
52
+ * - `'tsc'`: Uses TypeScript's native module resolution, which may be more compatible with complex setups, but slower.
53
+ *
54
+ * @default 'oxc'
55
+ */
56
56
  resolver?: "oxc" | "tsc";
57
57
  /**
58
- * Determines how the default export is emitted.
59
- *
60
- * If set to `true`, and you are only exporting a single item using `export default ...`,
61
- * the output will use `export = ...` instead of the standard ES module syntax.
62
- * This is useful for compatibility with CommonJS.
63
- */
58
+ * Determines how the default export is emitted.
59
+ *
60
+ * If set to `true`, and you are only exporting a single item using `export default ...`,
61
+ * the output will use `export = ...` instead of the standard ES module syntax.
62
+ * This is useful for compatibility with CommonJS.
63
+ */
64
64
  cjsDefault?: boolean;
65
65
  /**
66
- * Indicates whether the generated `.d.ts` files have side effects.
67
- * - If set to `true`, Rolldown will treat the `.d.ts` files as having side effects during tree-shaking.
68
- * - If set to `false`, Rolldown may consider the `.d.ts` files as side-effect-free, potentially removing them if they are not imported.
69
- *
70
- * @default false
71
- */
66
+ * Indicates whether the generated `.d.ts` files have side effects.
67
+ * - If set to `true`, Rolldown will treat the `.d.ts` files as having side effects during tree-shaking.
68
+ * - If set to `false`, Rolldown may consider the `.d.ts` files as side-effect-free, potentially removing them if they are not imported.
69
+ *
70
+ * @default false
71
+ */
72
72
  sideEffects?: boolean;
73
73
  }
74
74
  interface TscOptions {
75
75
  /**
76
- * Build mode for the TypeScript compiler:
77
- *
78
- * - If `true`, the plugin will use [`tsc -b`](https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript) to build the project and all referenced projects before emitting `.d.ts` files.
79
- * - If `false`, the plugin will use [`tsc`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) to emit `.d.ts` files without building referenced projects.
80
- *
81
- * @default false
82
- */
76
+ * Build mode for the TypeScript compiler:
77
+ *
78
+ * - If `true`, the plugin will use [`tsc -b`](https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript) to build the project and all referenced projects before emitting `.d.ts` files.
79
+ * - If `false`, the plugin will use [`tsc`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) to emit `.d.ts` files without building referenced projects.
80
+ *
81
+ * @default false
82
+ */
83
83
  build?: boolean;
84
84
  /**
85
- * If your tsconfig.json has
86
- * [`references`](https://www.typescriptlang.org/tsconfig/#references) option,
87
- * `rolldown-plugin-dts` will use [`tsc
88
- * -b`](https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript)
89
- * to build the project and all referenced projects before emitting `.d.ts`
90
- * files.
91
- *
92
- * In such case, if this option is `true`, `rolldown-plugin-dts` will write
93
- * down all built files into your disk, including
94
- * [`.tsbuildinfo`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)
95
- * and other built files. This is equivalent to running `tsc -b` in your
96
- * project.
97
- *
98
- * Otherwise, if this option is `false`, `rolldown-plugin-dts` will write
99
- * built files only into memory and leave a small footprint in your disk.
100
- *
101
- * Enabling this option will decrease the build time by caching previous build
102
- * results. This is helpful when you have a large project with multiple
103
- * referenced projects.
104
- *
105
- * By default, `incremental` is `true` if your tsconfig has
106
- * [`incremental`](https://www.typescriptlang.org/tsconfig/#incremental) or
107
- * [`tsBuildInfoFile`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)
108
- * enabled.
109
- *
110
- * This option is only used when {@link Options.oxc} is
111
- * `false`.
112
- */
85
+ * If your tsconfig.json has
86
+ * [`references`](https://www.typescriptlang.org/tsconfig/#references) option,
87
+ * `rolldown-plugin-dts` will use [`tsc
88
+ * -b`](https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript)
89
+ * to build the project and all referenced projects before emitting `.d.ts`
90
+ * files.
91
+ *
92
+ * In such case, if this option is `true`, `rolldown-plugin-dts` will write
93
+ * down all built files into your disk, including
94
+ * [`.tsbuildinfo`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)
95
+ * and other built files. This is equivalent to running `tsc -b` in your
96
+ * project.
97
+ *
98
+ * Otherwise, if this option is `false`, `rolldown-plugin-dts` will write
99
+ * built files only into memory and leave a small footprint in your disk.
100
+ *
101
+ * Enabling this option will decrease the build time by caching previous build
102
+ * results. This is helpful when you have a large project with multiple
103
+ * referenced projects.
104
+ *
105
+ * By default, `incremental` is `true` if your tsconfig has
106
+ * [`incremental`](https://www.typescriptlang.org/tsconfig/#incremental) or
107
+ * [`tsBuildInfoFile`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)
108
+ * enabled.
109
+ *
110
+ * This option is only used when {@link Options.oxc} is
111
+ * `false`.
112
+ */
113
113
  incremental?: boolean;
114
114
  /**
115
- * If `true`, the plugin will generate `.d.ts` files using `vue-tsc`.
116
- */
115
+ * If `true`, the plugin will generate `.d.ts` files using `vue-tsc`.
116
+ */
117
117
  vue?: boolean;
118
118
  /**
119
- * If `true`, the plugin will generate `.d.ts` files using `@ts-macro/tsc`.
120
- */
119
+ * If `true`, the plugin will generate `.d.ts` files using `@ts-macro/tsc`.
120
+ */
121
121
  tsMacro?: boolean;
122
122
  /**
123
- * If `true`, the plugin will launch a separate process for `tsc` or `vue-tsc`.
124
- * This enables processing multiple projects in parallel.
125
- */
123
+ * If `true`, the plugin will launch a separate process for `tsc` or `vue-tsc`.
124
+ * This enables processing multiple projects in parallel.
125
+ */
126
126
  parallel?: boolean;
127
127
  /**
128
- * If `true`, the plugin will prepare all files listed in `tsconfig.json` for `tsc` or `vue-tsc`.
129
- *
130
- * This is especially useful when you have a single `tsconfig.json` for multiple projects in a monorepo.
131
- */
128
+ * If `true`, the plugin will prepare all files listed in `tsconfig.json` for `tsc` or `vue-tsc`.
129
+ *
130
+ * This is especially useful when you have a single `tsconfig.json` for multiple projects in a monorepo.
131
+ */
132
132
  eager?: boolean;
133
133
  /**
134
- * If `true`, the plugin will create a new isolated context for each build,
135
- * ensuring that previously generated `.d.ts` code and caches are not reused.
136
- *
137
- * By default, the plugin may reuse internal caches or incremental build artifacts
138
- * to speed up repeated builds. Enabling this option forces a clean context,
139
- * guaranteeing that all type definitions are generated from scratch.
140
- *
141
- * @default false
142
- */
134
+ * If `true`, the plugin will create a new isolated context for each build,
135
+ * ensuring that previously generated `.d.ts` code and caches are not reused.
136
+ *
137
+ * By default, the plugin may reuse internal caches or incremental build artifacts
138
+ * to speed up repeated builds. Enabling this option forces a clean context,
139
+ * guaranteeing that all type definitions are generated from scratch.
140
+ *
141
+ * @default false
142
+ */
143
143
  newContext?: boolean;
144
144
  /**
145
- * If `true`, the plugin will emit `.d.ts` files for `.js` files as well.
146
- * This is useful when you want to generate type definitions for JavaScript files with JSDoc comments.
147
- *
148
- * Enabled by default when `allowJs` in compilerOptions is `true`.
149
- * This option is only used when {@link Options.oxc} is
150
- * `false`.
151
- */
145
+ * If `true`, the plugin will emit `.d.ts` files for `.js` files as well.
146
+ * This is useful when you want to generate type definitions for JavaScript files with JSDoc comments.
147
+ *
148
+ * Enabled by default when `allowJs` in compilerOptions is `true`.
149
+ * This option is only used when {@link Options.oxc} is
150
+ * `false`.
151
+ */
152
152
  emitJs?: boolean;
153
153
  }
154
154
  interface Options extends GeneralOptions, TscOptions {
155
155
  /**
156
- * If `true`, the plugin will generate `.d.ts` files using Oxc,
157
- * which is significantly faster than the TypeScript compiler.
158
- *
159
- * This option is automatically enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
160
- */
156
+ * If `true`, the plugin will generate `.d.ts` files using Oxc,
157
+ * which is significantly faster than the TypeScript compiler.
158
+ *
159
+ * This option is automatically enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
160
+ */
161
161
  oxc?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
162
162
  /**
163
- * **[Experimental]** Enables DTS generation using `tsgo`.
164
- *
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.
167
- *
168
- * **Note:** This option is not yet recommended for production environments.
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
- */
163
+ * **[Experimental]** Enables DTS generation using `tsgo`.
164
+ *
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.
167
+ *
168
+ * **Note:** This option is not yet recommended for production environments.
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
180
  tsgo?: boolean | TsgoOptions;
181
181
  }
182
182
  interface TsgoOptions {
183
183
  enabled?: boolean;
184
184
  /**
185
- * Custom path to the `tsgo` binary.
186
- */
185
+ * Custom path to the `tsgo` binary.
186
+ */
187
187
  path?: string;
188
188
  }
189
189
  type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
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-Cqnsj8Gp.mjs";
2
- import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-EuY-ImLj.mjs";
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-DhMOFFZT.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$1) => program.body[i] = stmt$1;
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$1) => stmt.declaration = decl$1 : setStmt;
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$1) => decl$1.id));
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,8 +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$1) {
243
- delete node$1.loc;
245
+ walkAST(declaration.decl, { enter(node) {
246
+ if (node.type === "CommentBlock") return;
247
+ delete node.loc;
244
248
  } });
245
249
  for (const [i, decl] of node.declarations.entries()) {
246
250
  const transformedBinding = {
@@ -256,8 +260,17 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
256
260
  for (const originalTypeParam of declaration.params[i].typeParams) originalTypeParam.name = transformedName;
257
261
  }
258
262
  const transformedDeps = depsFn.body.elements;
259
- for (const [i, originalDep] of declaration.deps.entries()) if (originalDep.replace) originalDep.replace(transformedDeps[i]);
260
- else Object.assign(originalDep, transformedDeps[i]);
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
+ }
261
274
  return inheritNodeComments(node, declaration.decl);
262
275
  }).filter((node) => !!node);
263
276
  if (program.body.length === 0) return "export { };";
@@ -267,9 +280,9 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
267
280
  const preserveComments = commentsMap.get(id);
268
281
  if (preserveComments) {
269
282
  preserveComments.forEach((c) => {
270
- const id$1 = c.type + c.value;
271
- if (commentsValue.has(id$1)) return;
272
- commentsValue.add(id$1);
283
+ const id = c.type + c.value;
284
+ if (commentsValue.has(id)) return;
285
+ commentsValue.add(id);
273
286
  comments.add(c);
274
287
  });
275
288
  commentsMap.delete(id);
@@ -280,7 +293,6 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
280
293
  program.body[0].leadingComments.unshift(...comments);
281
294
  }
282
295
  const result = generate(file, {
283
- comments: true,
284
296
  sourceMaps: sourcemap,
285
297
  sourceFileName: chunk.fileName
286
298
  });
@@ -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$1) {
313
- if ("typeParameters" in node$1 && node$1.typeParameters?.type === "TSTypeParameterDeclaration") typeParams.push(...node$1.typeParameters.params.map((param) => param.name));
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$1]) => ({
334
+ return Array.from(paramMap.entries()).map(([name, typeParams]) => ({
323
335
  name,
324
- typeParams: typeParams$1
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$1) {
333
- return node$1.type === "Identifier" && currentInferred.has(node$1.name);
344
+ function isInferred(node) {
345
+ return node.type === "Identifier" && currentInferred.has(node.name);
334
346
  }
335
347
  walkAST(node, {
336
- enter(node$1) {
337
- if (node$1.type === "TSConditionalType") {
338
- const inferred = collectInferredNames(node$1.extendsType);
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$1, parent) {
343
- if (node$1.type === "TSConditionalType") inferredStack.pop();
354
+ leave(node, parent) {
355
+ if (node.type === "TSConditionalType") inferredStack.pop();
344
356
  else if (parent?.type === "TSConditionalType") {
345
- const trueBranch = parent.trueType === node$1;
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$1.type === "ExportNamedDeclaration") {
349
- for (const specifier of node$1.specifiers) if (specifier.type === "ExportSpecifier") addDependency(specifier.local);
350
- } else if (node$1.type === "TSInterfaceDeclaration" && node$1.extends) for (const heritage of node$1.extends || []) addDependency(heritage.expression);
351
- else if (node$1.type === "ClassDeclaration") {
352
- if (node$1.superClass) addDependency(node$1.superClass);
353
- if (node$1.implements) for (const implement of node$1.implements) {
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$1, [
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$1.computed && isReferenceId(node$1.key)) addDependency(node$1.key);
365
- if ("value" in node$1 && isReferenceId(node$1.value)) addDependency(node$1.value);
366
- } else switch (node$1.type) {
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$1.typeName));
380
+ addDependency(TSEntityNameToRuntime(node.typeName));
369
381
  break;
370
382
  case "TSTypeQuery":
371
- if (seen.has(node$1.exprName)) return;
372
- if (node$1.exprName.type === "TSImportType") break;
373
- addDependency(TSEntityNameToRuntime(node$1.exprName));
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$1);
377
- const { source, qualifier } = node$1;
378
- addDependency(importNamespace(node$1, qualifier, source, namespaceStmts));
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$1) && isChildSymbol(node$1, parent)) children.add(node$1);
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$1) {
387
- if (isThisExpression(node$1) || isInferred(node$1)) return;
388
- deps.add(node$1);
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$1) {
426
- if (node$1.type === "TSInferType" && node$1.typeParameter) inferred.push(node$1.typeParameter.name.name);
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: path$1 } = getTsconfig(cwd) || {};
916
- tsconfig = path$1;
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-CQnlAxJ7.mjs");
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-Cqnsj8Gp.mjs";
3
- import { n as globalContext } from "./context-EuY-ImLj.mjs";
2
+ import { n as RE_DTS, r as RE_DTS_MAP } from "./filename-DhMOFFZT.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$1) {
31
- if (files.has(path$1)) return path$1;
32
- return ts.sys.resolvePath(path$1);
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$1) => path$1.startsWith(directory))) return true;
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$1, data, ...args) {
47
- files.set(path$1, data);
48
- ts.sys.writeFile(path$1, data, ...args);
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$1, data) {
60
- files.set(path$1, data);
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$1, options) => {
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$1, ts$1.sys.readFile);
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$1, options.options, vueOptions, (id) => id);
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$5 = createDebug("rolldown-plugin-dts:ts-macro");
278
- debug$5("loading ts-macro language tools");
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$1, options) => {
284
+ const getLanguagePlugin = (ts, options) => {
285
285
  const $rootDir = options.options.$rootDir;
286
- return tsMacro.getLanguagePlugins(ts$1, options.options, getOptions(ts$1, $rootDir))[0];
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$5("ts-macro language tools not found", error);
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$1, options) {
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$1.createProgram;
302
- return proxyCreateProgram(ts$1, ts$1.createProgram, (ts$2, options$1) => {
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$2, options$1));
305
- if (tsMacroLanguageTools) languagePlugins.push(tsMacroLanguageTools.getLanguagePlugin(ts$2, options$1));
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$1) => {
328
- const roots = program$1.getRootFileNames();
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
  });
@@ -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-CCPZT79j.mjs";
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 };
@@ -1,3 +1,3 @@
1
- import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-EuY-ImLj.mjs";
1
+ import { n as globalContext, r as invalidateContextFile, t as createContext } from "./context-DoVwxr5H.mjs";
2
2
 
3
3
  export { createContext, globalContext, invalidateContextFile };
@@ -1,4 +1,4 @@
1
- import { t as tscEmit } from "./index-C8o_kIRC.mjs";
1
+ import { t as tscEmit } from "./index-DWPGYc3m.mjs";
2
2
 
3
3
  //#region src/tsc/worker.d.ts
4
4
  declare const functions: {
@@ -1,4 +1,4 @@
1
- import { t as tscEmit } from "./tsc-DmkHlcNe.mjs";
1
+ import { t as tscEmit } from "./tsc-Cg6Z_HPb.mjs";
2
2
  const process = globalThis.process;
3
3
  import { createBirpc } from "birpc";
4
4
 
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-C8o_kIRC.mjs";
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
@@ -1,3 +1,3 @@
1
- import { t as tscEmit } from "./tsc-DmkHlcNe.mjs";
1
+ import { t as tscEmit } from "./tsc-Cg6Z_HPb.mjs";
2
2
 
3
3
  export { tscEmit };
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",
4
+ "version": "0.21.6",
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.4.5",
76
+ "@sxzz/eslint-config": "^7.5.0",
77
77
  "@sxzz/prettier-config": "^2.2.6",
78
78
  "@sxzz/test-utils": "^0.5.15",
79
- "@types/node": "^25.0.9",
80
- "@typescript/native-preview": "7.0.0-dev.20260118.1",
79
+ "@types/node": "^25.0.10",
80
+ "@typescript/native-preview": "7.0.0-dev.20260122.4",
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.8.0",
88
- "rolldown": "^1.0.0-beta.60",
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.0-beta.3",
93
+ "tsdown": "^0.20.1",
94
94
  "typescript": "^5.9.3",
95
- "vitest": "^4.0.17",
96
- "vue": "^3.5.26",
95
+ "vitest": "^4.0.18",
96
+ "vue": "^3.5.27",
97
97
  "vue-tsc": "^3.2.2"
98
98
  },
99
99
  "resolutions": {
100
- "rolldown": "^1.0.0-beta.60"
100
+ "rolldown": "^1.0.0-rc.1"
101
101
  },
102
102
  "prettier": "@sxzz/prettier-config",
103
103
  "scripts": {