rolldown-plugin-dts 0.26.0 → 0.27.0
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/{context-_3g_7Eca.d.mts → context-CcXGRVeM.d.mts} +0 -1
- package/dist/{index-DFO9SbW-.d.mts → index-Pfhuikcq.d.mts} +1 -2
- package/dist/index.d.mts +149 -193
- package/dist/index.mjs +212 -312
- package/dist/internal.d.mts +0 -1
- package/dist/{tsc-DBLgyoBn.mjs → tsc-CgJ-ct_1.mjs} +12 -4
- package/dist/tsc-context.d.mts +1 -1
- package/dist/tsc-worker.d.mts +11 -7
- package/dist/tsc-worker.mjs +15 -5
- package/dist/tsc.d.mts +1 -1
- package/dist/tsc.mjs +1 -1
- package/package.json +17 -20
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { r as TscContext } from "./context-
|
|
1
|
+
import { r as TscContext } from "./context-CcXGRVeM.mjs";
|
|
2
2
|
import { SourceMapInput } from "rolldown";
|
|
3
3
|
import { TsconfigJson } from "get-tsconfig";
|
|
4
4
|
import ts from "typescript";
|
|
5
|
-
|
|
6
5
|
//#region src/tsc/types.d.ts
|
|
7
6
|
interface TscModule {
|
|
8
7
|
program: ts.Program;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,205 +1,204 @@
|
|
|
1
1
|
import { Plugin } from "rolldown";
|
|
2
2
|
import { IsolatedDeclarationsOptions } from "rolldown/experimental";
|
|
3
3
|
import { TsconfigJson } from "get-tsconfig";
|
|
4
|
-
|
|
5
4
|
//#region src/options.d.ts
|
|
6
5
|
interface GeneralOptions {
|
|
7
6
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
* Glob pattern(s) to filter which entry files get `.d.ts` generation.
|
|
8
|
+
*
|
|
9
|
+
* When specified, only entry files matching these patterns will emit `.d.ts` chunks.
|
|
10
|
+
* When not specified, all entries get `.d.ts` generation.
|
|
11
|
+
*
|
|
12
|
+
* Supports negation patterns (e.g., `['**', '!src/icons/**']`) for exclusion.
|
|
13
|
+
* Patterns are matched against file paths relative to `cwd`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* entry: 'src/index.ts'
|
|
17
|
+
* entry: ['src/*.ts', '!src/internal/**']
|
|
18
|
+
*/
|
|
20
19
|
entry?: string | string[];
|
|
21
20
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
* The directory in which the plugin will search for the `tsconfig.json` file.
|
|
22
|
+
*/
|
|
24
23
|
cwd?: string;
|
|
25
24
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
* Set to `true` if your entry files are `.d.ts` files instead of `.ts` files.
|
|
26
|
+
*
|
|
27
|
+
* When enabled, the plugin will skip generating a `.d.ts` file for the entry point.
|
|
28
|
+
*/
|
|
30
29
|
dtsInput?: boolean;
|
|
31
30
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
* If `true`, the plugin will emit only `.d.ts` files and remove all other output chunks.
|
|
32
|
+
*
|
|
33
|
+
* This is especially useful when generating `.d.ts` files for the CommonJS format as part of a separate build step.
|
|
34
|
+
*/
|
|
36
35
|
emitDtsOnly?: boolean;
|
|
37
36
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
* The path to the `tsconfig.json` file.
|
|
38
|
+
*
|
|
39
|
+
* If set to `false`, the plugin will ignore any `tsconfig.json` file.
|
|
40
|
+
* You can still specify `compilerOptions` directly in the options.
|
|
41
|
+
*
|
|
42
|
+
* @default 'tsconfig.json'
|
|
43
|
+
*/
|
|
45
44
|
tsconfig?: string | boolean;
|
|
46
45
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
* Pass a raw `tsconfig.json` object directly to the plugin.
|
|
47
|
+
*
|
|
48
|
+
* @see https://www.typescriptlang.org/tsconfig
|
|
49
|
+
*/
|
|
51
50
|
tsconfigRaw?: Omit<TsconfigJson, "compilerOptions">;
|
|
52
51
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
* Override the `compilerOptions` specified in `tsconfig.json`.
|
|
53
|
+
*
|
|
54
|
+
* @see https://www.typescriptlang.org/tsconfig/#compilerOptions
|
|
55
|
+
*/
|
|
57
56
|
compilerOptions?: TsconfigJson.CompilerOptions;
|
|
58
57
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
* If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
|
|
59
|
+
*/
|
|
61
60
|
sourcemap?: boolean;
|
|
62
61
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
* Specifies a resolver to resolve type definitions, especially for `node_modules`.
|
|
63
|
+
*
|
|
64
|
+
* - `'oxc'`: Uses Oxc's module resolution, which is faster and more efficient.
|
|
65
|
+
* - `'tsc'`: Uses TypeScript's native module resolution, which may be more compatible with complex setups, but slower.
|
|
66
|
+
*
|
|
67
|
+
* @default 'oxc'
|
|
68
|
+
*/
|
|
70
69
|
resolver?: "oxc" | "tsc";
|
|
71
70
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
* Determines how the default export is emitted.
|
|
72
|
+
*
|
|
73
|
+
* If set to `true`, and you are only exporting a single item using `export default ...`,
|
|
74
|
+
* the output will use `export = ...` instead of the standard ES module syntax.
|
|
75
|
+
* This is useful for compatibility with CommonJS.
|
|
76
|
+
* This only controls the output format and does not enable support for
|
|
77
|
+
* CommonJS-style `.d.ts` input.
|
|
78
|
+
*/
|
|
80
79
|
cjsDefault?: boolean;
|
|
81
80
|
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
* Indicates whether the generated `.d.ts` files have side effects.
|
|
82
|
+
* - If set to `true`, Rolldown will treat the `.d.ts` files as having side effects during tree-shaking.
|
|
83
|
+
* - If set to `false`, Rolldown may consider the `.d.ts` files as side-effect-free, potentially removing them if they are not imported.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
88
87
|
sideEffects?: boolean;
|
|
89
88
|
}
|
|
90
89
|
interface TscOptions {
|
|
91
90
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
* Build mode for the TypeScript compiler:
|
|
92
|
+
*
|
|
93
|
+
* - 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.
|
|
94
|
+
* - 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.
|
|
95
|
+
*
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
99
98
|
build?: boolean;
|
|
100
99
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
100
|
+
* If your tsconfig.json has
|
|
101
|
+
* [`references`](https://www.typescriptlang.org/tsconfig/#references) option,
|
|
102
|
+
* `rolldown-plugin-dts` will use [`tsc
|
|
103
|
+
* -b`](https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript)
|
|
104
|
+
* to build the project and all referenced projects before emitting `.d.ts`
|
|
105
|
+
* files.
|
|
106
|
+
*
|
|
107
|
+
* In such case, if this option is `true`, `rolldown-plugin-dts` will write
|
|
108
|
+
* down all built files into your disk, including
|
|
109
|
+
* [`.tsbuildinfo`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)
|
|
110
|
+
* and other built files. This is equivalent to running `tsc -b` in your
|
|
111
|
+
* project.
|
|
112
|
+
*
|
|
113
|
+
* Otherwise, if this option is `false`, `rolldown-plugin-dts` will write
|
|
114
|
+
* built files only into memory and leave a small footprint in your disk.
|
|
115
|
+
*
|
|
116
|
+
* Enabling this option will decrease the build time by caching previous build
|
|
117
|
+
* results. This is helpful when you have a large project with multiple
|
|
118
|
+
* referenced projects.
|
|
119
|
+
*
|
|
120
|
+
* By default, `incremental` is `true` if your tsconfig has
|
|
121
|
+
* [`incremental`](https://www.typescriptlang.org/tsconfig/#incremental) or
|
|
122
|
+
* [`tsBuildInfoFile`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)
|
|
123
|
+
* enabled.
|
|
124
|
+
*
|
|
125
|
+
* This option is only used when {@link Options.oxc} is
|
|
126
|
+
* `false`.
|
|
127
|
+
*/
|
|
129
128
|
incremental?: boolean;
|
|
130
129
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
* If `true`, the plugin will generate `.d.ts` files using `vue-tsc`.
|
|
131
|
+
*/
|
|
133
132
|
vue?: boolean;
|
|
134
133
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
* If `true`, the plugin will generate `.d.ts` files using `@ts-macro/tsc`.
|
|
135
|
+
*/
|
|
137
136
|
tsMacro?: boolean;
|
|
138
137
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
* If `true`, the plugin will launch a separate process for `tsc` or `vue-tsc`.
|
|
139
|
+
* This enables processing multiple projects in parallel.
|
|
140
|
+
*/
|
|
142
141
|
parallel?: boolean;
|
|
143
142
|
/**
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
* If `true`, the plugin will prepare all files listed in `tsconfig.json` for `tsc` or `vue-tsc`.
|
|
144
|
+
*
|
|
145
|
+
* This is especially useful when you have a single `tsconfig.json` for multiple projects in a monorepo.
|
|
146
|
+
*/
|
|
148
147
|
eager?: boolean;
|
|
149
148
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
149
|
+
* If `true`, the plugin will create a new isolated context for each build,
|
|
150
|
+
* ensuring that previously generated `.d.ts` code and caches are not reused.
|
|
151
|
+
*
|
|
152
|
+
* By default, the plugin may reuse internal caches or incremental build artifacts
|
|
153
|
+
* to speed up repeated builds. Enabling this option forces a clean context,
|
|
154
|
+
* guaranteeing that all type definitions are generated from scratch.
|
|
155
|
+
*
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
159
158
|
newContext?: boolean;
|
|
160
159
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
160
|
+
* If `true`, the plugin will emit `.d.ts` files for `.js` files as well.
|
|
161
|
+
* This is useful when you want to generate type definitions for JavaScript files with JSDoc comments.
|
|
162
|
+
*
|
|
163
|
+
* Enabled by default when `allowJs` in compilerOptions is `true`.
|
|
164
|
+
* This option is only used when {@link Options.oxc} is
|
|
165
|
+
* `false`.
|
|
166
|
+
*/
|
|
168
167
|
emitJs?: boolean;
|
|
169
168
|
}
|
|
170
169
|
interface Options extends GeneralOptions, TscOptions {
|
|
171
170
|
/**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
* If `true`, the plugin will generate `.d.ts` files using Oxc,
|
|
172
|
+
* which is significantly faster than the TypeScript compiler.
|
|
173
|
+
*
|
|
174
|
+
* This option is automatically enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
|
|
175
|
+
*/
|
|
177
176
|
oxc?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
|
|
178
177
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
178
|
+
* **[Experimental]** Enables DTS generation using `tsgo`.
|
|
179
|
+
*
|
|
180
|
+
* To use this option, make sure `@typescript/native-preview` is installed as a dependency,
|
|
181
|
+
* or provide a custom path to the `tsgo` binary using the `path` option.
|
|
182
|
+
*
|
|
183
|
+
* **Note:** This option is not yet recommended for production environments.
|
|
184
|
+
* `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
|
|
185
|
+
*
|
|
186
|
+
*
|
|
187
|
+
* ```ts
|
|
188
|
+
* // Use tsgo from `@typescript/native-preview` dependency
|
|
189
|
+
* tsgo: true
|
|
190
|
+
*
|
|
191
|
+
* // Use custom tsgo path (e.g., managed by Nix)
|
|
192
|
+
* tsgo: { path: '/path/to/tsgo' }
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
196
195
|
tsgo?: boolean | TsgoOptions;
|
|
197
196
|
}
|
|
198
197
|
interface TsgoOptions {
|
|
199
198
|
enabled?: boolean;
|
|
200
199
|
/**
|
|
201
|
-
|
|
202
|
-
|
|
200
|
+
* Custom path to the `tsgo` binary.
|
|
201
|
+
*/
|
|
203
202
|
path?: string;
|
|
204
203
|
}
|
|
205
204
|
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
@@ -210,56 +209,13 @@ type OptionsResolved = Overwrite<Required<Omit<Options, "compilerOptions">>, {
|
|
|
210
209
|
tsconfigRaw: TsconfigJson;
|
|
211
210
|
tsgo: Omit<TsgoOptions, "enabled"> | false;
|
|
212
211
|
}>;
|
|
213
|
-
declare function resolveOptions({
|
|
214
|
-
entry,
|
|
215
|
-
cwd,
|
|
216
|
-
dtsInput,
|
|
217
|
-
emitDtsOnly,
|
|
218
|
-
tsconfig,
|
|
219
|
-
tsconfigRaw: overriddenTsconfigRaw,
|
|
220
|
-
compilerOptions,
|
|
221
|
-
sourcemap,
|
|
222
|
-
resolver,
|
|
223
|
-
cjsDefault,
|
|
224
|
-
sideEffects,
|
|
225
|
-
build,
|
|
226
|
-
incremental,
|
|
227
|
-
vue,
|
|
228
|
-
tsMacro,
|
|
229
|
-
parallel,
|
|
230
|
-
eager,
|
|
231
|
-
newContext,
|
|
232
|
-
emitJs,
|
|
233
|
-
oxc,
|
|
234
|
-
tsgo
|
|
235
|
-
}: Options): OptionsResolved;
|
|
212
|
+
declare function resolveOptions({ entry, cwd, dtsInput, emitDtsOnly, tsconfig, tsconfigRaw: overriddenTsconfigRaw, compilerOptions, sourcemap, resolver, cjsDefault, sideEffects, build, incremental, vue, tsMacro, parallel, eager, newContext, emitJs, oxc, tsgo }: Options): OptionsResolved;
|
|
236
213
|
//#endregion
|
|
237
214
|
//#region src/fake-js.d.ts
|
|
238
|
-
declare function createFakeJsPlugin({
|
|
239
|
-
sourcemap,
|
|
240
|
-
cjsDefault,
|
|
241
|
-
sideEffects
|
|
242
|
-
}: Pick<OptionsResolved, "sourcemap" | "cjsDefault" | "sideEffects">): Plugin;
|
|
215
|
+
declare function createFakeJsPlugin({ sourcemap, cjsDefault, sideEffects }: Pick<OptionsResolved, "sourcemap" | "cjsDefault" | "sideEffects">): Plugin;
|
|
243
216
|
//#endregion
|
|
244
217
|
//#region src/generate.d.ts
|
|
245
|
-
declare function createGeneratePlugin({
|
|
246
|
-
entry,
|
|
247
|
-
tsconfig,
|
|
248
|
-
tsconfigRaw,
|
|
249
|
-
build,
|
|
250
|
-
incremental,
|
|
251
|
-
cwd,
|
|
252
|
-
oxc,
|
|
253
|
-
emitDtsOnly,
|
|
254
|
-
vue,
|
|
255
|
-
tsMacro,
|
|
256
|
-
parallel,
|
|
257
|
-
eager,
|
|
258
|
-
tsgo,
|
|
259
|
-
newContext,
|
|
260
|
-
emitJs,
|
|
261
|
-
sourcemap
|
|
262
|
-
}: Pick<OptionsResolved, "entry" | "cwd" | "tsconfig" | "tsconfigRaw" | "build" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "tsMacro" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs" | "sourcemap">): Plugin;
|
|
218
|
+
declare function createGeneratePlugin({ entry, tsconfig, tsconfigRaw, build, incremental, cwd, oxc, emitDtsOnly, vue, tsMacro, parallel, eager, tsgo, newContext, emitJs, sourcemap }: Pick<OptionsResolved, "entry" | "cwd" | "tsconfig" | "tsconfigRaw" | "build" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "tsMacro" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs" | "sourcemap">): Plugin;
|
|
263
219
|
//#endregion
|
|
264
220
|
//#region src/index.d.ts
|
|
265
221
|
declare function dts(options?: Options): Plugin[];
|