vite-plugin-dts 3.1.0 → 3.1.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 +47 -77
- package/README.zh-CN.md +23 -51
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +38 -44
- package/dist/index.mjs +1 -0
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
<a href="https://www.npmjs.com/package/vite-plugin-dts">
|
|
9
9
|
<img src="https://img.shields.io/npm/v/vite-plugin-dts?color=orange&label=" alt="version" />
|
|
10
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>
|
|
11
14
|
</p>
|
|
12
15
|
|
|
13
16
|
**English** | [中文](./README.zh-CN.md)
|
|
@@ -40,34 +43,7 @@ export default defineConfig({
|
|
|
40
43
|
})
|
|
41
44
|
```
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```vue
|
|
46
|
-
<template>
|
|
47
|
-
<div></div>
|
|
48
|
-
</template>
|
|
49
|
-
|
|
50
|
-
<script lang="ts">
|
|
51
|
-
// using defineComponent for inferring types
|
|
52
|
-
import { defineComponent } from 'vue'
|
|
53
|
-
|
|
54
|
-
export default defineComponent({
|
|
55
|
-
name: 'Component'
|
|
56
|
-
})
|
|
57
|
-
</script>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
```vue
|
|
61
|
-
<script setup lang="ts">
|
|
62
|
-
defineProps<{
|
|
63
|
-
color: 'blue' | 'red'
|
|
64
|
-
}>()
|
|
65
|
-
</script>
|
|
66
|
-
|
|
67
|
-
<template>
|
|
68
|
-
<div>{{ color }}</div>
|
|
69
|
-
</template>
|
|
70
|
-
```
|
|
46
|
+
Starting with `3.0.0`, you can use this plugin with Rollup.
|
|
71
47
|
|
|
72
48
|
## FAQ
|
|
73
49
|
|
|
@@ -75,19 +51,19 @@ Here are some FAQ's and solutions.
|
|
|
75
51
|
|
|
76
52
|
### Missing some declaration files after build (before `1.7.0`)
|
|
77
53
|
|
|
78
|
-
By default, the `skipDiagnostics` option is set to `true` which means type
|
|
54
|
+
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).
|
|
79
55
|
|
|
80
|
-
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.
|
|
56
|
+
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.
|
|
81
57
|
|
|
82
58
|
### Type error when using both `script` and `setup-script` in Vue component (before `3.0.0`)
|
|
83
59
|
|
|
84
|
-
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
|
|
60
|
+
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.
|
|
85
61
|
|
|
86
|
-
Here is a simple [example](https://github.com/qmhc/vite-plugin-dts/blob/main/examples/vue/components/BothScripts.vue). You should remove the `defineComponent`
|
|
62
|
+
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.
|
|
87
63
|
|
|
88
64
|
### Type errors that are unable to infer types from packages in `node_modules`
|
|
89
65
|
|
|
90
|
-
This is an existing issue
|
|
66
|
+
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:
|
|
91
67
|
|
|
92
68
|
```json
|
|
93
69
|
{
|
|
@@ -116,11 +92,11 @@ export interface Resolver {
|
|
|
116
92
|
*/
|
|
117
93
|
name: string,
|
|
118
94
|
/**
|
|
119
|
-
* Determine whether the
|
|
95
|
+
* Determine whether the resolver supports the file
|
|
120
96
|
*/
|
|
121
97
|
supports: (id: string) => void | boolean,
|
|
122
98
|
/**
|
|
123
|
-
* Transform
|
|
99
|
+
* Transform source to declaration files
|
|
124
100
|
*/
|
|
125
101
|
transform: (payload: {
|
|
126
102
|
id: string,
|
|
@@ -136,39 +112,39 @@ export interface PluginOptions {
|
|
|
136
112
|
/**
|
|
137
113
|
* Specify root directory
|
|
138
114
|
*
|
|
139
|
-
*
|
|
115
|
+
* Defaults to the 'root' of the Vite config, or `process.cwd()` if using Rollup
|
|
140
116
|
*/
|
|
141
117
|
root?: string,
|
|
142
118
|
|
|
143
119
|
/**
|
|
144
|
-
*
|
|
120
|
+
* Output directory for declaration files
|
|
145
121
|
*
|
|
146
|
-
* Can be
|
|
122
|
+
* Can be an array to output to multiple directories
|
|
147
123
|
*
|
|
148
|
-
*
|
|
124
|
+
* Defaults to 'build.outDir' of the Vite config, or `outDir` of tsconfig.json if using Rollup
|
|
149
125
|
*/
|
|
150
126
|
outDir?: string | string[],
|
|
151
127
|
|
|
152
128
|
/**
|
|
153
|
-
*
|
|
129
|
+
* Override root path of entry files (useful in monorepos)
|
|
154
130
|
*
|
|
155
|
-
* The output path of each file will be calculated
|
|
131
|
+
* The output path of each file will be calculated based on the value provided
|
|
156
132
|
*
|
|
157
|
-
*
|
|
133
|
+
* The default is the smallest public path for all source files
|
|
158
134
|
*/
|
|
159
135
|
entryRoot?: string,
|
|
160
136
|
|
|
161
137
|
/**
|
|
162
|
-
*
|
|
138
|
+
* Restrict declaration files output to `outDir`
|
|
163
139
|
*
|
|
164
|
-
*
|
|
140
|
+
* If true, generated declaration files outside `outDir` will be ignored
|
|
165
141
|
*
|
|
166
142
|
* @default true
|
|
167
143
|
*/
|
|
168
144
|
strictOutput?: boolean,
|
|
169
145
|
|
|
170
146
|
/**
|
|
171
|
-
*
|
|
147
|
+
* Override compilerOptions
|
|
172
148
|
*
|
|
173
149
|
* @default null
|
|
174
150
|
*/
|
|
@@ -177,9 +153,9 @@ export interface PluginOptions {
|
|
|
177
153
|
/**
|
|
178
154
|
* Specify tsconfig.json path
|
|
179
155
|
*
|
|
180
|
-
* Plugin
|
|
156
|
+
* Plugin resolves `include` and `exclude` globs from tsconfig.json
|
|
181
157
|
*
|
|
182
|
-
*
|
|
158
|
+
* If not specified, plugin will find config file from root
|
|
183
159
|
*/
|
|
184
160
|
tsconfigPath?: string,
|
|
185
161
|
|
|
@@ -191,68 +167,64 @@ export interface PluginOptions {
|
|
|
191
167
|
resolvers?: Resolver[],
|
|
192
168
|
|
|
193
169
|
/**
|
|
194
|
-
* Set which paths should
|
|
195
|
-
*
|
|
196
|
-
* If it's regexp, it will test the original import path directly
|
|
170
|
+
* Set which paths should be excluded when transforming aliases
|
|
197
171
|
*
|
|
198
172
|
* @default []
|
|
199
173
|
*/
|
|
200
174
|
aliasesExclude?: (string | RegExp)[],
|
|
201
175
|
|
|
202
176
|
/**
|
|
203
|
-
* Whether transform file
|
|
177
|
+
* Whether to transform file names ending in '.vue.d.ts' to '.d.ts'
|
|
204
178
|
*
|
|
205
179
|
* @default false
|
|
206
180
|
*/
|
|
207
181
|
cleanVueFileName?: boolean,
|
|
208
182
|
|
|
209
183
|
/**
|
|
210
|
-
* Whether transform dynamic import to
|
|
211
|
-
*
|
|
212
|
-
* Force `true` when `rollupTypes` is effective
|
|
184
|
+
* Whether to transform dynamic imports to static (eg `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`)
|
|
213
185
|
*
|
|
214
|
-
*
|
|
186
|
+
* Value is forced to `true` when `rollupTypes` is `true`
|
|
215
187
|
*
|
|
216
188
|
* @default false
|
|
217
189
|
*/
|
|
218
190
|
staticImport?: boolean,
|
|
219
191
|
|
|
220
192
|
/**
|
|
221
|
-
*
|
|
193
|
+
* Override `include` glob
|
|
222
194
|
*
|
|
223
|
-
*
|
|
195
|
+
* Defaults to `include` property of tsconfig.json
|
|
224
196
|
*/
|
|
225
197
|
include?: string | string[],
|
|
226
198
|
|
|
227
199
|
/**
|
|
228
|
-
*
|
|
200
|
+
* Override `exclude` glob
|
|
229
201
|
*
|
|
230
|
-
*
|
|
202
|
+
* Defaults to `exclude` property of tsconfig.json or `'node_module/**'` if not supplied.
|
|
231
203
|
*/
|
|
232
204
|
exclude?: string | string[],
|
|
233
205
|
|
|
234
206
|
/**
|
|
235
|
-
* Whether remove
|
|
207
|
+
* Whether to remove `import 'xxx'`
|
|
236
208
|
*
|
|
237
209
|
* @default true
|
|
238
210
|
*/
|
|
239
211
|
clearPureImport?: boolean,
|
|
240
212
|
|
|
241
213
|
/**
|
|
242
|
-
* Whether generate types entry file
|
|
214
|
+
* Whether to generate types entry file(s)
|
|
243
215
|
*
|
|
244
|
-
* When `true
|
|
216
|
+
* When `true`, uses package.json `types` property if it exists or `${outDir}/index.d.ts`
|
|
245
217
|
*
|
|
246
|
-
*
|
|
218
|
+
* Value is forced to `true` when `rollupTypes` is `true`
|
|
247
219
|
*
|
|
248
220
|
* @default false
|
|
249
221
|
*/
|
|
250
222
|
insertTypesEntry?: boolean,
|
|
251
223
|
|
|
252
224
|
/**
|
|
253
|
-
*
|
|
225
|
+
* Rollup type declaration files after emitting them
|
|
254
226
|
*
|
|
255
|
-
*
|
|
227
|
+
* Powered by `@microsoft/api-extractor` - time-intensive operation
|
|
256
228
|
*
|
|
257
229
|
* @default false
|
|
258
230
|
*/
|
|
@@ -267,35 +239,35 @@ export interface PluginOptions {
|
|
|
267
239
|
bundledPackages?: string[],
|
|
268
240
|
|
|
269
241
|
/**
|
|
270
|
-
* Whether copy .d.ts source files
|
|
242
|
+
* Whether to copy .d.ts source files to `outDir`
|
|
271
243
|
*
|
|
272
244
|
* @default false
|
|
273
|
-
* @remarks Before 2.0
|
|
245
|
+
* @remarks Before 2.0, the default was `true`
|
|
274
246
|
*/
|
|
275
247
|
copyDtsFiles?: boolean,
|
|
276
248
|
|
|
277
249
|
/**
|
|
278
|
-
*
|
|
250
|
+
* Logging level for this plugin
|
|
279
251
|
*
|
|
280
|
-
*
|
|
252
|
+
* Defaults to the 'logLevel' property of your Vite config
|
|
281
253
|
*/
|
|
282
254
|
logLevel?: LogLevel,
|
|
283
255
|
|
|
284
256
|
/**
|
|
285
|
-
* Hook after diagnostic emitted
|
|
257
|
+
* Hook called after diagnostic is emitted
|
|
286
258
|
*
|
|
287
|
-
* According to the length
|
|
259
|
+
* According to the `diagnostics.length`, you can judge whether there is any type error
|
|
288
260
|
*
|
|
289
261
|
* @default () => {}
|
|
290
262
|
*/
|
|
291
263
|
afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => MaybePromise<void>,
|
|
292
264
|
|
|
293
265
|
/**
|
|
294
|
-
* Hook
|
|
266
|
+
* Hook called prior to writing each declaration file
|
|
295
267
|
*
|
|
296
|
-
*
|
|
268
|
+
* This allows you to transform the path or content
|
|
297
269
|
*
|
|
298
|
-
* The file will be skipped when return
|
|
270
|
+
* The file will be skipped when the return value `false`
|
|
299
271
|
*
|
|
300
272
|
* @default () => {}
|
|
301
273
|
*/
|
|
@@ -311,9 +283,7 @@ export interface PluginOptions {
|
|
|
311
283
|
},
|
|
312
284
|
|
|
313
285
|
/**
|
|
314
|
-
* Hook after
|
|
315
|
-
*
|
|
316
|
-
* It wil be called after all declaration files are written
|
|
286
|
+
* Hook called after all declaration files are written
|
|
317
287
|
*
|
|
318
288
|
* @default () => {}
|
|
319
289
|
*/
|
package/README.zh-CN.md
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
<a href="https://www.npmjs.com/package/vite-plugin-dts">
|
|
9
9
|
<img src="https://img.shields.io/npm/v/vite-plugin-dts?color=orange&label=" alt="version" />
|
|
10
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>
|
|
11
14
|
</p>
|
|
12
15
|
|
|
13
16
|
**中文** | [English](./README.md)
|
|
@@ -40,34 +43,7 @@ export default defineConfig({
|
|
|
40
43
|
})
|
|
41
44
|
```
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```vue
|
|
46
|
-
<template>
|
|
47
|
-
<div></div>
|
|
48
|
-
</template>
|
|
49
|
-
|
|
50
|
-
<script lang="ts">
|
|
51
|
-
// 使用 defineComponent 来进行类型推断
|
|
52
|
-
import { defineComponent } from 'vue'
|
|
53
|
-
|
|
54
|
-
export default defineComponent({
|
|
55
|
-
name: 'Component'
|
|
56
|
-
})
|
|
57
|
-
</script>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
```vue
|
|
61
|
-
<script setup lang="ts">
|
|
62
|
-
defineProps<{
|
|
63
|
-
color: 'blue' | 'red'
|
|
64
|
-
}>()
|
|
65
|
-
</script>
|
|
66
|
-
|
|
67
|
-
<template>
|
|
68
|
-
<div>{{ color }}</div>
|
|
69
|
-
</template>
|
|
70
|
-
```
|
|
46
|
+
从 `3.0.0` 开始,你可以在 Rollup 中使用该插件。
|
|
71
47
|
|
|
72
48
|
## 常见问题
|
|
73
49
|
|
|
@@ -116,7 +92,7 @@ export interface Resolver {
|
|
|
116
92
|
*/
|
|
117
93
|
name: string,
|
|
118
94
|
/**
|
|
119
|
-
*
|
|
95
|
+
* 判断解析器是否支持该文件
|
|
120
96
|
*/
|
|
121
97
|
supports: (id: string) => void | boolean,
|
|
122
98
|
/**
|
|
@@ -136,7 +112,7 @@ export interface PluginOptions {
|
|
|
136
112
|
/**
|
|
137
113
|
* 指定根目录
|
|
138
114
|
*
|
|
139
|
-
*
|
|
115
|
+
* 默认为 Vite 配置的 'root',使用 Rollup 为 `process.cwd()`
|
|
140
116
|
*/
|
|
141
117
|
root?: string,
|
|
142
118
|
|
|
@@ -145,30 +121,30 @@ export interface PluginOptions {
|
|
|
145
121
|
*
|
|
146
122
|
* 可以指定一个数组来输出到多个目录中
|
|
147
123
|
*
|
|
148
|
-
*
|
|
124
|
+
* 默认为 Vite 配置的 'build.outDir',使用 Rollup 时为 tsconfig.json 的 `outDir`
|
|
149
125
|
*/
|
|
150
126
|
outDir?: string | string[],
|
|
151
127
|
|
|
152
128
|
/**
|
|
153
|
-
*
|
|
129
|
+
* 用于手动设置入口文件的根路径(通常用在 monorepo)
|
|
154
130
|
*
|
|
155
131
|
* 在计算每个文件的输出路径时将基于该路径
|
|
156
132
|
*
|
|
157
|
-
*
|
|
133
|
+
* 默认为所有源文件的最小公共路径
|
|
158
134
|
*/
|
|
159
135
|
entryRoot?: string,
|
|
160
136
|
|
|
161
137
|
/**
|
|
162
|
-
*
|
|
138
|
+
* 限制类型文件生成在 `outDir` 内
|
|
163
139
|
*
|
|
164
|
-
*
|
|
140
|
+
* 如果为 `true`,生成在 `outDir` 外的文件将被忽略
|
|
165
141
|
*
|
|
166
142
|
* @default true
|
|
167
143
|
*/
|
|
168
144
|
strictOutput?: boolean,
|
|
169
145
|
|
|
170
146
|
/**
|
|
171
|
-
*
|
|
147
|
+
* 覆写 CompilerOptions
|
|
172
148
|
*
|
|
173
149
|
* @default null
|
|
174
150
|
*/
|
|
@@ -177,9 +153,9 @@ export interface PluginOptions {
|
|
|
177
153
|
/**
|
|
178
154
|
* 指定 tsconfig.json 的路径
|
|
179
155
|
*
|
|
180
|
-
*
|
|
156
|
+
* 插件会解析 tsconfig.json 的 include 和 exclude 选项
|
|
181
157
|
*
|
|
182
|
-
*
|
|
158
|
+
* 未指定时插件默认从根目录开始寻找配置文件
|
|
183
159
|
*/
|
|
184
160
|
tsconfigPath?: string,
|
|
185
161
|
|
|
@@ -205,12 +181,10 @@ export interface PluginOptions {
|
|
|
205
181
|
cleanVueFileName?: boolean,
|
|
206
182
|
|
|
207
183
|
/**
|
|
208
|
-
*
|
|
184
|
+
* 是否将动态引入转换为静态(例如:`import('vue').DefineComponent` 转换为 `import { DefineComponent } from 'vue'`)
|
|
209
185
|
*
|
|
210
186
|
* 开启 `rollupTypes` 时强制为 `true`
|
|
211
187
|
*
|
|
212
|
-
* 例如将 `import('vue').DefineComponent` 转换为 `import { DefineComponent } from 'vue'`
|
|
213
|
-
*
|
|
214
188
|
* @default false
|
|
215
189
|
*/
|
|
216
190
|
staticImport?: boolean,
|
|
@@ -230,18 +204,18 @@ export interface PluginOptions {
|
|
|
230
204
|
exclude?: string | string[],
|
|
231
205
|
|
|
232
206
|
/**
|
|
233
|
-
*
|
|
207
|
+
* 是否移除 `import 'xxx'`
|
|
234
208
|
*
|
|
235
209
|
* @default true
|
|
236
210
|
*/
|
|
237
211
|
clearPureImport?: boolean,
|
|
238
212
|
|
|
239
213
|
/**
|
|
240
|
-
*
|
|
214
|
+
* 是否生成类型入口文件
|
|
241
215
|
*
|
|
242
|
-
* 当为 `true` 时会基于 package.json 的 types 字段生成,或者 `${outDir}/index.d.ts`
|
|
216
|
+
* 当为 `true` 时会基于 package.json 的 `types` 字段生成,或者 `${outDir}/index.d.ts`
|
|
243
217
|
*
|
|
244
|
-
*
|
|
218
|
+
* 当开启 `rollupTypes` 时强制为 `true`
|
|
245
219
|
*
|
|
246
220
|
* @default false
|
|
247
221
|
*/
|
|
@@ -250,7 +224,7 @@ export interface PluginOptions {
|
|
|
250
224
|
/**
|
|
251
225
|
* 设置是否在发出类型文件后将其打包
|
|
252
226
|
*
|
|
253
|
-
* 基于 `@microsoft/api-extractor
|
|
227
|
+
* 基于 `@microsoft/api-extractor`,过程将会消耗一些时间
|
|
254
228
|
*
|
|
255
229
|
* @default false
|
|
256
230
|
*/
|
|
@@ -268,7 +242,7 @@ export interface PluginOptions {
|
|
|
268
242
|
* 是否将源码里的 .d.ts 文件复制到 `outDir`
|
|
269
243
|
*
|
|
270
244
|
* @default false
|
|
271
|
-
* @remarks 在 2.0 之前它默认为 true
|
|
245
|
+
* @remarks 在 2.0 之前它默认为 `true`
|
|
272
246
|
*/
|
|
273
247
|
copyDtsFiles?: boolean,
|
|
274
248
|
|
|
@@ -282,7 +256,7 @@ export interface PluginOptions {
|
|
|
282
256
|
/**
|
|
283
257
|
* 获取诊断信息后的钩子
|
|
284
258
|
*
|
|
285
|
-
*
|
|
259
|
+
* 可以根据 `diagnostics.length` 来判断有误类型错误
|
|
286
260
|
*
|
|
287
261
|
* @default () => {}
|
|
288
262
|
*/
|
|
@@ -309,9 +283,7 @@ export interface PluginOptions {
|
|
|
309
283
|
},
|
|
310
284
|
|
|
311
285
|
/**
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
* 将会在所有类型文件被写入后调用
|
|
286
|
+
* 在所有类型文件被写入后调用的钩子
|
|
315
287
|
*
|
|
316
288
|
* @default () => {}
|
|
317
289
|
*/
|
package/dist/index.cjs
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -11,11 +11,11 @@ interface Resolver {
|
|
|
11
11
|
*/
|
|
12
12
|
name: string;
|
|
13
13
|
/**
|
|
14
|
-
* Determine whether the
|
|
14
|
+
* Determine whether the resolver supports the file
|
|
15
15
|
*/
|
|
16
16
|
supports: (id: string) => void | boolean;
|
|
17
17
|
/**
|
|
18
|
-
* Transform
|
|
18
|
+
* Transform source to declaration files
|
|
19
19
|
*/
|
|
20
20
|
transform: (payload: {
|
|
21
21
|
id: string;
|
|
@@ -33,35 +33,35 @@ interface PluginOptions {
|
|
|
33
33
|
/**
|
|
34
34
|
* Specify root directory
|
|
35
35
|
*
|
|
36
|
-
*
|
|
36
|
+
* Defaults to the 'root' of the Vite config, or `process.cwd()` if using Rollup
|
|
37
37
|
*/
|
|
38
38
|
root?: string;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Output directory for declaration files
|
|
41
41
|
*
|
|
42
|
-
* Can be
|
|
42
|
+
* Can be an array to output to multiple directories
|
|
43
43
|
*
|
|
44
|
-
*
|
|
44
|
+
* Defaults to 'build.outDir' of the Vite config, or `outDir` of tsconfig.json if using Rollup
|
|
45
45
|
*/
|
|
46
46
|
outDir?: string | string[];
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Override root path of entry files (useful in monorepos)
|
|
49
49
|
*
|
|
50
|
-
* The output path of each file will be calculated
|
|
50
|
+
* The output path of each file will be calculated based on the value provided
|
|
51
51
|
*
|
|
52
|
-
*
|
|
52
|
+
* The default is the smallest public path for all source files
|
|
53
53
|
*/
|
|
54
54
|
entryRoot?: string;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Restrict declaration files output to `outDir`
|
|
57
57
|
*
|
|
58
|
-
*
|
|
58
|
+
* If true, generated declaration files outside `outDir` will be ignored
|
|
59
59
|
*
|
|
60
60
|
* @default true
|
|
61
61
|
*/
|
|
62
62
|
strictOutput?: boolean;
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
64
|
+
* Override compilerOptions
|
|
65
65
|
*
|
|
66
66
|
* @default null
|
|
67
67
|
*/
|
|
@@ -69,9 +69,9 @@ interface PluginOptions {
|
|
|
69
69
|
/**
|
|
70
70
|
* Specify tsconfig.json path
|
|
71
71
|
*
|
|
72
|
-
* Plugin
|
|
72
|
+
* Plugin resolves `include` and `exclude` globs from tsconfig.json
|
|
73
73
|
*
|
|
74
|
-
*
|
|
74
|
+
* If not specified, plugin will find config file from root
|
|
75
75
|
*/
|
|
76
76
|
tsconfigPath?: string;
|
|
77
77
|
/**
|
|
@@ -81,61 +81,57 @@ interface PluginOptions {
|
|
|
81
81
|
*/
|
|
82
82
|
resolvers?: Resolver[];
|
|
83
83
|
/**
|
|
84
|
-
* Set which paths should
|
|
85
|
-
*
|
|
86
|
-
* If it's regexp, it will test the original import path directly
|
|
84
|
+
* Set which paths should be excluded when transforming aliases
|
|
87
85
|
*
|
|
88
86
|
* @default []
|
|
89
87
|
*/
|
|
90
88
|
aliasesExclude?: (string | RegExp)[];
|
|
91
89
|
/**
|
|
92
|
-
* Whether transform file
|
|
90
|
+
* Whether to transform file names ending in '.vue.d.ts' to '.d.ts'
|
|
93
91
|
*
|
|
94
92
|
* @default false
|
|
95
93
|
*/
|
|
96
94
|
cleanVueFileName?: boolean;
|
|
97
95
|
/**
|
|
98
|
-
* Whether transform dynamic import to
|
|
99
|
-
*
|
|
100
|
-
* Force `true` when `rollupTypes` is effective
|
|
96
|
+
* Whether to transform dynamic imports to static (eg `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`)
|
|
101
97
|
*
|
|
102
|
-
*
|
|
98
|
+
* Value is forced to `true` when `rollupTypes` is `true`
|
|
103
99
|
*
|
|
104
100
|
* @default false
|
|
105
101
|
*/
|
|
106
102
|
staticImport?: boolean;
|
|
107
103
|
/**
|
|
108
|
-
*
|
|
104
|
+
* Override `include` glob
|
|
109
105
|
*
|
|
110
|
-
*
|
|
106
|
+
* Defaults to `include` property of tsconfig.json
|
|
111
107
|
*/
|
|
112
108
|
include?: string | string[];
|
|
113
109
|
/**
|
|
114
|
-
*
|
|
110
|
+
* Override `exclude` glob
|
|
115
111
|
*
|
|
116
|
-
*
|
|
112
|
+
* Defaults to `exclude` property of tsconfig.json or `'node_module/**'` if not supplied.
|
|
117
113
|
*/
|
|
118
114
|
exclude?: string | string[];
|
|
119
115
|
/**
|
|
120
|
-
* Whether remove
|
|
116
|
+
* Whether to remove `import 'xxx'`
|
|
121
117
|
*
|
|
122
118
|
* @default true
|
|
123
119
|
*/
|
|
124
120
|
clearPureImport?: boolean;
|
|
125
121
|
/**
|
|
126
|
-
* Whether generate types entry file
|
|
122
|
+
* Whether to generate types entry file(s)
|
|
127
123
|
*
|
|
128
|
-
* When `true
|
|
124
|
+
* When `true`, uses package.json `types` property if it exists or `${outDir}/index.d.ts`
|
|
129
125
|
*
|
|
130
|
-
*
|
|
126
|
+
* Value is forced to `true` when `rollupTypes` is `true`
|
|
131
127
|
*
|
|
132
128
|
* @default false
|
|
133
129
|
*/
|
|
134
130
|
insertTypesEntry?: boolean;
|
|
135
131
|
/**
|
|
136
|
-
*
|
|
132
|
+
* Rollup type declaration files after emitting them
|
|
137
133
|
*
|
|
138
|
-
*
|
|
134
|
+
* Powered by `@microsoft/api-extractor` - time-intensive operation
|
|
139
135
|
*
|
|
140
136
|
* @default false
|
|
141
137
|
*/
|
|
@@ -148,32 +144,32 @@ interface PluginOptions {
|
|
|
148
144
|
*/
|
|
149
145
|
bundledPackages?: string[];
|
|
150
146
|
/**
|
|
151
|
-
* Whether copy .d.ts source files
|
|
147
|
+
* Whether to copy .d.ts source files to `outDir`
|
|
152
148
|
*
|
|
153
149
|
* @default false
|
|
154
|
-
* @remarks Before 2.0
|
|
150
|
+
* @remarks Before 2.0, the default was `true`
|
|
155
151
|
*/
|
|
156
152
|
copyDtsFiles?: boolean;
|
|
157
153
|
/**
|
|
158
|
-
*
|
|
154
|
+
* Logging level for this plugin
|
|
159
155
|
*
|
|
160
|
-
*
|
|
156
|
+
* Defaults to the 'logLevel' property of your Vite config
|
|
161
157
|
*/
|
|
162
158
|
logLevel?: LogLevel;
|
|
163
159
|
/**
|
|
164
|
-
* Hook after diagnostic emitted
|
|
160
|
+
* Hook called after diagnostic is emitted
|
|
165
161
|
*
|
|
166
|
-
* According to the length
|
|
162
|
+
* According to the `diagnostics.length`, you can judge whether there is any type error
|
|
167
163
|
*
|
|
168
164
|
* @default () => {}
|
|
169
165
|
*/
|
|
170
166
|
afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => MaybePromise<void>;
|
|
171
167
|
/**
|
|
172
|
-
* Hook
|
|
168
|
+
* Hook called prior to writing each declaration file
|
|
173
169
|
*
|
|
174
|
-
*
|
|
170
|
+
* This allows you to transform the path or content
|
|
175
171
|
*
|
|
176
|
-
* The file will be skipped when return
|
|
172
|
+
* The file will be skipped when the return value `false`
|
|
177
173
|
*
|
|
178
174
|
* @default () => {}
|
|
179
175
|
*/
|
|
@@ -182,9 +178,7 @@ interface PluginOptions {
|
|
|
182
178
|
content?: string;
|
|
183
179
|
};
|
|
184
180
|
/**
|
|
185
|
-
* Hook after
|
|
186
|
-
*
|
|
187
|
-
* It wil be called after all declaration files are written
|
|
181
|
+
* Hook called after all declaration files are written
|
|
188
182
|
*
|
|
189
183
|
* @default () => {}
|
|
190
184
|
*/
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-dts",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "qmhc",
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
"@vue/eslint-config-standard": "^8.0.1",
|
|
78
78
|
"@vue/eslint-config-typescript": "^11.0.3",
|
|
79
79
|
"conventional-changelog-cli": "^3.0.0",
|
|
80
|
-
"cross-env": "^7.0.3",
|
|
81
80
|
"eslint": "^8.43.0",
|
|
82
81
|
"execa": "^7.1.1",
|
|
83
82
|
"husky": "^8.0.3",
|