-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entries.ts
315 lines (308 loc) · 6.51 KB
/
entries.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
import type { OutputOptions, Plugin } from 'rollup'
import type { TransformersChunk, TransformersDeclaration } from './transformers'
export interface EntryBase {
/**
* Specifies the format of the generated module.
*
* @default 'esm'
*/
format?: OutputOptions['format']
/**
* Specifies the module IDs, or regular expressions to match module IDs,
* that should remain external to the bundle.
*
* If not specified, infers the IDs from the global `options.externals` option.
*
* @default undefined
*/
externals?: (string | RegExp)[]
/**
* Specifies the string to be inserted at the beginning of the module.
*
* @default undefined
*/
banner?: OutputOptions['banner']
/**
* Specifies the string to be inserted at the end of the module.
*
* @default undefined
*/
footer?: OutputOptions['footer']
/**
* Specifies the code at the beginning that goes inside any _format-specific_ wrapper.
*
* @default undefined
*/
intro?: OutputOptions['intro']
/**
* Specifies the code at the end that goes inside any _format-specific_ wrapper.
*
* @default undefined
*/
outro?: OutputOptions['outro']
/**
* Maps external module IDs to paths.
*
* @default undefined
*/
paths?: OutputOptions['paths']
/**
* Specifies custom filters that will display only certain log messages.
*
* @default undefined
*/
logFilter?: string[]
/**
* Specifies `rollup` plugins.
*
* Adding custom plugins disables all built-in `transformers` for full customization.
*
* @default undefined
*/
plugins?: Plugin[]
}
export interface EntryChunk extends EntryBase {
/**
* Specifies the path of the build source.
*
* @example
*
* ```ts
* export default defineConfig({
* entries: [
* { input: './src/index.ts' }, // => './dist/index.mjs'
* ]
* })
* ```
*/
input?: string
/**
* Specifies the path of the transformed file.
*
* @example
*
* ```ts
* export default defineConfig({
* entries: [
* {
* input: './src/index.ts',
* output: './out/index.js', // => './out/index.js'
* },
* ]
* })
* ```
*
* @default undefined
*/
output?: string
/**
* Specifies the built-in `transformers` options.
*
* Available transformers:
*
* - `esbuild`
* - `resolve`
* - `replace`
* - `json`
* - `alias`
*
* @default undefined
*/
transformers?: TransformersChunk
/**
* Specifies the global variable name that representing exported bundle.
*
* Intended for `umd/iife` formats.
*
* @default undefined
*/
name?: OutputOptions['name']
/**
* Specifies global _module ID_ and _variable name_ pairs necessary for external imports.
*
* Intended for `umd/iife` formats.
*
* @default undefined
*/
globals?: OutputOptions['globals']
/**
* Specifies whether to extend the global variable defined by the `name` option.
*
* Intended for `umd/iife` formats.
*/
extend?: OutputOptions['extend']
/**
* Minifies the generated code if enabled.
*
* @default undefined
*/
minify?: boolean
declaration?: never
dts?: never
copy?: never
template?: never
}
export interface EntryDeclaration extends EntryBase {
/**
* Specifies the path of the TypeScript `declaration` build source.
*
* @example
*
* ```ts
* export default defineConfig({
* entries: [
* { dts: './src/types.ts' }, // => './dist/types.d.mts'
* ]
* })
* ```
*/
dts?: string
/**
* Specifies the path of the TypeScript `declaration` build source.
*
* Also, it is possible to use `dts` alias.
*
* @example
*
* ```ts
* export default defineConfig({
* entries: [
* { declaration: './src/types.ts' }, // => './dist/types.d.mts'
* ]
* })
* ```
*/
declaration?: string
/**
* Specifies the path of the TypeScript transformed `declaration` file.
*
* @example
*
* ```ts
* export default defineConfig({
* entries: [
* {
* dts: './src/types.ts',
* output: './out/types.d.ts', // => './out/types.d.ts'
* },
* ]
* })
* ```
*
* @default undefined
*/
output?: string
/**
* Specifies the built-in `transformers` options.
*
* Available transformers:
*
* - `dts`
* - `alias`
*
* @default undefined
*/
transformers?: TransformersDeclaration
input?: never
copy?: never
template?: never
name?: never
globals?: never
extend?: never
minify?: never
}
export interface CopyOptions {
/**
* Specifies the path of the source.
*/
input: string | string[]
/**
* Specifies the path of the destination directory.
*/
output: string
/**
* Copy directories recursively.
*
* @default true
*/
recursive?: boolean
/**
* Filters copied `files/directories`.
*
* Returns `true` to copy the item, `false` to ignore it.
*
* @default undefined
*/
filter?(source: string, destination: string): boolean
}
export interface EntryCopy {
/**
* Copies the single `file` or entire `directory` structure from source to destination, including subdirectories and files.
*
* This can be very useful for copying some assets that don't need a transformation process, but a simple copy paste feature.
*
* @example
*
* ```ts
* export default defineConfig({
* entries: [
* {
* copy: {
* input: './src/path/file.ts', // or ['path-dir', 'path-file.ts', ...]
* output: './dist/out', // path to output dir
* }
* }
* ]
* })
* ```
*
* @default undefined
*/
copy?: CopyOptions
input?: never
declaration?: never
dts?: never
template?: never
name?: never
globals?: never
extend?: never
minify?: never
}
export interface EntryTemplate {
/**
* Specifies the content of the `template` file.
*
* Provides the ability to dynamically inject template content during the build phase.
*
* @example
*
* ```ts
* export default defineConfig({
* entries: [
* {
* template: `// TypeScript code...`,
* output: './dist/template.ts',
* },
* ]
* })
* ```
*/
template: string
/**
* Specifies the path of the transformed `template` file.
*/
output: string
input?: never
declaration?: never
dts?: never
copy?: never
name?: never
globals?: never
extend?: never
minify?: never
}
export type EntryOptions =
| EntryChunk
| EntryDeclaration
| EntryCopy
| EntryTemplate