rolldown-plugin-dts 0.15.0 → 0.15.1

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
@@ -91,11 +91,19 @@ Resolve external types used in `.d.ts` files from `node_modules`.
91
91
  > [!NOTE]
92
92
  > These options are only applicable when `oxc` and `tsgo` are not enabled.
93
93
 
94
+ #### `build`
95
+
96
+ Build mode for the TypeScript compiler:
97
+
98
+ - 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.
99
+ - 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.
100
+
101
+ **Default:** `false`
102
+
94
103
  #### `incremental`
95
104
 
96
105
  Controls how project references and incremental builds are handled:
97
106
 
98
- - If your `tsconfig.json` uses [`references`](https://www.typescriptlang.org/tsconfig/#references), 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.
99
107
  - If `incremental` is `true`, all built files (including [`.tsbuildinfo`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)) will be written to disk, similar to running `tsc -b` in your project.
100
108
  - If `incremental` is `false`, built files are kept in memory, minimizing disk usage.
101
109
 
@@ -12,6 +12,7 @@ interface TscOptions {
12
12
  tsconfig?: string;
13
13
  tsconfigRaw: TsConfigJson;
14
14
  cwd: string;
15
+ build: boolean;
15
16
  incremental: boolean;
16
17
  entries?: string[];
17
18
  id: string;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { TsConfigJson } from "get-tsconfig";
4
4
  import { Plugin } from "rolldown";
5
5
 
6
6
  //#region src/options.d.ts
7
- interface Options {
7
+ interface GeneralOptions {
8
8
  /**
9
9
  * The directory in which the plugin will search for the `tsconfig.json` file.
10
10
  */
@@ -37,6 +37,31 @@ interface Options {
37
37
  */
38
38
  tsconfigRaw?: Omit<TsConfigJson, "compilerOptions">;
39
39
  /**
40
+ * Override the `compilerOptions` specified in `tsconfig.json`.
41
+ *
42
+ * @see https://www.typescriptlang.org/tsconfig/#compilerOptions
43
+ */
44
+ compilerOptions?: TsConfigJson.CompilerOptions;
45
+ /**
46
+ * If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
47
+ */
48
+ sourcemap?: boolean;
49
+ /**
50
+ * Resolve external types used in `.d.ts` files from `node_modules`.
51
+ */
52
+ resolve?: boolean | (string | RegExp)[];
53
+ }
54
+ interface TscOptions {
55
+ /**
56
+ * Build mode for the TypeScript compiler:
57
+ *
58
+ * - 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.
59
+ * - 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.
60
+ *
61
+ * @default false
62
+ */
63
+ build?: boolean;
64
+ /**
40
65
  * If your tsconfig.json has
41
66
  * [`references`](https://www.typescriptlang.org/tsconfig/#references) option,
42
67
  * `rolldown-plugin-dts` will use [`tsc
@@ -67,27 +92,6 @@ interface Options {
67
92
  */
68
93
  incremental?: boolean;
69
94
  /**
70
- * Override the `compilerOptions` specified in `tsconfig.json`.
71
- *
72
- * @see https://www.typescriptlang.org/tsconfig/#compilerOptions
73
- */
74
- compilerOptions?: TsConfigJson.CompilerOptions;
75
- /**
76
- * If `true`, the plugin will generate `.d.ts` files using Oxc,
77
- * which is significantly faster than the TypeScript compiler.
78
- *
79
- * This option is automatically enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
80
- */
81
- oxc?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
82
- /**
83
- * If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
84
- */
85
- sourcemap?: boolean;
86
- /**
87
- * Resolve external types used in `.d.ts` files from `node_modules`.
88
- */
89
- resolve?: boolean | (string | RegExp)[];
90
- /**
91
95
  * If `true`, the plugin will generate `.d.ts` files using `vue-tsc`.
92
96
  */
93
97
  vue?: boolean;
@@ -103,15 +107,6 @@ interface Options {
103
107
  */
104
108
  eager?: boolean;
105
109
  /**
106
- * **[Experimental]** Enables DTS generation using `tsgo`.
107
- *
108
- * To use this option, make sure `@typescript/native-preview` is installed as a dependency.
109
- *
110
- * **Note:** This option is not yet recommended for production environments.
111
- * `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
112
- */
113
- tsgo?: boolean;
114
- /**
115
110
  * If `true`, the plugin will create a new isolated context for each build,
116
111
  * ensuring that previously generated `.d.ts` code and caches are not reused.
117
112
  *
@@ -132,6 +127,24 @@ interface Options {
132
127
  */
133
128
  emitJs?: boolean;
134
129
  }
130
+ interface Options extends GeneralOptions, TscOptions {
131
+ /**
132
+ * If `true`, the plugin will generate `.d.ts` files using Oxc,
133
+ * which is significantly faster than the TypeScript compiler.
134
+ *
135
+ * This option is automatically enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
136
+ */
137
+ oxc?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
138
+ /**
139
+ * **[Experimental]** Enables DTS generation using `tsgo`.
140
+ *
141
+ * To use this option, make sure `@typescript/native-preview` is installed as a dependency.
142
+ *
143
+ * **Note:** This option is not yet recommended for production environments.
144
+ * `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
145
+ */
146
+ tsgo?: boolean;
147
+ }
135
148
  type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
136
149
  type OptionsResolved = Overwrite<Required<Omit<Options, "compilerOptions">>, {
137
150
  tsconfig: string | undefined;
@@ -140,21 +153,22 @@ type OptionsResolved = Overwrite<Required<Omit<Options, "compilerOptions">>, {
140
153
  }>;
141
154
  declare function resolveOptions({
142
155
  cwd,
156
+ dtsInput,
157
+ emitDtsOnly,
143
158
  tsconfig,
144
- incremental,
145
- compilerOptions,
146
159
  tsconfigRaw: overriddenTsconfigRaw,
147
- oxc,
160
+ compilerOptions,
148
161
  sourcemap,
149
- dtsInput,
150
- emitDtsOnly,
151
162
  resolve,
163
+ build,
164
+ incremental,
152
165
  vue,
153
166
  parallel,
154
167
  eager,
155
- tsgo,
156
168
  newContext,
157
- emitJs
169
+ emitJs,
170
+ oxc,
171
+ tsgo
158
172
  }: Options): OptionsResolved;
159
173
  //#endregion
160
174
  //#region src/fake-js.d.ts
@@ -167,6 +181,7 @@ declare function createFakeJsPlugin({
167
181
  declare function createGeneratePlugin({
168
182
  tsconfig,
169
183
  tsconfigRaw,
184
+ build,
170
185
  incremental,
171
186
  cwd,
172
187
  oxc,
@@ -177,7 +192,7 @@ declare function createGeneratePlugin({
177
192
  tsgo,
178
193
  newContext,
179
194
  emitJs
180
- }: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs">): Plugin;
195
+ }: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "build" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs">): Plugin;
181
196
  //#endregion
182
197
  //#region src/index.d.ts
183
198
  declare function dts(options?: Options): Plugin[];
package/dist/index.js CHANGED
@@ -639,7 +639,7 @@ const spawnAsync = (...args) => new Promise((resolve, reject) => {
639
639
  child.on("close", () => resolve());
640
640
  child.on("error", (error) => reject(error));
641
641
  });
642
- function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, oxc, emitDtsOnly, vue, parallel, eager, tsgo, newContext, emitJs }) {
642
+ function createGeneratePlugin({ tsconfig, tsconfigRaw, build, incremental, cwd, oxc, emitDtsOnly, vue, parallel, eager, tsgo, newContext, emitJs }) {
643
643
  const dtsMap = /* @__PURE__ */ new Map();
644
644
  /**
645
645
  * A map of input id to output file name
@@ -765,6 +765,7 @@ function createGeneratePlugin({ tsconfig, tsconfigRaw, incremental, cwd, oxc, em
765
765
  const options = {
766
766
  tsconfig,
767
767
  tsconfigRaw,
768
+ build,
768
769
  incremental,
769
770
  cwd,
770
771
  entries,
@@ -827,7 +828,7 @@ async function runTsgo(root, tsconfig) {
827
828
  //#endregion
828
829
  //#region src/options.ts
829
830
  let warnedTsgo = false;
830
- function resolveOptions({ cwd = process.cwd(), tsconfig, incremental = false, compilerOptions = {}, tsconfigRaw: overriddenTsconfigRaw = {}, oxc, sourcemap, dtsInput = false, emitDtsOnly = false, resolve = false, vue = false, parallel = false, eager = false, tsgo = false, newContext = false, emitJs }) {
831
+ function resolveOptions({ cwd = process.cwd(), dtsInput = false, emitDtsOnly = false, tsconfig, tsconfigRaw: overriddenTsconfigRaw = {}, compilerOptions = {}, sourcemap, resolve = false, build = false, incremental = false, vue = false, parallel = false, eager = false, newContext = false, emitJs, oxc, tsgo = false }) {
831
832
  let resolvedTsconfig;
832
833
  if (tsconfig === true || tsconfig == null) {
833
834
  const { config, path: path$1 } = getTsconfig(cwd) || {};
@@ -867,20 +868,21 @@ function resolveOptions({ cwd = process.cwd(), tsconfig, incremental = false, co
867
868
  }
868
869
  return {
869
870
  cwd,
871
+ dtsInput,
872
+ emitDtsOnly,
870
873
  tsconfig,
871
874
  tsconfigRaw,
872
- incremental,
873
- oxc,
874
875
  sourcemap,
875
- dtsInput,
876
- emitDtsOnly,
877
876
  resolve,
877
+ build,
878
+ incremental,
878
879
  vue,
879
880
  parallel,
880
881
  eager,
881
- tsgo,
882
882
  newContext,
883
- emitJs
883
+ emitJs,
884
+ oxc,
885
+ tsgo
884
886
  };
885
887
  }
886
888
 
@@ -177,11 +177,11 @@ function parseTsconfig(tsconfigPath, fsSystem) {
177
177
  if (diagnostics.length) throw new Error(`[rolldown-plugin-dts] Unable to read ${tsconfigPath}: ${ts.formatDiagnostics(diagnostics, formatHost)}`);
178
178
  return parsedConfig;
179
179
  }
180
- function createTsProgram({ entries, id, tsconfig, tsconfigRaw, incremental, vue, cwd, context = globalContext }) {
180
+ function createTsProgram({ entries, id, tsconfig, tsconfigRaw, build, incremental, vue, cwd, context = globalContext }) {
181
181
  const fsSystem = createFsSystem(context.files);
182
182
  const baseDir = tsconfig ? path.dirname(tsconfig) : cwd;
183
183
  const parsedConfig = ts.parseJsonConfigFileContent(tsconfigRaw, fsSystem, baseDir);
184
- if (tsconfig && parsedConfig.projectReferences?.length) {
184
+ if (tsconfig && build) {
185
185
  const projectPaths = buildSolution(tsconfig, incremental, context);
186
186
  debug(`collected projects: ${JSON.stringify(projectPaths)}`);
187
187
  const project = findProjectContainingFile(projectPaths, id, fsSystem);
@@ -1,5 +1,5 @@
1
1
  import "./context-DIRjVfC4.js";
2
- import { tscEmit } from "./index-D_X_vGiL.js";
2
+ import { tscEmit } from "./index-BPD4iQBs.js";
3
3
 
4
4
  //#region src/tsc/worker.d.ts
5
5
  declare const functions: {
@@ -1,5 +1,5 @@
1
1
  import "./context-BG0dlajy.js";
2
- import { tscEmit } from "./tsc-BjWJCGE1.js";
2
+ import { tscEmit } from "./tsc-BSxLVaDe.js";
3
3
  import process from "node:process";
4
4
  import { createBirpc } from "birpc";
5
5
 
package/dist/tsc.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import "./context-DIRjVfC4.js";
2
- import { TscModule, TscOptions, TscResult, tscEmit } from "./index-D_X_vGiL.js";
2
+ import { TscModule, TscOptions, TscResult, tscEmit } from "./index-BPD4iQBs.js";
3
3
  export { TscModule, TscOptions, TscResult, tscEmit };
package/dist/tsc.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./context-BG0dlajy.js";
2
- import { tscEmit } from "./tsc-BjWJCGE1.js";
2
+ import { tscEmit } from "./tsc-BSxLVaDe.js";
3
3
 
4
4
  export { tscEmit };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "A Rolldown plugin to bundle dts files",
5
5
  "type": "module",
6
6
  "license": "MIT",