rolldown-plugin-dts 0.21.0 → 0.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -190,13 +190,13 @@ To use this option, ensure that `@typescript/native-preview` is installed as a d
190
190
 
191
191
  `tsconfigRaw` and `compilerOptions` options will be ignored when this option is enabled.
192
192
 
193
- ## Advanced Chunks Support
193
+ ## Code Splitting Support
194
194
 
195
- When using Rolldown's advanced chunking features such as `manualChunks` or `advancedChunks`, you should pay special attention to handling `.d.ts` files. The chunk names for `.d.ts` files must end with `.d`.
195
+ When using Rolldown's code splitting features `codeSplitting`, you should pay special attention to handling `.d.ts` files. The chunk names for `.d.ts` files must end with `.d`.
196
196
 
197
197
  ```ts
198
198
  export default {
199
- advancedChunks: {
199
+ codeSplitting: {
200
200
  groups: [
201
201
  // handle .d.ts files
202
202
  { test: /foo.*\.d\.[cm]?ts$/, name: 'shared.d' },
package/dist/index.d.mts CHANGED
@@ -5,168 +5,168 @@ 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
- *
167
- * **Note:** This option is not yet recommended for production environments.
168
- * `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
169
- */
163
+ * **[Experimental]** Enables DTS generation using `tsgo`.
164
+ *
165
+ * To use this option, make sure `@typescript/native-preview` is installed as a dependency.
166
+ *
167
+ * **Note:** This option is not yet recommended for production environments.
168
+ * `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
169
+ */
170
170
  tsgo?: boolean;
171
171
  }
172
172
  type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
package/dist/index.mjs CHANGED
@@ -22,11 +22,11 @@ const {
22
22
  readFile,
23
23
  rm
24
24
  } = globalThis.process.getBuiltinModule("node:fs/promises");
25
+ const path = globalThis.process.getBuiltinModule("node:path");
26
+ import { ResolverFactory, isolatedDeclarationSync } from "rolldown/experimental";
25
27
  const {
26
28
  tmpdir
27
29
  } = globalThis.process.getBuiltinModule("node:os");
28
- const path = globalThis.process.getBuiltinModule("node:path");
29
- import { ResolverFactory, isolatedDeclarationSync } from "rolldown/experimental";
30
30
  const process = globalThis.process;
31
31
  import { getTsconfig, parseTsconfig } from "get-tsconfig";
32
32
  import { createResolver } from "dts-resolver";
@@ -99,10 +99,15 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
99
99
  handler: transform
100
100
  },
101
101
  renderChunk,
102
- generateBundle: sourcemap ? void 0 : (options, bundle) => {
102
+ generateBundle(options, bundle) {
103
103
  for (const chunk of Object.values(bundle)) {
104
104
  if (!RE_DTS_MAP.test(chunk.fileName)) continue;
105
- delete bundle[chunk.fileName];
105
+ if (sourcemap) {
106
+ if (chunk.type === "chunk" || typeof chunk.source !== "string") continue;
107
+ const map = JSON.parse(chunk.source);
108
+ map.sourcesContent = void 0;
109
+ chunk.source = JSON.stringify(map);
110
+ } else delete bundle[chunk.fileName];
106
111
  }
107
112
  }
108
113
  };
@@ -223,6 +228,9 @@ function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }) {
223
228
  const [symbolIdNode, depsFn] = node.declarations[0].init.elements;
224
229
  const symbolId = symbolIdNode.value;
225
230
  const original = getSymbol(symbolId);
231
+ walkAST(original.decl, { enter(node$1) {
232
+ delete node$1.loc;
233
+ } });
226
234
  for (const [i, decl] of node.declarations.entries()) {
227
235
  const transformedBinding = {
228
236
  ...decl.id,
@@ -597,14 +605,42 @@ function inheritNodeComments(oldNode, newNode) {
597
605
  }
598
606
 
599
607
  //#endregion
600
- //#region src/generate.ts
601
- const debug$2 = createDebug("rolldown-plugin-dts:generate");
602
- const WORKER_URL = "./tsc-worker.mjs";
608
+ //#region src/tsgo.ts
609
+ const debug$3 = createDebug("rolldown-plugin-dts:tsgo");
603
610
  const spawnAsync = (...args) => new Promise((resolve, reject) => {
604
611
  const child = spawn(...args);
605
612
  child.on("close", () => resolve());
606
613
  child.on("error", (error) => reject(error));
607
614
  });
615
+ async function runTsgo(rootDir, tsconfig, sourcemap) {
616
+ debug$3("[tsgo] rootDir", rootDir);
617
+ const tsgoPkg = import.meta.resolve("@typescript/native-preview/package.json");
618
+ const { default: getExePath } = await import(new URL("lib/getExePath.js", tsgoPkg).href);
619
+ const tsgo = getExePath();
620
+ const tsgoDist = await mkdtemp(path.join(tmpdir(), "rolldown-plugin-dts-"));
621
+ debug$3("[tsgo] tsgoDist", tsgoDist);
622
+ const args = [
623
+ "--noEmit",
624
+ "false",
625
+ "--declaration",
626
+ "--emitDeclarationOnly",
627
+ ...tsconfig ? ["-p", tsconfig] : [],
628
+ "--outDir",
629
+ tsgoDist,
630
+ "--rootDir",
631
+ rootDir,
632
+ "--noCheck",
633
+ ...sourcemap ? ["--declarationMap"] : []
634
+ ];
635
+ debug$3("[tsgo] args %o", args);
636
+ await spawnAsync(tsgo, args, { stdio: "inherit" });
637
+ return tsgoDist;
638
+ }
639
+
640
+ //#endregion
641
+ //#region src/generate.ts
642
+ const debug$2 = createDebug("rolldown-plugin-dts:generate");
643
+ const WORKER_URL = "./tsc-worker.mjs";
608
644
  function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd, oxc, emitDtsOnly, vue, tsMacro, parallel, eager, tsgo, newContext, emitJs, sourcemap }) {
609
645
  const dtsMap = /* @__PURE__ */ new Map();
610
646
  /**
@@ -626,7 +662,7 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd,
626
662
  return {
627
663
  name: "rolldown-plugin-dts:generate",
628
664
  async buildStart(options) {
629
- if (tsgo) tsgoDist = await runTsgo(rootDir, tsconfig);
665
+ if (tsgo) tsgoDist = await runTsgo(rootDir, tsconfig, sourcemap);
630
666
  else if (!oxc) if (parallel) {
631
667
  childProcess = fork(new URL(WORKER_URL, import.meta.url), { stdio: "inherit" });
632
668
  rpc = (await import("birpc")).createBirpc({}, {
@@ -716,11 +752,19 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd,
716
752
  if (tsgo) {
717
753
  if (RE_VUE.test(id)) throw new Error("tsgo does not support Vue files.");
718
754
  const dtsPath = path.resolve(tsgoDist, path.relative(path.resolve(rootDir), filename_to_dts(id)));
719
- if (existsSync(dtsPath)) dtsCode = await readFile(dtsPath, "utf8");
720
- else {
755
+ if (!existsSync(dtsPath)) {
721
756
  debug$2("[tsgo]", dtsPath, "is missing");
722
757
  throw new Error(`tsgo did not generate dts file for ${id}, please check your tsconfig.`);
723
758
  }
759
+ dtsCode = await readFile(dtsPath, "utf8");
760
+ const mapPath = `${dtsPath}.map`;
761
+ if (existsSync(mapPath)) {
762
+ const mapRaw = await readFile(mapPath, "utf8");
763
+ map = {
764
+ ...JSON.parse(mapRaw),
765
+ sources: [id]
766
+ };
767
+ }
724
768
  } else if (oxc && !RE_VUE.test(id)) {
725
769
  const result = isolatedDeclarationSync(id, code, oxc);
726
770
  if (result.errors.length) {
@@ -797,27 +841,6 @@ export { __json_default_export as default }`;
797
841
  }
