vite-plugin-dts 4.2.3 → 4.3.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/README.md CHANGED
@@ -1,417 +1,417 @@
1
- <h1 align="center">vite-plugin-dts</h1>
2
-
3
- <p align="center">
4
- A Vite plugin that generates declaration files (<code>*.d.ts</code>) from <code>.ts(x)</code> or <code>.vue</code> source files when using Vite in <a href="https://vitejs.dev/guide/build.html#library-mode">library mode</a>.
5
- </p>
6
-
7
- <p align="center">
8
- <a href="https://www.npmjs.com/package/vite-plugin-dts">
9
- <img src="https://img.shields.io/npm/v/vite-plugin-dts?color=orange&label=" alt="version" />
10
- </a>
11
- <a href="https://github.com/qmhc/vite-plugin-dts/blob/main/LICENSE">
12
- <img src="https://img.shields.io/npm/l/vite-plugin-dts" alt="license" />
13
- </a>
14
- </p>
15
-
16
- **English** | [中文](./README.zh-CN.md)
17
-
18
- ## Install
19
-
20
- ```sh
21
- pnpm i vite-plugin-dts -D
22
- ```
23
-
24
- ## Usage
25
-
26
- In `vite.config.ts`:
27
-
28
- ```ts
29
- import { resolve } from 'path'
30
- import { defineConfig } from 'vite'
31
- import dts from 'vite-plugin-dts'
32
-
33
- export default defineConfig({
34
- build: {
35
- lib: {
36
- entry: resolve(__dirname, 'src/index.ts'),
37
- name: 'MyLib',
38
- formats: ['es'],
39
- fileName: 'my-lib'
40
- }
41
- },
42
- plugins: [dts()]
43
- })
44
- ```
45
-
46
- By default, the generated declaration files are following the source structure.
47
-
48
- If you want to merge all declarations into one file, just specify `rollupTypes: true`:
49
-
50
- ```ts
51
- {
52
- plugins: [dts({ rollupTypes: true })]
53
- }
54
- ```
55
-
56
- If you start with official Vite template, you should specify the `tsconfigPath`:
57
-
58
- ```ts
59
- {
60
- plugins: [dts({ tsconfigPath: './tsconfig.app.json' })]
61
- }
62
- ```
63
-
64
- Starting with `3.0.0`, you can use this plugin with Rollup.
65
-
66
- ## FAQ
67
-
68
- Here are some FAQ's and solutions.
69
-
70
- ### Type errors that are unable to infer types from packages in `node_modules`
71
-
72
- This is an existing [TypeScript issue](https://github.com/microsoft/TypeScript/issues/42873) where TypeScript infers types from packages located in `node_modules` through soft links (pnpm). A workaround is to add `baseUrl` to your `tsconfig.json` and specify the `paths` for these packages:
73
-
74
- ```json
75
- {
76
- "compilerOptions": {
77
- "baseUrl": ".",
78
- "paths": {
79
- "third-lib": ["node_modules/third-lib"]
80
- }
81
- }
82
- }
83
- ```
84
-
85
- ### `Internal Error` occurs when using `rollupTypes: true`
86
-
87
- Refer to this [issue](https://github.com/microsoft/rushstack/issues/3875), it's due to a limitation of `@microsoft/api-extractor` or TypeScript resolver.
88
-
89
- The main reason is that `baseUrl` is specified in `tsconfig.json` and non-standard paths are used directly when imported.
90
-
91
- For example: `baseUrl: 'src'` is specified and importing from `<root>/src/components/index.ts` in `<root>/src/index.ts`, and `import 'components'` is used instead of `import './components'`.
92
-
93
- Currently, you need to avoid the above situation, or use aliases instead (with the `paths` option).
94
-
95
- ### Get module not found errors during build
96
-
97
- This is likely due to incorrect configuration of the `include` property in your default `tsconfig.json`.
98
-
99
- Due to some limitations, the plugin relies on the top-level `tsconfig.json` to resolve the files to include. Therefore, you need to specify the correct `include` property in the top-level `tsconfig.json`, or you can specify a configuration file path with the correct `include` property using the `tsconfigPath` option of the plugin. For example, in the Vite initial template, it is `tsconfig.app.json`.
100
-
101
- You can refer to this [comment](https://github.com/qmhc/vite-plugin-dts/issues/343#issuecomment-2198111439).
102
-
103
- <details>
104
- <summary>Legacy</summary>
105
-
106
- ### Missing some declaration files after build (before `1.7.0`)
107
-
108
- By default, the `skipDiagnostics` option is set to `true` which means type diagnostics will be skipped during the build process (some projects may have diagnostic tools such as `vue-tsc`). Files with type errors which interrupt the build process will not be emitted (declaration files won't be generated).
109
-
110
- If your project doesn't use type diagnostic tools, you can set `skipDiagnostics: false` and `logDiagnostics: true` to turn on diagnostic and logging features of this plugin. Type errors during build will be logged to the terminal.
111
-
112
- ### Type error when using both `script` and `setup-script` in Vue component (before `3.0.0`)
113
-
114
- This is usually caused by using the `defineComponent` function in both `script` and `setup-script`. When `vue/compiler-sfc` compiles these files, the default export result from `script` gets merged with the parameter object of `defineComponent` from `setup-script`. This is incompatible with parameters and types returned from `defineComponent`. This results in a type error.
115
-
116
- Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/examples/vue/components/BothScripts.vue). You should remove the `defineComponent` in `script` and export a native object directly.
117
-
118
- </details>
119
-
120
- ## Options
121
-
122
- ```ts
123
- import type ts from 'typescript'
124
- import type { IExtractorConfigPrepareOptions, IExtractorInvokeOptions } from '@microsoft/api-extractor'
125
- import type { LogLevel } from 'vite'
126
-
127
- type MaybePromise<T> = T | Promise<T>
128
-
129
- export type RollupConfig = Omit<
130
- IExtractorConfigPrepareOptions['configObject'],
131
- | 'projectFolder'
132
- | 'mainEntryPointFilePath'
133
- | 'compiler'
134
- | 'dtsRollup'
135
- >
136
-
137
- export interface Resolver {
138
- /**
139
- * The name of the resolver
140
- *
141
- * The later resolver with the same name will overwrite the earlier
142
- */
143
- name: string,
144
- /**
145
- * Determine whether the resolver supports the file
146
- */
147
- supports: (id: string) => void | boolean,
148
- /**
149
- * Transform source to declaration files
150
- *
151
- * Note that the path of the returns should base on `outDir`, or relative path to `root`
152
- */
153
- transform: (payload: {
154
- id: string,
155
- code: string,
156
- root: string,
157
- outDir: string,
158
- host: ts.CompilerHost,
159
- program: ts.Program
160
- }) => MaybePromise<{ path: string, content: string }[]>
161
- }
162
-
163
- export interface PluginOptions {
164
- /**
165
- * Specify root directory.
166
- *
167
- * Defaults to the 'root' of the Vite config, or `process.cwd()` if using Rollup.
168
- */
169
- root?: string,
170
-
171
- /**
172
- * Output directory for declaration files.
173
- *
174
- * Can be an array to output to multiple directories.
175
- *
176
- * Defaults to 'build.outDir' of the Vite config, or `outDir` of tsconfig.json if using Rollup.
177
- */
178
- outDir?: string | string[],
179
-
180
- /**
181
- * Override root path of entry files (useful in monorepos).
182
- *
183
- * The output path of each file will be calculated based on the value provided.
184
- *
185
- * The default is the smallest public path for all source files.
186
- */
187
- entryRoot?: string,
188
-
189
- /**
190
- * Restrict declaration files output to `outDir`.
191
- *
192
- * If true, generated declaration files outside `outDir` will be ignored.
193
- *
194
- * @default true
195
- */
196
- strictOutput?: boolean,
197
-
198
- /**
199
- * Override compilerOptions.
200
- *
201
- * @default null
202
- */
203
- compilerOptions?: ts.CompilerOptions | null,
204
-
205
- /**
206
- * Specify tsconfig.json path.
207
- *
208
- * Plugin resolves `include` and `exclude` globs from tsconfig.json.
209
- *
210
- * If not specified, plugin will find config file from root.
211
- */
212
- tsconfigPath?: string,
213
-
214
- /**
215
- * Specify custom resolvers.
216
- *
217
- * @default []
218
- */
219
- resolvers?: Resolver[],
220
-
221
- /**
222
- * Parsing `paths` of tsconfig.json to aliases.
223
- *
224
- * Note that these aliases only use for declaration files.
225
- *
226
- * @default true
227
- * @remarks Only use first replacement of each path.
228
- */
229
- pathsToAliases?: boolean,
230
-
231
- /**
232
- * Set which paths should be excluded when transforming aliases.
233
- *
234
- * @default []
235
- */
236
- aliasesExclude?: (string | RegExp)[],
237
-
238
- /**
239
- * Whether to transform file names ending in '.vue.d.ts' to '.d.ts'.
240
- *
241
- * If there is a duplicate name after transform, it will fall back to the original name.
242
- *
243
- * @default false
244
- */
245
- cleanVueFileName?: boolean,
246
-
247
- /**
248
- * Whether to transform dynamic imports to static (eg `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`).
249
- *
250
- * Value is forced to `true` when `rollupTypes` is `true`.
251
- *
252
- * @default false
253
- */
254
- staticImport?: boolean,
255
-
256
- /**
257
- * Override `include` glob (relative to root).
258
- *
259
- * Defaults to `include` property of tsconfig.json (relative to tsconfig.json located).
260
- */
261
- include?: string | string[],
262
-
263
- /**
264
- * Override `exclude` glob.
265
- *
266
- * Defaults to `exclude` property of tsconfig.json or `'node_modules/**'` if not supplied.
267
- */
268
- exclude?: string | string[],
269
-
270
- /**
271
- * Whether to remove `import 'xxx'`.
272
- *
273
- * @default true
274
- */
275
- clearPureImport?: boolean,
276
-
277
- /**
278
- * Whether to generate types entry file(s).
279
- *
280
- * When `true`, uses package.json `types` property if it exists or `${outDir}/index.d.ts`.
281
- *
282
- * Value is forced to `true` when `rollupTypes` is `true`.
283
- *
284
- * @default false
285
- */
286
- insertTypesEntry?: boolean,
287
-
288
- /**
289
- * Rollup type declaration files after emitting them.
290
- *
291
- * Powered by `@microsoft/api-extractor` - time-intensive operation.
292
- *
293
- * @default false
294
- */
295
- rollupTypes?: boolean,
296
-
297
- /**
298
- * Bundled packages for `@microsoft/api-extractor`.
299
- *
300
- * @default []
301
- * @see https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
302
- */
303
- bundledPackages?: string[],
304
-
305
- /**
306
- * Override the config of `@microsoft/api-extractor`.
307
- *
308
- * @default null
309
- * @see https://api-extractor.com/pages/setup/configure_api_report/
310
- */
311
- rollupConfig?: RollupConfig,
312
-
313
- /**
314
- * Override the invoke options of `@microsoft/api-extractor`.
315
- *
316
- * @default null
317
- * @see https://api-extractor.com/pages/setup/invoking/#invoking-from-a-build-script
318
- */
319
- rollupOptions?: IExtractorInvokeOptions,
320
-
321
- /**
322
- * Whether to copy .d.ts source files to `outDir`.
323
- *
324
- * @default false
325
- * @remarks Before 2.0, the default was `true`.
326
- */
327
- copyDtsFiles?: boolean,
328
-
329
- /**
330
- * Whether to emit declaration files only.
331
- *
332
- * When `true`, all the original outputs of vite (rollup) will be force removed.
333
- *
334
- * @default false
335
- */
336
- declarationOnly?: boolean,
337
-
338
- /**
339
- * Logging level for this plugin.
340
- *
341
- * Defaults to the 'logLevel' property of your Vite config.
342
- */
343
- logLevel?: LogLevel,
344
-
345
- /**
346
- * Hook called after diagnostic is emitted.
347
- *
348
- * According to the `diagnostics.length`, you can judge whether there is any type error.
349
- *
350
- * @default () => {}
351
- */
352
- afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => MaybePromise<void>,
353
-
354
- /**
355
- * Hook called prior to writing each declaration file.
356
- *
357
- * This allows you to transform the path or content.
358
- *
359
- * The file will be skipped when the return value `false` or `Promise<false>`.
360
- *
361
- * @default () => {}
362
- */
363
- beforeWriteFile?: (
364
- filePath: string,
365
- content: string
366
- ) => MaybePromise<
367
- | void
368
- | false
369
- | {
370
- filePath?: string,
371
- content?: string
372
- }
373
- >,
374
-
375
- /**
376
- * Hook called after rolling up declaration files.
377
- *
378
- * @default () => {}
379
- */
380
- afterRollup?: (result: ExtractorResult) => MaybePromise<void>,
381
-
382
- /**
383
- * Hook called after all declaration files are written.
384
- *
385
- * It will be received a map (path -> content) that records those emitted files.
386
- *
387
- * @default () => {}
388
- */
389
- afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>
390
- }
391
- ```
392
-
393
- ## Contributors
394
-
395
- Thanks for all the contributions!
396
-
397
- <a href="https://github.com/qmhc/vite-plugin-dts/graphs/contributors">
398
- <img src="https://contrib.rocks/image?repo=qmhc/vite-plugin-dts" alt="contributors" />
399
- </a>
400
-
401
- ## Example
402
-
403
- Clone and run the following script:
404
-
405
- ```sh
406
- pnpm run test:ts
407
- ```
408
-
409
- Then check `examples/ts/types`.
410
-
411
- Also Vue and React cases under `examples`.
412
-
413
- A real project using this plugin: [Vexip UI](https://github.com/vexip-ui/vexip-ui).
414
-
415
- ## License
416
-
417
- MIT License.
1
+ <h1 align="center">vite-plugin-dts</h1>
2
+
3
+ <p align="center">
4
+ A Vite plugin that generates declaration files (<code>*.d.ts</code>) from <code>.ts(x)</code> or <code>.vue</code> source files when using Vite in <a href="https://vitejs.dev/guide/build.html#library-mode">library mode</a>.
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/vite-plugin-dts">
9
+ <img src="https://img.shields.io/npm/v/vite-plugin-dts?color=orange&label=" alt="version" />
10
+ </a>
11
+ <a href="https://github.com/qmhc/vite-plugin-dts/blob/main/LICENSE">
12
+ <img src="https://img.shields.io/npm/l/vite-plugin-dts" alt="license" />
13
+ </a>
14
+ </p>
15
+
16
+ **English** | [中文](./README.zh-CN.md)
17
+
18
+ ## Install
19
+
20
+ ```sh
21
+ pnpm i vite-plugin-dts -D
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ In `vite.config.ts`:
27
+
28
+ ```ts
29
+ import { resolve } from 'path'
30
+ import { defineConfig } from 'vite'
31
+ import dts from 'vite-plugin-dts'
32
+
33
+ export default defineConfig({
34
+ build: {
35
+ lib: {
36
+ entry: resolve(__dirname, 'src/index.ts'),
37
+ name: 'MyLib',
38
+ formats: ['es'],
39
+ fileName: 'my-lib'
40
+ }
41
+ },
42
+ plugins: [dts()]
43
+ })
44
+ ```
45
+
46
+ By default, the generated declaration files are following the source structure.
47
+
48
+ If you want to merge all declarations into one file, just specify `rollupTypes: true`:
49
+
50
+ ```ts
51
+ {
52
+ plugins: [dts({ rollupTypes: true })]
53
+ }
54
+ ```
55
+
56
+ If you start with official Vite template, you should specify the `tsconfigPath`:
57
+
58
+ ```ts
59
+ {
60
+ plugins: [dts({ tsconfigPath: './tsconfig.app.json' })]
61
+ }
62
+ ```
63
+
64
+ Starting with `3.0.0`, you can use this plugin with Rollup.
65
+
66
+ ## FAQ
67
+
68
+ Here are some FAQ's and solutions.
69
+
70
+ ### Type errors that are unable to infer types from packages in `node_modules`
71
+
72
+ This is an existing [TypeScript issue](https://github.com/microsoft/TypeScript/issues/42873) where TypeScript infers types from packages located in `node_modules` through soft links (pnpm). A workaround is to add `baseUrl` to your `tsconfig.json` and specify the `paths` for these packages:
73
+
74
+ ```json
75
+ {
76
+ "compilerOptions": {
77
+ "baseUrl": ".",
78
+ "paths": {
79
+ "third-lib": ["node_modules/third-lib"]
80
+ }
81
+ }
82
+ }
83
+ ```
84
+
85
+ ### `Internal Error` occurs when using `rollupTypes: true`
86
+
87
+ Refer to this [issue](https://github.com/microsoft/rushstack/issues/3875), it's due to a limitation of `@microsoft/api-extractor` or TypeScript resolver.
88
+
89
+ The main reason is that `baseUrl` is specified in `tsconfig.json` and non-standard paths are used directly when imported.
90
+
91
+ For example: `baseUrl: 'src'` is specified and importing from `<root>/src/components/index.ts` in `<root>/src/index.ts`, and `import 'components'` is used instead of `import './components'`.
92
+
93
+ Currently, you need to avoid the above situation, or use aliases instead (with the `paths` option).
94
+
95
+ ### Get module not found errors during build
96
+
97
+ This is likely due to incorrect configuration of the `include` property in your default `tsconfig.json`.
98
+
99
+ Due to some limitations, the plugin relies on the top-level `tsconfig.json` to resolve the files to include. Therefore, you need to specify the correct `include` property in the top-level `tsconfig.json`, or you can specify a configuration file path with the correct `include` property using the `tsconfigPath` option of the plugin. For example, in the Vite initial template, it is `tsconfig.app.json`.
100
+
101
+ You can refer to this [comment](https://github.com/qmhc/vite-plugin-dts/issues/343#issuecomment-2198111439).
102
+
103
+ <details>
104
+ <summary>Legacy</summary>
105
+
106
+ ### Missing some declaration files after build (before `1.7.0`)
107
+
108
+ By default, the `skipDiagnostics` option is set to `true` which means type diagnostics will be skipped during the build process (some projects may have diagnostic tools such as `vue-tsc`). Files with type errors which interrupt the build process will not be emitted (declaration files won't be generated).
109
+
110
+ If your project doesn't use type diagnostic tools, you can set `skipDiagnostics: false` and `logDiagnostics: true` to turn on diagnostic and logging features of this plugin. Type errors during build will be logged to the terminal.
111
+
112
+ ### Type error when using both `script` and `setup-script` in Vue component (before `3.0.0`)
113
+
114
+ This is usually caused by using the `defineComponent` function in both `script` and `setup-script`. When `vue/compiler-sfc` compiles these files, the default export result from `script` gets merged with the parameter object of `defineComponent` from `setup-script`. This is incompatible with parameters and types returned from `defineComponent`. This results in a type error.
115
+
116
+ Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/examples/vue/components/BothScripts.vue). You should remove the `defineComponent` in `script` and export a native object directly.
117
+
118
+ </details>
119
+
120
+ ## Options
121
+
122
+ ```ts
123
+ import type ts from 'typescript'
124
+ import type { IExtractorConfigPrepareOptions, IExtractorInvokeOptions } from '@microsoft/api-extractor'
125
+ import type { LogLevel } from 'vite'
126
+
127
+ type MaybePromise<T> = T | Promise<T>
128
+
129
+ export type RollupConfig = Omit<
130
+ IExtractorConfigPrepareOptions['configObject'],
131
+ | 'projectFolder'
132
+ | 'mainEntryPointFilePath'
133
+ | 'compiler'
134
+ | 'dtsRollup'
135
+ >
136
+
137
+ export interface Resolver {
138
+ /**
139
+ * The name of the resolver
140
+ *
141
+ * The later resolver with the same name will overwrite the earlier
142
+ */
143
+ name: string,
144
+ /**
145
+ * Determine whether the resolver supports the file
146
+ */
147
+ supports: (id: string) => void | boolean,
148
+ /**
149
+ * Transform source to declaration files
150
+ *
151
+ * Note that the path of the returns should base on `outDir`, or relative path to `root`
152
+ */
153
+ transform: (payload: {
154
+ id: string,
155
+ code: string,
156
+ root: string,
157
+ outDir: string,
158
+ host: ts.CompilerHost,
159
+ program: ts.Program
160
+ }) => MaybePromise<{ path: string, content: string }[]>
161
+ }
162
+
163
+ export interface PluginOptions {
164
+ /**
165
+ * Specify root directory.
166
+ *
167
+ * Defaults to the 'root' of the Vite config, or `process.cwd()` if using Rollup.
168
+ */
169
+ root?: string,
170
+
171
+ /**
172
+ * Output directory for declaration files.
173
+ *
174
+ * Can be an array to output to multiple directories.
175
+ *
176
+ * Defaults to 'build.outDir' of the Vite config, or `outDir` of tsconfig.json if using Rollup.
177
+ */
178
+ outDir?: string | string[],
179
+
180
+ /**
181
+ * Override root path of entry files (useful in monorepos).
182
+ *
183
+ * The output path of each file will be calculated based on the value provided.
184
+ *
185
+ * The default is the smallest public path for all source files.
186
+ */
187
+ entryRoot?: string,
188
+
189
+ /**
190
+ * Restrict declaration files output to `outDir`.
191
+ *
192
+ * If true, generated declaration files outside `outDir` will be ignored.
193
+ *
194
+ * @default true
195
+ */
196
+ strictOutput?: boolean,
197
+
198
+ /**
199
+ * Override compilerOptions.
200
+ *
201
+ * @default null
202
+ */
203
+ compilerOptions?: ts.CompilerOptions | null,
204
+
205
+ /**
206
+ * Specify tsconfig.json path.
207
+ *
208
+ * Plugin resolves `include` and `exclude` globs from tsconfig.json.
209
+ *
210
+ * If not specified, plugin will find config file from root.
211
+ */
212
+ tsconfigPath?: string,
213
+
214
+ /**
215
+ * Specify custom resolvers.
216
+ *
217
+ * @default []
218
+ */
219
+ resolvers?: Resolver[],
220
+
221
+ /**
222
+ * Parsing `paths` of tsconfig.json to aliases.
223
+ *
224
+ * Note that these aliases only use for declaration files.
225
+ *
226
+ * @default true
227
+ * @remarks Only use first replacement of each path.
228
+ */
229
+ pathsToAliases?: boolean,
230
+
231
+ /**
232
+ * Set which paths should be excluded when transforming aliases.
233
+ *
234
+ * @default []
235
+ */
236
+ aliasesExclude?: (string | RegExp)[],
237
+
238
+ /**
239
+ * Whether to transform file names ending in '.vue.d.ts' to '.d.ts'.
240
+ *
241
+ * If there is a duplicate name after transform, it will fall back to the original name.
242
+ *
243
+ * @default false
244
+ */
245
+ cleanVueFileName?: boolean,
246
+
247
+ /**
248
+ * Whether to transform dynamic imports to static (eg `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`).
249
+ *
250
+ * Value is forced to `true` when `rollupTypes` is `true`.
251
+ *
252
+ * @default false
253
+ */
254
+ staticImport?: boolean,
255
+
256
+ /**
257
+ * Override `include` glob (relative to root).
258
+ *
259
+ * Defaults to `include` property of tsconfig.json (relative to tsconfig.json located).
260
+ */
261
+ include?: string | string[],
262
+
263
+ /**
264
+ * Override `exclude` glob.
265
+ *
266
+ * Defaults to `exclude` property of tsconfig.json or `'node_modules/**'` if not supplied.
267
+ */
268
+ exclude?: string | string[],
269
+
270
+ /**
271
+ * Whether to remove `import 'xxx'`.
272
+ *
273
+ * @default true
274
+ */
275
+ clearPureImport?: boolean,
276
+
277
+ /**
278
+ * Whether to generate types entry file(s).
279
+ *
280
+ * When `true`, uses package.json `types` property if it exists or `${outDir}/index.d.ts`.
281
+ *
282
+ * Value is forced to `true` when `rollupTypes` is `true`.
283
+ *
284
+ * @default false
285
+ */
286
+ insertTypesEntry?: boolean,
287
+
288
+ /**
289
+ * Rollup type declaration files after emitting them.
290
+ *
291
+ * Powered by `@microsoft/api-extractor` - time-intensive operation.
292
+ *
293
+ * @default false
294
+ */
295
+ rollupTypes?: boolean,
296
+
297
+ /**
298
+ * Bundled packages for `@microsoft/api-extractor`.
299
+ *
300
+ * @default []
301
+ * @see https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
302
+ */
303
+ bundledPackages?: string[],
304
+
305
+ /**
306
+ * Override the config of `@microsoft/api-extractor`.
307
+ *
308
+ * @default null
309
+ * @see https://api-extractor.com/pages/setup/configure_api_report/
310
+ */
311
+ rollupConfig?: RollupConfig,
312
+
313
+ /**
314
+ * Override the invoke options of `@microsoft/api-extractor`.
315
+ *
316
+ * @default null
317
+ * @see https://api-extractor.com/pages/setup/invoking/#invoking-from-a-build-script
318
+ */
319
+ rollupOptions?: IExtractorInvokeOptions,
320
+
321
+ /**
322
+ * Whether to copy .d.ts source files to `outDir`.
323
+ *
324
+ * @default false
325
+ * @remarks Before 2.0, the default was `true`.
326
+ */
327
+ copyDtsFiles?: boolean,
328
+
329
+ /**
330
+ * Whether to emit declaration files only.
331
+ *
332
+ * When `true`, all the original outputs of vite (rollup) will be force removed.
333
+ *
334
+ * @default false
335
+ */
336
+ declarationOnly?: boolean,
337
+
338
+ /**
339
+ * Logging level for this plugin.
340
+ *
341
+ * Defaults to the 'logLevel' property of your Vite config.
342
+ */
343
+ logLevel?: LogLevel,
344
+
345
+ /**
346
+ * Hook called after diagnostic is emitted.
347
+ *
348
+ * According to the `diagnostics.length`, you can judge whether there is any type error.
349
+ *
350
+ * @default () => {}
351
+ */
352
+ afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => MaybePromise<void>,
353
+
354
+ /**
355
+ * Hook called prior to writing each declaration file.
356
+ *
357
+ * This allows you to transform the path or content.
358
+ *
359
+ * The file will be skipped when the return value `false` or `Promise<false>`.
360
+ *
361
+ * @default () => {}
362
+ */
363
+ beforeWriteFile?: (
364
+ filePath: string,
365
+ content: string
366
+ ) => MaybePromise<
367
+ | void
368
+ | false
369
+ | {
370
+ filePath?: string,
371
+ content?: string
372
+ }
373
+ >,
374
+
375
+ /**
376
+ * Hook called after rolling up declaration files.
377
+ *
378
+ * @default () => {}
379
+ */
380
+ afterRollup?: (result: ExtractorResult) => MaybePromise<void>,
381
+
382
+ /**
383
+ * Hook called after all declaration files are written.
384
+ *
385
+ * It will be received a map (path -> content) that records those emitted files.
386
+ *
387
+ * @default () => {}
388
+ */
389
+ afterBuild?: (emittedFiles: Map<string, string>) => MaybePromise<void>
390
+ }
391
+ ```
392
+
393
+ ## Contributors
394
+
395
+ Thanks for all the contributions!
396
+
397
+ <a href="https://github.com/qmhc/vite-plugin-dts/graphs/contributors">
398
+ <img src="https://contrib.rocks/image?repo=qmhc/vite-plugin-dts" alt="contributors" />
399
+ </a>
400
+
401
+ ## Example
402
+
403
+ Clone and run the following script:
404
+
405
+ ```sh
406
+ pnpm run test:ts
407
+ ```
408
+
409
+ Then check `examples/ts/types`.
410
+
411
+ Also Vue and React cases under `examples`.
412
+
413
+ A real project using this plugin: [Vexip UI](https://github.com/vexip-ui/vexip-ui).
414
+
415
+ ## License
416
+
417
+ MIT License.