vite-plugin-dts 1.7.2 → 2.0.0-beta.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 +326 -318
- package/README.zh-CN.md +8 -0
- package/dist/index.cjs +197 -55
- package/dist/index.mjs +197 -55
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,318 +1,326 @@
|
|
|
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
|
-
</p>
|
|
12
|
-
|
|
13
|
-
<p align="center">
|
|
14
|
-
<strong>English</strong> | <a href="./README.zh-CN.md">中文</a>
|
|
15
|
-
</p>
|
|
16
|
-
|
|
17
|
-
<p align="center"><strong>Notice: </strong><code>skipDiagnostics</code> option default to <code>false</code> since 1.7.0.</p>
|
|
18
|
-
|
|
19
|
-
<br />
|
|
20
|
-
|
|
21
|
-
## Install
|
|
22
|
-
|
|
23
|
-
```sh
|
|
24
|
-
pnpm add vite-plugin-dts -D
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Usage
|
|
28
|
-
|
|
29
|
-
In `vite.config.ts`:
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
import { resolve } from 'path'
|
|
33
|
-
import { defineConfig } from 'vite'
|
|
34
|
-
import dts from 'vite-plugin-dts'
|
|
35
|
-
|
|
36
|
-
export default defineConfig({
|
|
37
|
-
build: {
|
|
38
|
-
lib: {
|
|
39
|
-
entry: resolve(__dirname, 'src/index.ts'),
|
|
40
|
-
name: 'MyLib',
|
|
41
|
-
formats: ['es'],
|
|
42
|
-
fileName: 'my-lib'
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
plugins: [dts()]
|
|
46
|
-
})
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
In your component:
|
|
50
|
-
|
|
51
|
-
```vue
|
|
52
|
-
<template>
|
|
53
|
-
<div></div>
|
|
54
|
-
</template>
|
|
55
|
-
|
|
56
|
-
<script lang="ts">
|
|
57
|
-
// using defineComponent for inferring types
|
|
58
|
-
import { defineComponent } from 'vue'
|
|
59
|
-
|
|
60
|
-
export default defineComponent({
|
|
61
|
-
name: 'Component'
|
|
62
|
-
})
|
|
63
|
-
</script>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
```vue
|
|
67
|
-
<script setup lang="ts">
|
|
68
|
-
// Need to access the defineProps returned value to
|
|
69
|
-
// infer types although you never use the props directly
|
|
70
|
-
const props = defineProps<{
|
|
71
|
-
color: 'blue' | 'red'
|
|
72
|
-
}>()
|
|
73
|
-
</script>
|
|
74
|
-
|
|
75
|
-
<template>
|
|
76
|
-
<div>{{ color }}</div>
|
|
77
|
-
</template>
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## FAQ
|
|
81
|
-
|
|
82
|
-
Here are some FAQ's and solutions.
|
|
83
|
-
|
|
84
|
-
### Missing some declaration files after build (before `1.7.0`)
|
|
85
|
-
|
|
86
|
-
By default `skipDiagnostics` option is `true`, which means that type diagnostic will be skipped during the build process (some projects may have diagnostic tools such as `vue-tsc`). If there are some files with type errors which interrupt the build process, these files will not be emitted (declaration files won't be generated).
|
|
87
|
-
|
|
88
|
-
If your project doesn't use type diagnostic tools, you can set `skipDiagnostics: false` and `logDiagnostics: true` to turn on the diagnostic and log features of this plugin. It will help you check the type errors during build and log error information to the terminal.
|
|
89
|
-
|
|
90
|
-
### Take type error when using both `script` and `setup-script` in vue component
|
|
91
|
-
|
|
92
|
-
This is usually caused by using `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`, which results in a type error.
|
|
93
|
-
|
|
94
|
-
Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/example/components/BothScripts.vue), you should remove the `defineComponent` which in `script` and export a native object directly.
|
|
95
|
-
|
|
96
|
-
### Take errors that unable to infer types from packages which under `node_modules`
|
|
97
|
-
|
|
98
|
-
This is a exist issue when TypeScript inferring types from packages which under `node_modules` through soft links (pnpm), you can refer to this [issue](https://github.com/microsoft/TypeScript/issues/42873). Currently has a workaround that add `baseUrl` to your `tsconfig.json` and specify the `paths` for these packages:
|
|
99
|
-
|
|
100
|
-
```json
|
|
101
|
-
{
|
|
102
|
-
"compilerOptions": {
|
|
103
|
-
"baseUrl": ".",
|
|
104
|
-
"paths": {
|
|
105
|
-
"third-lib": ["node_modules/third-lib"]
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Options
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
import type { ts, Diagnostic } from 'ts-morph'
|
|
115
|
-
|
|
116
|
-
interface TransformWriteFile {
|
|
117
|
-
filePath?: string
|
|
118
|
-
content?: string
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface PluginOptions {
|
|
122
|
-
/**
|
|
123
|
-
* Depends on the root directory
|
|
124
|
-
*
|
|
125
|
-
* Defaults base on your vite config root options
|
|
126
|
-
*/
|
|
127
|
-
root?: string
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Declaration files output directory
|
|
131
|
-
*
|
|
132
|
-
* Can be specified a array to output to multiple directories
|
|
133
|
-
*
|
|
134
|
-
* Defaults base on your vite config output options
|
|
135
|
-
*/
|
|
136
|
-
outputDir?: string | string[]
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Manually set the root path of the entry files
|
|
140
|
-
*
|
|
141
|
-
* The output path of each file will be caculated base on it
|
|
142
|
-
*
|
|
143
|
-
* Defaults is the smallest public path for all files
|
|
144
|
-
*/
|
|
145
|
-
entryRoot?: string
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Project init compilerOptions using by ts-morph
|
|
149
|
-
*
|
|
150
|
-
* @default null
|
|
151
|
-
*/
|
|
152
|
-
compilerOptions?: ts.CompilerOptions | null
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Project init tsconfig.json file path by ts-morph
|
|
156
|
-
*
|
|
157
|
-
* Plugin also resolve incldue and exclude files from tsconfig.json
|
|
158
|
-
*
|
|
159
|
-
* @default 'tsconfig.json'
|
|
160
|
-
*/
|
|
161
|
-
tsConfigFilePath?: string
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Set which paths should exclude when transform aliases
|
|
165
|
-
*
|
|
166
|
-
* If it's regexp, it will test the original import path directly
|
|
167
|
-
*
|
|
168
|
-
* @default []
|
|
169
|
-
*/
|
|
170
|
-
aliasesExclude?: (string | RegExp)[]
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Whether transform file name '.vue.d.ts' to '.d.ts'
|
|
174
|
-
*
|
|
175
|
-
* @default false
|
|
176
|
-
*/
|
|
177
|
-
cleanVueFileName?: boolean
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Whether transform dynamic import to static
|
|
181
|
-
*
|
|
182
|
-
* Force true when `rollupTypes` is effective
|
|
183
|
-
*
|
|
184
|
-
* eg. 'import('vue').DefineComponent' to 'import { DefineComponent } from "vue"'
|
|
185
|
-
*
|
|
186
|
-
* @default false
|
|
187
|
-
*/
|
|
188
|
-
staticImport?: boolean
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Manual set include glob
|
|
192
|
-
*
|
|
193
|
-
* Defaults base on your tsconfig.json include option
|
|
194
|
-
*/
|
|
195
|
-
include?: string | string[]
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Manual set exclude glob
|
|
199
|
-
*
|
|
200
|
-
* Defaults base on your tsconfig.json exclude option, be 'node_modules/**' when empty
|
|
201
|
-
*/
|
|
202
|
-
exclude?: string | string[]
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Do not emit if content of file only includes 'export {}'
|
|
206
|
-
*
|
|
207
|
-
* @default true
|
|
208
|
-
*/
|
|
209
|
-
clearPureImport?: boolean
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Whether generate types entry file
|
|
213
|
-
*
|
|
214
|
-
* When true will from package.json types field if exists or `${outputDir}/index.d.ts`
|
|
215
|
-
*
|
|
216
|
-
* Force true when `rollupTypes` is effective
|
|
217
|
-
*
|
|
218
|
-
* @default false
|
|
219
|
-
*/
|
|
220
|
-
insertTypesEntry?: boolean
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Set to rollup declaration files after emit
|
|
224
|
-
*
|
|
225
|
-
* Power by `@microsoft/api-extractor`, it will start a new program which takes some time
|
|
226
|
-
*
|
|
227
|
-
* @default false
|
|
228
|
-
*/
|
|
229
|
-
rollupTypes?: boolean
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Whether copy .d.ts source files into outputDir
|
|
233
|
-
*
|
|
234
|
-
* @default true
|
|
235
|
-
*/
|
|
236
|
-
copyDtsFiles?: boolean
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Whether emit nothing when has any diagnostic
|
|
240
|
-
*
|
|
241
|
-
* @default false
|
|
242
|
-
*/
|
|
243
|
-
noEmitOnError?: boolean
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Whether skip typescript diagnostics
|
|
247
|
-
*
|
|
248
|
-
* Skip type diagnostics means that type errors will not interrupt the build process
|
|
249
|
-
*
|
|
250
|
-
* But for the source files with type errors will not be emitted
|
|
251
|
-
*
|
|
252
|
-
* @default false
|
|
253
|
-
*/
|
|
254
|
-
skipDiagnostics?: boolean
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Whether log diagnostic informations
|
|
258
|
-
*
|
|
259
|
-
* Not effective when `skipDiagnostics` is true
|
|
260
|
-
*
|
|
261
|
-
* @deprecated
|
|
262
|
-
* @default false
|
|
263
|
-
*/
|
|
264
|
-
logDiagnostics?: boolean
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Customize typescript lib folder path
|
|
268
|
-
*
|
|
269
|
-
* Should pass a relative path to root or a absolute path
|
|
270
|
-
*
|
|
271
|
-
* @default undefined
|
|
272
|
-
*/
|
|
273
|
-
libFolderPath?: string
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* After emit diagnostic hook
|
|
277
|
-
*
|
|
278
|
-
* According to the length to judge whether there is any type error
|
|
279
|
-
*
|
|
280
|
-
* @default () => {}
|
|
281
|
-
*/
|
|
282
|
-
afterDiagnostic?: (diagnostics: Diagnostic[]) => void | Promise<void>
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Before declaration file be writed hook
|
|
286
|
-
*
|
|
287
|
-
* You can transform declaration file-path and content through it
|
|
288
|
-
*
|
|
289
|
-
* The file will be skipped when return exact false
|
|
290
|
-
*
|
|
291
|
-
* @default () => {}
|
|
292
|
-
*/
|
|
293
|
-
beforeWriteFile?: (filePath: string, content: string) => void | false | TransformWriteFile
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* After build hook
|
|
297
|
-
*
|
|
298
|
-
* It wil be called after all declaration files are written
|
|
299
|
-
*
|
|
300
|
-
* @default () => {}
|
|
301
|
-
*/
|
|
302
|
-
afterBuild?: () => void | Promise<void>
|
|
303
|
-
}
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
##
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<strong>English</strong> | <a href="./README.zh-CN.md">中文</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center"><strong>Notice: </strong><code>skipDiagnostics</code> option default to <code>false</code> since 1.7.0.</p>
|
|
18
|
+
|
|
19
|
+
<br />
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
pnpm add vite-plugin-dts -D
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
In `vite.config.ts`:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { resolve } from 'path'
|
|
33
|
+
import { defineConfig } from 'vite'
|
|
34
|
+
import dts from 'vite-plugin-dts'
|
|
35
|
+
|
|
36
|
+
export default defineConfig({
|
|
37
|
+
build: {
|
|
38
|
+
lib: {
|
|
39
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
40
|
+
name: 'MyLib',
|
|
41
|
+
formats: ['es'],
|
|
42
|
+
fileName: 'my-lib'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
plugins: [dts()]
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
In your component:
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<template>
|
|
53
|
+
<div></div>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script lang="ts">
|
|
57
|
+
// using defineComponent for inferring types
|
|
58
|
+
import { defineComponent } from 'vue'
|
|
59
|
+
|
|
60
|
+
export default defineComponent({
|
|
61
|
+
name: 'Component'
|
|
62
|
+
})
|
|
63
|
+
</script>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<script setup lang="ts">
|
|
68
|
+
// Need to access the defineProps returned value to
|
|
69
|
+
// infer types although you never use the props directly
|
|
70
|
+
const props = defineProps<{
|
|
71
|
+
color: 'blue' | 'red'
|
|
72
|
+
}>()
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<template>
|
|
76
|
+
<div>{{ color }}</div>
|
|
77
|
+
</template>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## FAQ
|
|
81
|
+
|
|
82
|
+
Here are some FAQ's and solutions.
|
|
83
|
+
|
|
84
|
+
### Missing some declaration files after build (before `1.7.0`)
|
|
85
|
+
|
|
86
|
+
By default `skipDiagnostics` option is `true`, which means that type diagnostic will be skipped during the build process (some projects may have diagnostic tools such as `vue-tsc`). If there are some files with type errors which interrupt the build process, these files will not be emitted (declaration files won't be generated).
|
|
87
|
+
|
|
88
|
+
If your project doesn't use type diagnostic tools, you can set `skipDiagnostics: false` and `logDiagnostics: true` to turn on the diagnostic and log features of this plugin. It will help you check the type errors during build and log error information to the terminal.
|
|
89
|
+
|
|
90
|
+
### Take type error when using both `script` and `setup-script` in vue component
|
|
91
|
+
|
|
92
|
+
This is usually caused by using `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`, which results in a type error.
|
|
93
|
+
|
|
94
|
+
Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/example/components/BothScripts.vue), you should remove the `defineComponent` which in `script` and export a native object directly.
|
|
95
|
+
|
|
96
|
+
### Take errors that unable to infer types from packages which under `node_modules`
|
|
97
|
+
|
|
98
|
+
This is a exist issue when TypeScript inferring types from packages which under `node_modules` through soft links (pnpm), you can refer to this [issue](https://github.com/microsoft/TypeScript/issues/42873). Currently has a workaround that add `baseUrl` to your `tsconfig.json` and specify the `paths` for these packages:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"compilerOptions": {
|
|
103
|
+
"baseUrl": ".",
|
|
104
|
+
"paths": {
|
|
105
|
+
"third-lib": ["node_modules/third-lib"]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Options
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import type { ts, Diagnostic } from 'ts-morph'
|
|
115
|
+
|
|
116
|
+
interface TransformWriteFile {
|
|
117
|
+
filePath?: string
|
|
118
|
+
content?: string
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface PluginOptions {
|
|
122
|
+
/**
|
|
123
|
+
* Depends on the root directory
|
|
124
|
+
*
|
|
125
|
+
* Defaults base on your vite config root options
|
|
126
|
+
*/
|
|
127
|
+
root?: string
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Declaration files output directory
|
|
131
|
+
*
|
|
132
|
+
* Can be specified a array to output to multiple directories
|
|
133
|
+
*
|
|
134
|
+
* Defaults base on your vite config output options
|
|
135
|
+
*/
|
|
136
|
+
outputDir?: string | string[]
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Manually set the root path of the entry files
|
|
140
|
+
*
|
|
141
|
+
* The output path of each file will be caculated base on it
|
|
142
|
+
*
|
|
143
|
+
* Defaults is the smallest public path for all files
|
|
144
|
+
*/
|
|
145
|
+
entryRoot?: string
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Project init compilerOptions using by ts-morph
|
|
149
|
+
*
|
|
150
|
+
* @default null
|
|
151
|
+
*/
|
|
152
|
+
compilerOptions?: ts.CompilerOptions | null
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Project init tsconfig.json file path by ts-morph
|
|
156
|
+
*
|
|
157
|
+
* Plugin also resolve incldue and exclude files from tsconfig.json
|
|
158
|
+
*
|
|
159
|
+
* @default 'tsconfig.json'
|
|
160
|
+
*/
|
|
161
|
+
tsConfigFilePath?: string
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Set which paths should exclude when transform aliases
|
|
165
|
+
*
|
|
166
|
+
* If it's regexp, it will test the original import path directly
|
|
167
|
+
*
|
|
168
|
+
* @default []
|
|
169
|
+
*/
|
|
170
|
+
aliasesExclude?: (string | RegExp)[]
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Whether transform file name '.vue.d.ts' to '.d.ts'
|
|
174
|
+
*
|
|
175
|
+
* @default false
|
|
176
|
+
*/
|
|
177
|
+
cleanVueFileName?: boolean
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Whether transform dynamic import to static
|
|
181
|
+
*
|
|
182
|
+
* Force true when `rollupTypes` is effective
|
|
183
|
+
*
|
|
184
|
+
* eg. 'import('vue').DefineComponent' to 'import { DefineComponent } from "vue"'
|
|
185
|
+
*
|
|
186
|
+
* @default false
|
|
187
|
+
*/
|
|
188
|
+
staticImport?: boolean
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Manual set include glob
|
|
192
|
+
*
|
|
193
|
+
* Defaults base on your tsconfig.json include option
|
|
194
|
+
*/
|
|
195
|
+
include?: string | string[]
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Manual set exclude glob
|
|
199
|
+
*
|
|
200
|
+
* Defaults base on your tsconfig.json exclude option, be 'node_modules/**' when empty
|
|
201
|
+
*/
|
|
202
|
+
exclude?: string | string[]
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Do not emit if content of file only includes 'export {}'
|
|
206
|
+
*
|
|
207
|
+
* @default true
|
|
208
|
+
*/
|
|
209
|
+
clearPureImport?: boolean
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Whether generate types entry file
|
|
213
|
+
*
|
|
214
|
+
* When true will from package.json types field if exists or `${outputDir}/index.d.ts`
|
|
215
|
+
*
|
|
216
|
+
* Force true when `rollupTypes` is effective
|
|
217
|
+
*
|
|
218
|
+
* @default false
|
|
219
|
+
*/
|
|
220
|
+
insertTypesEntry?: boolean
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Set to rollup declaration files after emit
|
|
224
|
+
*
|
|
225
|
+
* Power by `@microsoft/api-extractor`, it will start a new program which takes some time
|
|
226
|
+
*
|
|
227
|
+
* @default false
|
|
228
|
+
*/
|
|
229
|
+
rollupTypes?: boolean
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Whether copy .d.ts source files into outputDir
|
|
233
|
+
*
|
|
234
|
+
* @default true
|
|
235
|
+
*/
|
|
236
|
+
copyDtsFiles?: boolean
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Whether emit nothing when has any diagnostic
|
|
240
|
+
*
|
|
241
|
+
* @default false
|
|
242
|
+
*/
|
|
243
|
+
noEmitOnError?: boolean
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Whether skip typescript diagnostics
|
|
247
|
+
*
|
|
248
|
+
* Skip type diagnostics means that type errors will not interrupt the build process
|
|
249
|
+
*
|
|
250
|
+
* But for the source files with type errors will not be emitted
|
|
251
|
+
*
|
|
252
|
+
* @default false
|
|
253
|
+
*/
|
|
254
|
+
skipDiagnostics?: boolean
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Whether log diagnostic informations
|
|
258
|
+
*
|
|
259
|
+
* Not effective when `skipDiagnostics` is true
|
|
260
|
+
*
|
|
261
|
+
* @deprecated
|
|
262
|
+
* @default false
|
|
263
|
+
*/
|
|
264
|
+
logDiagnostics?: boolean
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Customize typescript lib folder path
|
|
268
|
+
*
|
|
269
|
+
* Should pass a relative path to root or a absolute path
|
|
270
|
+
*
|
|
271
|
+
* @default undefined
|
|
272
|
+
*/
|
|
273
|
+
libFolderPath?: string
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* After emit diagnostic hook
|
|
277
|
+
*
|
|
278
|
+
* According to the length to judge whether there is any type error
|
|
279
|
+
*
|
|
280
|
+
* @default () => {}
|
|
281
|
+
*/
|
|
282
|
+
afterDiagnostic?: (diagnostics: Diagnostic[]) => void | Promise<void>
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Before declaration file be writed hook
|
|
286
|
+
*
|
|
287
|
+
* You can transform declaration file-path and content through it
|
|
288
|
+
*
|
|
289
|
+
* The file will be skipped when return exact false
|
|
290
|
+
*
|
|
291
|
+
* @default () => {}
|
|
292
|
+
*/
|
|
293
|
+
beforeWriteFile?: (filePath: string, content: string) => void | false | TransformWriteFile
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* After build hook
|
|
297
|
+
*
|
|
298
|
+
* It wil be called after all declaration files are written
|
|
299
|
+
*
|
|
300
|
+
* @default () => {}
|
|
301
|
+
*/
|
|
302
|
+
afterBuild?: () => void | Promise<void>
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Contributors
|
|
307
|
+
|
|
308
|
+
Thanks for all their contributions!
|
|
309
|
+
|
|
310
|
+
<a href="https://github.com/qmhc/vite-plugin-dts/graphs/contributors">
|
|
311
|
+
<img src="https://contrib.rocks/image?repo=qmhc/vite-plugin-dts" />
|
|
312
|
+
</a>
|
|
313
|
+
|
|
314
|
+
## Example
|
|
315
|
+
|
|
316
|
+
Clone and run the following script:
|
|
317
|
+
|
|
318
|
+
```sh
|
|
319
|
+
pnpm run test:ts
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Then check `examples/ts/types`.
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
MIT License.
|
package/README.zh-CN.md
CHANGED
|
@@ -302,6 +302,14 @@ export interface PluginOptions {
|
|
|
302
302
|
}
|
|
303
303
|
```
|
|
304
304
|
|
|
305
|
+
## 贡献者
|
|
306
|
+
|
|
307
|
+
感谢他们的所做的一切贡献!
|
|
308
|
+
|
|
309
|
+
<a href="https://github.com/qmhc/vite-plugin-dts/graphs/contributors">
|
|
310
|
+
<img src="https://contrib.rocks/image?repo=qmhc/vite-plugin-dts" />
|
|
311
|
+
</a>
|
|
312
|
+
|
|
305
313
|
## 示例
|
|
306
314
|
|
|
307
315
|
克隆项目然后执行下列命令:
|