vite-plugin-dts 2.3.0 → 3.0.0-beta.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 +302 -326
- package/README.zh-CN.md +35 -59
- package/dist/index.cjs +312 -670
- package/dist/index.d.ts +148 -174
- package/dist/index.mjs +310 -673
- package/package.json +41 -47
package/dist/index.d.ts
CHANGED
|
@@ -1,180 +1,154 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import { LogLevel } from 'vite';
|
|
3
|
-
import
|
|
3
|
+
import ts from 'typescript';
|
|
4
4
|
|
|
5
|
-
interface TransformWriteFile {
|
|
6
|
-
filePath?: string;
|
|
7
|
-
content?: string;
|
|
8
|
-
}
|
|
9
|
-
interface PluginOptions {
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* By Default it base on 'root'
|
|
14
|
-
*/
|
|
15
|
-
root?: string;
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* Can be specified a array to output to multiple directories
|
|
20
|
-
*
|
|
21
|
-
* By Default it base on 'build.outDir'
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Manually set the root path of the entry files
|
|
26
|
-
*
|
|
27
|
-
* The output path of each file will be calculated base on it
|
|
28
|
-
*
|
|
29
|
-
* By Default it is the smallest public path for all files
|
|
30
|
-
*/
|
|
31
|
-
entryRoot?: string;
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @default null
|
|
36
|
-
*/
|
|
37
|
-
compilerOptions?: ts.CompilerOptions | null;
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* Plugin also resolve include and exclude files from tsconfig.json
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Set which paths should exclude when transform aliases
|
|
48
|
-
*
|
|
49
|
-
* If it's regexp, it will test the original import path directly
|
|
50
|
-
*
|
|
51
|
-
* @default []
|
|
52
|
-
*/
|
|
53
|
-
aliasesExclude?: (string | RegExp)[];
|
|
54
|
-
/**
|
|
55
|
-
* Whether transform file name '.vue.d.ts' to '.d.ts'
|
|
56
|
-
*
|
|
57
|
-
* @default false
|
|
58
|
-
*/
|
|
59
|
-
cleanVueFileName?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Whether transform dynamic import to static
|
|
62
|
-
*
|
|
63
|
-
* Force true when `rollupTypes` is effective
|
|
64
|
-
*
|
|
65
|
-
* eg.
|
|
66
|
-
*
|
|
67
|
-
* @default false
|
|
68
|
-
*/
|
|
69
|
-
staticImport?: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Manual set include glob
|
|
72
|
-
*
|
|
73
|
-
* By Default it base on
|
|
74
|
-
*/
|
|
75
|
-
include?: string | string[];
|
|
76
|
-
/**
|
|
77
|
-
* Manual set exclude glob
|
|
78
|
-
*
|
|
79
|
-
* By Default it base on
|
|
80
|
-
*/
|
|
81
|
-
exclude?: string | string[];
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* @default true
|
|
86
|
-
*/
|
|
87
|
-
clearPureImport?: boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Whether generate types entry file
|
|
90
|
-
*
|
|
91
|
-
* When true will from package.json types field if exists or `${
|
|
92
|
-
*
|
|
93
|
-
* Force true when `rollupTypes` is effective
|
|
94
|
-
*
|
|
95
|
-
* @default false
|
|
96
|
-
*/
|
|
97
|
-
insertTypesEntry?: boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Set
|
|
100
|
-
*
|
|
101
|
-
* Power by `@microsoft/api-extractor`, it will start a new program which takes some time
|
|
102
|
-
*
|
|
103
|
-
* @default false
|
|
104
|
-
*/
|
|
105
|
-
rollupTypes?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Bundled packages for
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* @
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* After emit diagnostic hook
|
|
154
|
-
*
|
|
155
|
-
* According to the length to judge whether there is any type error
|
|
156
|
-
*
|
|
157
|
-
* @default () => {}
|
|
158
|
-
*/
|
|
159
|
-
afterDiagnostic?: (diagnostics: Diagnostic[]) => void | Promise<void>;
|
|
160
|
-
/**
|
|
161
|
-
* Before declaration file be writed hook
|
|
162
|
-
*
|
|
163
|
-
* You can transform declaration file-path and content through it
|
|
164
|
-
*
|
|
165
|
-
* The file will be skipped when return exact false
|
|
166
|
-
*
|
|
167
|
-
* @default () => {}
|
|
168
|
-
*/
|
|
169
|
-
beforeWriteFile?: (filePath: string, content: string) => void | false | TransformWriteFile;
|
|
170
|
-
/**
|
|
171
|
-
* After build hook
|
|
172
|
-
*
|
|
173
|
-
* It wil be called after all declaration files are written
|
|
174
|
-
*
|
|
175
|
-
* @default () => {}
|
|
176
|
-
*/
|
|
177
|
-
afterBuild?: () => void | Promise<void>;
|
|
5
|
+
interface TransformWriteFile {
|
|
6
|
+
filePath?: string;
|
|
7
|
+
content?: string;
|
|
8
|
+
}
|
|
9
|
+
interface PluginOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Specify root directory
|
|
12
|
+
*
|
|
13
|
+
* By Default it base on 'root' of your Vite config, or `process.cwd()` if using Rollup
|
|
14
|
+
*/
|
|
15
|
+
root?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Specify declaration files output directory
|
|
18
|
+
*
|
|
19
|
+
* Can be specified a array to output to multiple directories
|
|
20
|
+
*
|
|
21
|
+
* By Default it base on 'build.outDir' of your Vite config, or `outDir` of tsconfig.json if using Rollup
|
|
22
|
+
*/
|
|
23
|
+
outDir?: string | string[];
|
|
24
|
+
/**
|
|
25
|
+
* Manually set the root path of the entry files, useful in monorepo
|
|
26
|
+
*
|
|
27
|
+
* The output path of each file will be calculated base on it
|
|
28
|
+
*
|
|
29
|
+
* By Default it is the smallest public path for all files
|
|
30
|
+
*/
|
|
31
|
+
entryRoot?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Specify a CompilerOptions to override
|
|
34
|
+
*
|
|
35
|
+
* @default null
|
|
36
|
+
*/
|
|
37
|
+
compilerOptions?: ts.CompilerOptions | null;
|
|
38
|
+
/**
|
|
39
|
+
* Specify tsconfig.json path
|
|
40
|
+
*
|
|
41
|
+
* Plugin also resolve include and exclude files from tsconfig.json
|
|
42
|
+
*
|
|
43
|
+
* By default plugin will find config form root if not specify
|
|
44
|
+
*/
|
|
45
|
+
tsconfigPath?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Set which paths should exclude when transform aliases
|
|
48
|
+
*
|
|
49
|
+
* If it's regexp, it will test the original import path directly
|
|
50
|
+
*
|
|
51
|
+
* @default []
|
|
52
|
+
*/
|
|
53
|
+
aliasesExclude?: (string | RegExp)[];
|
|
54
|
+
/**
|
|
55
|
+
* Whether transform file name '.vue.d.ts' to '.d.ts'
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
cleanVueFileName?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Whether transform dynamic import to static
|
|
62
|
+
*
|
|
63
|
+
* Force `true` when `rollupTypes` is effective
|
|
64
|
+
*
|
|
65
|
+
* eg. `import('vue').DefineComponent` to `import { DefineComponent } from 'vue'`
|
|
66
|
+
*
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
staticImport?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Manual set include glob
|
|
72
|
+
*
|
|
73
|
+
* By Default it base on `include` option of the tsconfig.json
|
|
74
|
+
*/
|
|
75
|
+
include?: string | string[];
|
|
76
|
+
/**
|
|
77
|
+
* Manual set exclude glob
|
|
78
|
+
*
|
|
79
|
+
* By Default it base on `exclude` option of the tsconfig.json, be `'node_module/**'` when empty
|
|
80
|
+
*/
|
|
81
|
+
exclude?: string | string[];
|
|
82
|
+
/**
|
|
83
|
+
* Whether remove those `import 'xxx'`
|
|
84
|
+
*
|
|
85
|
+
* @default true
|
|
86
|
+
*/
|
|
87
|
+
clearPureImport?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Whether generate types entry file
|
|
90
|
+
*
|
|
91
|
+
* When `true` will from package.json types field if exists or `` `${outDir}/index.d.ts` ``
|
|
92
|
+
*
|
|
93
|
+
* Force `true` when `rollupTypes` is effective
|
|
94
|
+
*
|
|
95
|
+
* @default false
|
|
96
|
+
*/
|
|
97
|
+
insertTypesEntry?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Set whether rollup declaration files after emit
|
|
100
|
+
*
|
|
101
|
+
* Power by `@microsoft/api-extractor`, it will start a new program which takes some time
|
|
102
|
+
*
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
rollupTypes?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Bundled packages for `@microsoft/api-extractor`
|
|
108
|
+
*
|
|
109
|
+
* @default []
|
|
110
|
+
* @see https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
|
|
111
|
+
*/
|
|
112
|
+
bundledPackages?: string[];
|
|
113
|
+
/**
|
|
114
|
+
* Whether copy .d.ts source files into `outDir`
|
|
115
|
+
*
|
|
116
|
+
* @default false
|
|
117
|
+
* @remarks Before 2.0 it defaults to true
|
|
118
|
+
*/
|
|
119
|
+
copyDtsFiles?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Specify the log level of plugin
|
|
122
|
+
*
|
|
123
|
+
* By Default it base on 'logLevel' option of your Vite config
|
|
124
|
+
*/
|
|
125
|
+
logLevel?: LogLevel;
|
|
126
|
+
/**
|
|
127
|
+
* Hook after diagnostic emitted
|
|
128
|
+
*
|
|
129
|
+
* According to the length to judge whether there is any type error
|
|
130
|
+
*
|
|
131
|
+
* @default () => {}
|
|
132
|
+
*/
|
|
133
|
+
afterDiagnostic?: (diagnostics: readonly ts.Diagnostic[]) => void | Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Hook before each declaration file is written
|
|
136
|
+
*
|
|
137
|
+
* You can transform declaration file's path and content through it
|
|
138
|
+
*
|
|
139
|
+
* The file will be skipped when return exact `false`
|
|
140
|
+
*
|
|
141
|
+
* @default () => {}
|
|
142
|
+
*/
|
|
143
|
+
beforeWriteFile?: (filePath: string, content: string) => void | false | TransformWriteFile;
|
|
144
|
+
/**
|
|
145
|
+
* Hook after built
|
|
146
|
+
*
|
|
147
|
+
* It wil be called after all declaration files are written
|
|
148
|
+
*
|
|
149
|
+
* @default () => {}
|
|
150
|
+
*/
|
|
151
|
+
afterBuild?: () => void | Promise<void>;
|
|
178
152
|
}
|
|
179
153
|
|
|
180
154
|
declare function dtsPlugin(options?: PluginOptions): vite.Plugin;
|