vite-plugin-dts 2.2.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/dist/index.d.ts CHANGED
@@ -1,180 +1,154 @@
1
1
  import * as vite from 'vite';
2
2
  import { LogLevel } from 'vite';
3
- import { ts, Diagnostic } from 'ts-morph';
3
+ import ts from 'typescript';
4
4
 
5
- interface TransformWriteFile {
6
- filePath?: string;
7
- content?: string;
8
- }
9
- interface PluginOptions {
10
- /**
11
- * Depends on the root directory
12
- *
13
- * By Default it base on 'root' option of your vite config
14
- */
15
- root?: string;
16
- /**
17
- * 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' option of your vite config
22
- */
23
- outputDir?: string | string[];
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
- * Project init compilerOptions using by ts-morph
34
- *
35
- * @default null
36
- */
37
- compilerOptions?: ts.CompilerOptions | null;
38
- /**
39
- * Project init tsconfig.json file path by ts-morph
40
- *
41
- * Plugin also resolve include and exclude files from tsconfig.json
42
- *
43
- * @default 'tsconfig.json'
44
- */
45
- tsConfigFilePath?: 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
- * Do not emit if content of file only includes 'export {}'
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 `${outputDir}/index.d.ts`
92
- *
93
- * Force true when `rollupTypes` is effective
94
- *
95
- * @default false
96
- */
97
- insertTypesEntry?: boolean;
98
- /**
99
- * Set to 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 rollup types
108
- *
109
- * See https://api-extractor.com/pages/configs/api-extractor_json/#bundledpackages
110
- *
111
- * @default []
112
- */
113
- bundledPackages?: string[];
114
- /**
115
- * Whether copy .d.ts source files into outputDir
116
- *
117
- * @default false
118
- * @remarks Before 2.0 it defaults to true
119
- */
120
- copyDtsFiles?: boolean;
121
- /**
122
- * Whether emit nothing when has any diagnostic
123
- *
124
- * @default false
125
- */
126
- noEmitOnError?: boolean;
127
- /**
128
- * Whether skip typescript diagnostics
129
- *
130
- * Skip type diagnostics means that type errors will not interrupt the build process
131
- *
132
- * But for the source files with type errors will not be emitted
133
- *
134
- * @default false
135
- * @remarks Before 1.7 it defaults to true
136
- */
137
- skipDiagnostics?: boolean;
138
- /**
139
- * Customize typescript lib folder path
140
- *
141
- * Should pass a relative path to root or a absolute path
142
- *
143
- * @default undefined
144
- */
145
- libFolderPath?: string;
146
- /**
147
- * Specify the log level of plugin
148
- *
149
- * By Default it base on 'logLevel' option of your vite config
150
- */
151
- logLevel?: LogLevel;
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;