798
842
  };
799
843
  }
800
- async function runTsgo(rootDir, tsconfig) {
801
- const tsgoPkg = import.meta.resolve("@typescript/native-preview/package.json");
802
- const { default: getExePath } = await import(new URL("lib/getExePath.js", tsgoPkg).href);
803
- const tsgo = getExePath();
804
- const tsgoDist = await mkdtemp(path.join(tmpdir(), "rolldown-plugin-dts-"));
805
- debug$2("[tsgo] tsgoDist", tsgoDist);
806
- debug$2("[tsgo] rootDir", rootDir);
807
- await spawnAsync(tsgo, [
808
- "--noEmit",
809
- "false",
810
- "--declaration",
811
- "--emitDeclarationOnly",
812
- ...tsconfig ? ["-p", tsconfig] : [],
813
- "--outDir",
814
- tsgoDist,
815
- "--rootDir",
816
- rootDir,
817
- "--noCheck"
818
- ], { stdio: "inherit" });
819
- return tsgoDist;
820
- }
821
844
  function collectJsonExportMap(code) {
822
845
  const exportMap = /* @__PURE__ */ new Map();
823
846
  const { program } = parse(code, {
@@ -16,7 +16,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
16
16
 
17
17
  //#endregion
18
18
  //#region src/tsc/system.ts
19
- const debug$3 = createDebug("rolldown-plugin-dts:tsc-system");
19
+ const debug$4 = createDebug("rolldown-plugin-dts:tsc-system");
20
20
  /**
21
21
  * A system that writes files to both memory and disk. It will try read files
22
22
  * from memory firstly and fallback to disk if not found.
@@ -25,7 +25,7 @@ function createFsSystem(files) {
25
25
  return {
26
26
  ...ts.sys,
27
27
  write(message) {
28
- debug$3(message);
28
+ debug$4(message);
29
29
  },
30
30
  resolvePath(path$1) {
31
31
  if (files.has(path$1)) return path$1;
@@ -90,20 +90,20 @@ function setSourceMapRoot(map, originalFilePath, finalFilePath) {
90
90
 
91
91
  //#endregion
92
92
  //#region src/tsc/emit-build.ts
93
- const debug$2 = createDebug("rolldown-plugin-dts:tsc-build");
93
+ const debug$3 = createDebug("rolldown-plugin-dts:tsc-build");
94
94
  function tscEmitBuild(tscOptions) {
95
95
  const { id, tsconfig, incremental, context = globalContext, sourcemap } = tscOptions;
96
- debug$2(`running tscEmitBuild id: ${id}, tsconfig: ${tsconfig}, incremental: ${incremental}`);
96
+ debug$3(`running tscEmitBuild id: ${id}, tsconfig: ${tsconfig}, incremental: ${incremental}`);
97
97
  if (!tsconfig) return { error: "[rolldown-plugin-dts] build mode requires a tsconfig path" };
98
98
  const fsSystem = (incremental ? createFsSystem : createMemorySystem)(context.files);
99
99
  const resolvedId = fsSystem.resolvePath(id);
100
- if (resolvedId !== id) debug$2(`resolved id from ${id} to ${resolvedId}`);
100
+ if (resolvedId !== id) debug$3(`resolved id from ${id} to ${resolvedId}`);
101
101
  const project = getOrBuildProjects(context, fsSystem, tsconfig, !incremental, sourcemap).get(resolvedId);
102
102
  if (!project) {
103
- debug$2(`unable to locate a project containing ${resolvedId}`);
103
+ debug$3(`unable to locate a project containing ${resolvedId}`);
104
104
  return { error: `Unable to locate ${id} from the given tsconfig file ${tsconfig}` };
105
105
  }
106
- debug$2(`loaded project ${project.tsconfigPath} for ${id}`);
106
+ debug$3(`loaded project ${project.tsconfigPath} for ${id}`);
107
107
  const ignoreCase = !fsSystem.useCaseSensitiveFileNames;
108
108
  const outputFiles = ts.getOutputFileNames(project.parsedConfig, resolvedId, ignoreCase);
109
109
  let code;
@@ -133,20 +133,20 @@ function tscEmitBuild(tscOptions) {
133
133
  map
134
134
  };
135
135
  if (incremental) {
136
- debug$2(`incremental build failed`);
136
+ debug$3(`incremental build failed`);
137
137
  return tscEmitBuild({
138
138
  ...tscOptions,
139
139
  incremental: false
140
140
  });
141
141
  }
142
- debug$2(`unable to build .d.ts file for ${id}`);
142
+ debug$3(`unable to build .d.ts file for ${id}`);
143
143
  if (project.parsedConfig.options.declaration !== true) return { error: `Unable to build .d.ts file for ${id}; Make sure the "declaration" option is set to true in ${project.tsconfigPath}` };
144
144
  return { error: `Unable to build .d.ts file for ${id}; This seems like a bug of rolldown-plugin-dts. Please report this issue to https://github.com/sxzz/rolldown-plugin-dts/issues` };
145
145
  }
146
146
  function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
147
147
  let projectMap = context.projects.get(tsconfig);
148
148
  if (projectMap) {
149
- debug$2(`skip building projects for ${tsconfig}`);
149
+ debug$3(`skip building projects for ${tsconfig}`);
150
150
  return projectMap;
151
151
  }
152
152
  projectMap = buildProjects(fsSystem, tsconfig, force, sourcemap);
@@ -157,15 +157,15 @@ function getOrBuildProjects(context, fsSystem, tsconfig, force, sourcemap) {
157
157
  * Use TypeScript compiler to build all projects referenced
158
158
  */
159
159
  function buildProjects(fsSystem, tsconfig, force, sourcemap) {
160
- debug$2(`start building projects for ${tsconfig}`);
160
+ debug$3(`start building projects for ${tsconfig}`);
161
161
  const projects = collectProjectGraph(tsconfig, fsSystem, force, sourcemap);
162
- debug$2("collected %d projects: %j", projects.length, projects.map((project) => project.tsconfigPath));
162
+ debug$3("collected %d projects: %j", projects.length, projects.map((project) => project.tsconfigPath));
163
163
  const host = ts.createSolutionBuilderHost(fsSystem, createProgramWithPatchedCompilerOptions);
164
- debug$2(`built solution for ${tsconfig} with exit status ${ts.createSolutionBuilder(host, [tsconfig], {
164
+ debug$3(`built solution for ${tsconfig} with exit status ${ts.createSolutionBuilder(host, [tsconfig], {
165
165
  force,
166
166
  verbose: true
167
167
  }).build(void 0, void 0, void 0, (project) => {
168
- debug$2(`transforming project ${project}`);
168
+ debug$3(`transforming project ${project}`);
169
169
  return customTransformers;
170
170
  })}`);
171
171
  const sourceFileToProjectMap = /* @__PURE__ */ new Map();
@@ -244,33 +244,38 @@ const createProgramWithPatchedCompilerOptions = (rootNames, options, ...args) =>
244
244
 
245
245
  //#endregion
246
246
  //#region src/tsc/volar.ts
247
+ const debug$2 = createDebug("rolldown-plugin-dts:volar");
247
248
  function loadVueLanguageTools() {
248
- const debug$4 = createDebug("rolldown-plugin-dts:vue");
249
- debug$4("loading vue language tools");
249
+ debug$2("loading vue language tools");
250
250
  try {
251
251
  const vueTscPath = __require.resolve("vue-tsc");
252
- const { proxyCreateProgram } = __require(__require.resolve("@volar/typescript", { paths: [vueTscPath] }));
253
- const vue = __require(__require.resolve("@vue/language-core", { paths: [vueTscPath] }));
254
- const getLanguagePlugin = (ts$1, options) => {
255
- const $rootDir = options.options.$rootDir;
256
- const $configRaw = options.options.$configRaw;
257
- const resolver = new vue.CompilerOptionsResolver(ts$1, ts$1.sys.readFile);
258
- resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
259
- const vueOptions = resolver.build();
260
- return vue.createVueLanguagePlugin(ts$1, options.options, vueOptions, (id) => id);
261
- };
262
252
  return {
263
- proxyCreateProgram,
264
- getLanguagePlugin
253
+ volarTs: __require(__require.resolve("@volar/typescript", { paths: [vueTscPath] })),
254
+ vue: __require(__require.resolve("@vue/language-core", { paths: [vueTscPath] }))
265
255
  };
266
256
  } catch (error) {
267
- debug$4("vue language tools not found", error);
257
+ debug$2("vue language tools not found", error);
268
258
  throw new Error("Failed to load vue language tools. Please manually install vue-tsc.");
269
259
  }
270
260
  }
271
- function loadTsMacro() {
272
- const debug$4 = createDebug("rolldown-plugin-dts:ts-macro");
273
- debug$4("loading ts-macro language tools");
261
+ function initVueLanguageTools() {
262
+ const { vue, volarTs: { proxyCreateProgram } } = loadVueLanguageTools();
263
+ const getLanguagePlugin = (ts$1, options) => {
264
+ const $rootDir = options.options.$rootDir;
265
+ const $configRaw = options.options.$configRaw;
266
+ const resolver = new vue.CompilerOptionsResolver(ts$1, ts$1.sys.readFile);
267
+ resolver.addConfig($configRaw?.vueCompilerOptions ?? {}, $rootDir);
268
+ const vueOptions = resolver.build();
269
+ return vue.createVueLanguagePlugin(ts$1, options.options, vueOptions, (id) => id);
270
+ };
271
+ return {
272
+ proxyCreateProgram,
273
+ getLanguagePlugin
274
+ };
275
+ }
276
+ function initTsMacro() {
277
+ const debug$5 = createDebug("rolldown-plugin-dts:ts-macro");
278
+ debug$5("loading ts-macro language tools");
274
279
  try {
275
280
  const tsMacroPath = __require.resolve("@ts-macro/tsc");
276
281
  const { proxyCreateProgram } = __require(__require.resolve("@volar/typescript", { paths: [tsMacroPath] }));
@@ -285,13 +290,13 @@ function loadTsMacro() {
285
290
  getLanguagePlugin
286
291
  };
287
292
  } catch (error) {
288
- debug$4("ts-macro language tools not found", error);
293
+ debug$5("ts-macro language tools not found", error);
289
294
  throw new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.");
290
295
  }
291
296
  }
292
297
  function createProgramFactory(ts$1, options) {
293
- const vueLanguageTools = options.vue ? loadVueLanguageTools() : void 0;
294
- const tsMacroLanguageTools = options.tsMacro ? loadTsMacro() : void 0;
298
+ const vueLanguageTools = options.vue ? initVueLanguageTools() : void 0;
299
+ const tsMacroLanguageTools = options.tsMacro ? initTsMacro() : void 0;
295
300
  const proxyCreateProgram = vueLanguageTools?.proxyCreateProgram || tsMacroLanguageTools?.proxyCreateProgram;
296
301
  if (!proxyCreateProgram) return ts$1.createProgram;
297
302
  return proxyCreateProgram(ts$1, ts$1.createProgram, (ts$2, options$1) => {
@@ -340,7 +345,11 @@ function createOrGetTsModule(options) {
340
345
  function createTsProgram({ entries, id, tsconfig, tsconfigRaw, vue, tsMacro, cwd, context = globalContext }) {
341
346
  const fsSystem = createFsSystem(context.files);
342
347
  const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
343
- const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir);
348
+ const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir, void 0, void 0, void 0, vue ? [{
349
+ extension: "vue",
350
+ isMixedContent: true,
351
+ scriptKind: ts.ScriptKind.Deferred
352
+ }] : void 0);
344
353
  debug$1(`creating program for root project: ${baseDir}`);
345
354
  return createTsProgramFromParsedConfig({
346
355
  parsedConfig,
@@ -1,4 +1,4 @@
1
- import { t as tscEmit } from "./tsc-C0UrtIA5.mjs";
1
+ import { t as tscEmit } from "./tsc-DmkHlcNe.mjs";
2
2
  const process = globalThis.process;
3
3
  import { createBirpc } from "birpc";
4
4
 
package/dist/tsc.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as tscEmit } from "./tsc-C0UrtIA5.mjs";
1
+ import { t as tscEmit } from "./tsc-DmkHlcNe.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.0",
4
+ "version": "0.21.2",
5
5
  "description": "A Rolldown plugin to generate and bundle dts files.",
6
6
  "author": "Kevin Deng <sxzz@sxzz.moe>",
7
7
  "license": "MIT",
@@ -30,8 +30,6 @@
30
30
  "./tsc-worker": "./dist/tsc-worker.mjs",
31
31
  "./package.json": "./package.json"
32
32
  },
33
- "main": "./dist/index.mjs",
34
- "module": "./dist/index.mjs",
35
33
  "types": "./dist/index.d.mts",
36
34
  "files": [
37
35
  "dist"
@@ -64,9 +62,9 @@
64
62
  }
65
63
  },
66
64
  "dependencies": {
67
- "@babel/generator": "^7.28.5",
68
- "@babel/parser": "^7.28.5",
69
- "@babel/types": "^7.28.5",
65
+ "@babel/generator": "^7.28.6",
66
+ "@babel/parser": "^7.28.6",
67
+ "@babel/types": "^7.28.6",
70
68
  "ast-kit": "^2.2.0",
71
69
  "birpc": "^4.0.0",
72
70
  "dts-resolver": "^2.1.3",
@@ -74,32 +72,32 @@
74
72
  "obug": "^2.1.1"
75
73
  },
76
74
  "devDependencies": {
77
- "@sxzz/eslint-config": "^7.4.4",
75
+ "@sxzz/eslint-config": "^7.4.5",
78
76
  "@sxzz/prettier-config": "^2.2.6",
79
77
  "@sxzz/test-utils": "^0.5.15",
80
78
  "@types/babel__generator": "^7.27.0",
81
- "@types/node": "^25.0.3",
82
- "@typescript/native-preview": "7.0.0-dev.20251228.1",
79
+ "@types/node": "^25.0.8",
80
+ "@typescript/native-preview": "7.0.0-dev.20260115.1",
83
81
  "@volar/typescript": "^2.4.27",
84
- "@vue/language-core": "^3.2.1",
82
+ "@vue/language-core": "^3.2.2",
85
83
  "arktype": "^2.1.29",
86
- "bumpp": "^10.3.2",
87
- "diff": "^8.0.2",
84
+ "bumpp": "^10.4.0",
85
+ "diff": "^8.0.3",
88
86
  "eslint": "^9.39.2",
89
- "prettier": "^3.7.4",
90
- "rolldown": "^1.0.0-beta.57",
87
+ "prettier": "^3.8.0",
88
+ "rolldown": "^1.0.0-beta.60",
91
89
  "rolldown-plugin-dts-snapshot": "^0.3.2",
92
90
  "rolldown-plugin-require-cjs": "^0.3.3",
93
91
  "rollup-plugin-dts": "^6.3.0",
94
92
  "tinyglobby": "^0.2.15",
95
- "tsdown": "^0.18.3",
93
+ "tsdown": "^0.20.0-beta.3",
96
94
  "typescript": "^5.9.3",
97
- "vitest": "^4.0.16",
95
+ "vitest": "^4.0.17",
98
96
  "vue": "^3.5.26",
99
- "vue-tsc": "^3.2.1"
97
+ "vue-tsc": "^3.2.2"
100
98
  },
101
99
  "resolutions": {
102
- "rolldown": "^1.0.0-beta.57"
100
+ "rolldown": "^1.0.0-beta.60"
103
101
  },
104
102
  "prettier": "@sxzz/prettier-config",
105
103
  "scripts": {