@monstermann/unplugin-map 0.2.0 → 0.4.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/dist/vite.d.mts CHANGED
@@ -1,7 +1,3049 @@
1
+ /// <reference types="node" />
1
2
  import { Options } from "./types.mjs";
2
- import * as vite0 from "vite";
3
+ import { r as TransformOptions$1, t as BuildOptions$1 } from "./main-C-Md8Psx.mjs";
4
+ import { S as WatcherOptions, _ as RollupOptions, a as MinimalPluginContext, b as TransformPluginContext, c as ObjectHook, d as PartialResolvedId, f as Plugin$1, g as RollupError, h as ResolveIdResult, i as LoadResult, l as OutputBundle, m as PluginHooks, n as InputOption, o as ModuleFormat, p as PluginContext, r as InputOptions, s as ModuleInfo, t as CustomPluginOptions, u as OutputChunk, v as SourceDescription, x as TransformResult$1, y as SourceMap } from "./rollup-CswG1dEP.mjs";
5
+ import * as http from "node:http";
6
+ import { Agent, ClientRequest, ClientRequestArgs, IncomingMessage, OutgoingHttpHeaders, Server } from "node:http";
7
+ import { Http2SecureServer } from "node:http2";
8
+ import * as fs from "node:fs";
9
+ import * as events from "node:events";
10
+ import { EventEmitter } from "node:events";
11
+ import { Server as Server$1, ServerOptions } from "node:https";
12
+ import * as net from "node:net";
13
+ import * as url from "node:url";
14
+ import { URL } from "node:url";
15
+ import * as stream from "node:stream";
16
+ import { Duplex, DuplexOptions } from "node:stream";
17
+ import { SecureContextOptions } from "node:tls";
18
+ import { ZlibOptions } from "node:zlib";
3
19
 
20
+ //#region ../../node_modules/vite/types/hmrPayload.d.ts
21
+ type HMRPayload = ConnectedPayload | UpdatePayload | FullReloadPayload | CustomPayload | ErrorPayload | PrunePayload;
22
+ interface ConnectedPayload {
23
+ type: 'connected';
24
+ }
25
+ interface UpdatePayload {
26
+ type: 'update';
27
+ updates: Update[];
28
+ }
29
+ interface Update {
30
+ type: 'js-update' | 'css-update';
31
+ path: string;
32
+ acceptedPath: string;
33
+ timestamp: number;
34
+ /** @internal */
35
+ explicitImportRequired?: boolean;
36
+ /** @internal */
37
+ isWithinCircularImport?: boolean;
38
+ /** @internal */
39
+ ssrInvalidates?: string[];
40
+ }
41
+ interface PrunePayload {
42
+ type: 'prune';
43
+ paths: string[];
44
+ }
45
+ interface FullReloadPayload {
46
+ type: 'full-reload';
47
+ path?: string;
48
+ /** @internal */
49
+ triggeredBy?: string;
50
+ }
51
+ interface CustomPayload {
52
+ type: 'custom';
53
+ event: string;
54
+ data?: any;
55
+ }
56
+ interface ErrorPayload {
57
+ type: 'error';
58
+ err: {
59
+ [name: string]: any;
60
+ message: string;
61
+ stack: string;
62
+ id?: string;
63
+ frame?: string;
64
+ plugin?: string;
65
+ pluginCode?: string;
66
+ loc?: {
67
+ file?: string;
68
+ line: number;
69
+ column: number;
70
+ };
71
+ };
72
+ }
73
+ //#endregion
74
+ //#region ../../node_modules/vite/types/customEvent.d.ts
75
+ interface CustomEventMap {
76
+ 'vite:beforeUpdate': UpdatePayload;
77
+ 'vite:afterUpdate': UpdatePayload;
78
+ 'vite:beforePrune': PrunePayload;
79
+ 'vite:beforeFullReload': FullReloadPayload;
80
+ 'vite:error': ErrorPayload;
81
+ 'vite:invalidate': InvalidatePayload;
82
+ 'vite:ws:connect': WebSocketConnectionPayload;
83
+ 'vite:ws:disconnect': WebSocketConnectionPayload;
84
+ }
85
+ interface WebSocketConnectionPayload {
86
+ /**
87
+ * @experimental
88
+ * We expose this instance experimentally to see potential usage.
89
+ * This might be removed in the future if we didn't find reasonable use cases.
90
+ * If you find this useful, please open an issue with details so we can discuss and make it stable API.
91
+ */
92
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
93
+ webSocket: WebSocket;
94
+ }
95
+ interface InvalidatePayload {
96
+ path: string;
97
+ message: string | undefined;
98
+ }
99
+ /**
100
+ * provides types for built-in Vite events
101
+ */
102
+ type InferCustomEventPayload<T extends string> = T extends keyof CustomEventMap ? CustomEventMap[T] : any;
103
+ //#endregion
104
+ //#region ../../node_modules/vite/dist/node/types.d-aGj9QkWt.d.ts
105
+ type FetchResult = ExternalFetchResult | ViteFetchResult;
106
+ interface ExternalFetchResult {
107
+ /**
108
+ * The path to the externalized module starting with file://,
109
+ * by default this will be imported via a dynamic "import"
110
+ * instead of being transformed by vite and loaded with vite runtime
111
+ */
112
+ externalize: string;
113
+ /**
114
+ * Type of the module. Will be used to determine if import statement is correct.
115
+ * For example, if Vite needs to throw an error if variable is not actually exported
116
+ */
117
+ type?: 'module' | 'commonjs' | 'builtin' | 'network';
118
+ }
119
+ interface ViteFetchResult {
120
+ /**
121
+ * Code that will be evaluated by vite runtime
122
+ * by default this will be wrapped in an async function
123
+ */
124
+ code: string;
125
+ /**
126
+ * File path of the module on disk.
127
+ * This will be resolved as import.meta.url/filename
128
+ */
129
+ file: string | null;
130
+ }
131
+ //#endregion
132
+ //#region ../../node_modules/vite/types/metadata.d.ts
133
+ interface ChunkMetadata {
134
+ importedAssets: Set<string>;
135
+ importedCss: Set<string>;
136
+ }
137
+ declare module 'rollup' {
138
+ export interface RenderedChunk {
139
+ viteMetadata?: ChunkMetadata;
140
+ }
141
+ }
142
+ //#endregion
143
+ //#region ../../node_modules/vite/dist/node/index.d.ts
144
+ interface Alias {
145
+ find: string | RegExp;
146
+ replacement: string;
147
+ /**
148
+ * Instructs the plugin to use an alternative resolving algorithm,
149
+ * rather than the Rollup's resolver.
150
+ * @default null
151
+ */
152
+ customResolver?: ResolverFunction | ResolverObject | null;
153
+ }
154
+ type MapToFunction<T> = T extends Function ? T : never;
155
+ type ResolverFunction = MapToFunction<PluginHooks['resolveId']>;
156
+ interface ResolverObject {
157
+ buildStart?: PluginHooks['buildStart'];
158
+ resolveId: ResolverFunction;
159
+ }
160
+ /**
161
+ * Specifies an `Object`, or an `Array` of `Object`,
162
+ * which defines aliases used to replace values in `import` or `require` statements.
163
+ * With either format, the order of the entries is important,
164
+ * in that the first defined rules are applied first.
165
+ *
166
+ * This is passed to \@rollup/plugin-alias as the "entries" field
167
+ * https://github.com/rollup/plugins/tree/master/packages/alias#entries
168
+ */
169
+ type AliasOptions = readonly Alias[] | {
170
+ [find: string]: string;
171
+ };
172
+ type AnymatchFn = (testString: string) => boolean;
173
+ type AnymatchPattern = string | RegExp | AnymatchFn;
174
+ type AnymatchMatcher = AnymatchPattern | AnymatchPattern[]; // Inlined to avoid extra dependency (chokidar is bundled in the published build)
175
+ declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
176
+ options: WatchOptions;
177
+ /**
178
+ * Constructs a new FSWatcher instance with optional WatchOptions parameter.
179
+ */
180
+ constructor(options?: WatchOptions);
181
+ /**
182
+ * When called, requests that the Node.js event loop not exit so long as the fs.FSWatcher is active.
183
+ * Calling watcher.ref() multiple times will have no effect.
184
+ */
185
+ ref(): this;
186
+ /**
187
+ * When called, the active fs.FSWatcher object will not require the Node.js event loop to remain active.
188
+ * If there is no other activity keeping the event loop running, the process may exit before the fs.FSWatcher object's callback is invoked.
189
+ * Calling watcher.unref() multiple times will have no effect.
190
+ */
191
+ unref(): this;
192
+ /**
193
+ * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
194
+ * string.
195
+ */
196
+ add(paths: string | ReadonlyArray<string>): this;
197
+ /**
198
+ * Stop watching files, directories, or glob patterns. Takes an array of strings or just one
199
+ * string.
200
+ */
201
+ unwatch(paths: string | ReadonlyArray<string>): this;
202
+ /**
203
+ * Returns an object representing all the paths on the file system being watched by this
204
+ * `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
205
+ * the `cwd` option was used), and the values are arrays of the names of the items contained in
206
+ * each directory.
207
+ */
208
+ getWatched(): {
209
+ [directory: string]: string[];
210
+ };
211
+ /**
212
+ * Removes all listeners from watched files.
213
+ */
214
+ close(): Promise<void>;
215
+ on(event: 'add' | 'addDir' | 'change', listener: (path: string, stats?: fs.Stats) => void): this;
216
+ on(event: 'all', listener: (eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', path: string, stats?: fs.Stats) => void): this;
217
+ /**
218
+ * Error occurred
219
+ */
220
+ on(event: 'error', listener: (error: Error) => void): this;
221
+ /**
222
+ * Exposes the native Node `fs.FSWatcher events`
223
+ */
224
+ on(event: 'raw', listener: (eventName: string, path: string, details: any) => void): this;
225
+ /**
226
+ * Fires when the initial scan is complete
227
+ */
228
+ on(event: 'ready', listener: () => void): this;
229
+ on(event: 'unlink' | 'unlinkDir', listener: (path: string) => void): this;
230
+ on(event: string, listener: (...args: any[]) => void): this;
231
+ }
232
+ interface WatchOptions {
233
+ /**
234
+ * Indicates whether the process should continue to run as long as files are being watched. If
235
+ * set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`,
236
+ * even if the process continues to run.
237
+ */
238
+ persistent?: boolean;
239
+ /**
240
+ * ([anymatch](https://github.com/micromatch/anymatch)-compatible definition) Defines files/paths to
241
+ * be ignored. The whole relative or absolute path is tested, not just filename. If a function
242
+ * with two arguments is provided, it gets called twice per path - once with a single argument
243
+ * (the path), second time with two arguments (the path and the
244
+ * [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
245
+ */
246
+ ignored?: AnymatchMatcher;
247
+ /**
248
+ * If set to `false` then `add`/`addDir` events are also emitted for matching paths while
249
+ * instantiating the watching as chokidar discovers these file paths (before the `ready` event).
250
+ */
251
+ ignoreInitial?: boolean;
252
+ /**
253
+ * When `false`, only the symlinks themselves will be watched for changes instead of following
254
+ * the link references and bubbling events through the link's path.
255
+ */
256
+ followSymlinks?: boolean;
257
+ /**
258
+ * The base directory from which watch `paths` are to be derived. Paths emitted with events will
259
+ * be relative to this.
260
+ */
261
+ cwd?: string;
262
+ /**
263
+ * If set to true then the strings passed to .watch() and .add() are treated as literal path
264
+ * names, even if they look like globs.
265
+ *
266
+ * @default false
267
+ */
268
+ disableGlobbing?: boolean;
269
+ /**
270
+ * Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU
271
+ * utilization, consider setting this to `false`. It is typically necessary to **set this to
272
+ * `true` to successfully watch files over a network**, and it may be necessary to successfully
273
+ * watch files in other non-standard situations. Setting to `true` explicitly on OS X overrides
274
+ * the `useFsEvents` default.
275
+ */
276
+ usePolling?: boolean;
277
+ /**
278
+ * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
279
+ * and `fsevents` is available this supersedes the `usePolling` setting. When set to `false` on
280
+ * OS X, `usePolling: true` becomes the default.
281
+ */
282
+ useFsEvents?: boolean;
283
+ /**
284
+ * If relying upon the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that
285
+ * may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is
286
+ * provided even in cases where it wasn't already available from the underlying watch events.
287
+ */
288
+ alwaysStat?: boolean;
289
+ /**
290
+ * If set, limits how many levels of subdirectories will be traversed.
291
+ */
292
+ depth?: number;
293
+ /**
294
+ * Interval of file system polling.
295
+ */
296
+ interval?: number;
297
+ /**
298
+ * Interval of file system polling for binary files. ([see list of binary extensions](https://gi
299
+ * thub.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
300
+ */
301
+ binaryInterval?: number;
302
+ /**
303
+ * Indicates whether to watch files that don't have read permissions if possible. If watching
304
+ * fails due to `EPERM` or `EACCES` with this set to `true`, the errors will be suppressed
305
+ * silently.
306
+ */
307
+ ignorePermissionErrors?: boolean;
308
+ /**
309
+ * `true` if `useFsEvents` and `usePolling` are `false`. Automatically filters out artifacts
310
+ * that occur when using editors that use "atomic writes" instead of writing directly to the
311
+ * source file. If a file is re-added within 100 ms of being deleted, Chokidar emits a `change`
312
+ * event rather than `unlink` then `add`. If the default of 100 ms does not work well for you,
313
+ * you can override it by setting `atomic` to a custom value, in milliseconds.
314
+ */
315
+ atomic?: boolean | number;
316
+ /**
317
+ * can be set to an object in order to adjust timing params:
318
+ */
319
+ awaitWriteFinish?: AwaitWriteFinishOptions | boolean;
320
+ }
321
+ interface AwaitWriteFinishOptions {
322
+ /**
323
+ * Amount of time in milliseconds for a file size to remain constant before emitting its event.
324
+ */
325
+ stabilityThreshold?: number;
326
+ /**
327
+ * File size polling interval.
328
+ */
329
+ pollInterval?: number;
330
+ } // Inlined to avoid extra dependency
331
+ // MIT Licensed https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE
332
+ declare namespace Connect {
333
+ export type ServerHandle = HandleFunction | http.Server;
334
+ export class IncomingMessage extends http.IncomingMessage {
335
+ originalUrl?: http.IncomingMessage['url'] | undefined;
336
+ }
337
+ export type NextFunction = (err?: any) => void;
338
+ export type SimpleHandleFunction = (req: IncomingMessage, res: http.ServerResponse) => void;
339
+ export type NextHandleFunction = (req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
340
+ export type ErrorHandleFunction = (err: any, req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
341
+ export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
342
+ export interface ServerStackItem {
343
+ route: string;
344
+ handle: ServerHandle;
345
+ }
346
+ export interface Server extends NodeJS.EventEmitter {
347
+ (req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void;
348
+ route: string;
349
+ stack: ServerStackItem[];
350
+ /**
351
+ * Utilize the given middleware `handle` to the given `route`,
352
+ * defaulting to _/_. This "route" is the mount-point for the
353
+ * middleware, when given a value other than _/_ the middleware
354
+ * is only effective when that segment is present in the request's
355
+ * pathname.
356
+ *
357
+ * For example if we were to mount a function at _/admin_, it would
358
+ * be invoked on _/admin_, and _/admin/settings_, however it would
359
+ * not be invoked for _/_, or _/posts_.
360
+ */
361
+ use(fn: NextHandleFunction): Server;
362
+ use(fn: HandleFunction): Server;
363
+ use(route: string, fn: NextHandleFunction): Server;
364
+ use(route: string, fn: HandleFunction): Server;
365
+ /**
366
+ * Handle server requests, punting them down
367
+ * the middleware stack.
368
+ */
369
+ handle(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void;
370
+ /**
371
+ * Listen for connections.
372
+ *
373
+ * This method takes the same arguments
374
+ * as node's `http.Server#listen()`.
375
+ *
376
+ * HTTP and HTTPS:
377
+ *
378
+ * If you run your application both as HTTP
379
+ * and HTTPS you may wrap them individually,
380
+ * since your Connect "server" is really just
381
+ * a JavaScript `Function`.
382
+ *
383
+ * var connect = require('connect')
384
+ * , http = require('http')
385
+ * , https = require('https');
386
+ *
387
+ * var app = connect();
388
+ *
389
+ * http.createServer(app).listen(80);
390
+ * https.createServer(options, app).listen(443);
391
+ */
392
+ listen(port: number, hostname?: string, backlog?: number, callback?: Function): http.Server;
393
+ listen(port: number, hostname?: string, callback?: Function): http.Server;
394
+ listen(path: string, callback?: Function): http.Server;
395
+ listen(handle: any, listeningListener?: Function): http.Server;
396
+ }
397
+ } // Inlined to avoid extra dependency
398
+ // MIT Licensed https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE
399
+ declare namespace HttpProxy {
400
+ export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
401
+ export type ProxyTargetUrl = string | Partial<url.Url>;
402
+ export interface ProxyTargetDetailed {
403
+ host: string;
404
+ port: number;
405
+ protocol?: string | undefined;
406
+ hostname?: string | undefined;
407
+ socketPath?: string | undefined;
408
+ key?: string | undefined;
409
+ passphrase?: string | undefined;
410
+ pfx?: Buffer | string | undefined;
411
+ cert?: string | undefined;
412
+ ca?: string | undefined;
413
+ ciphers?: string | undefined;
414
+ secureProtocol?: string | undefined;
415
+ }
416
+ export type ErrorCallback = (err: Error, req: http.IncomingMessage, res: http.ServerResponse, target?: ProxyTargetUrl) => void;
417
+ export class Server extends events.EventEmitter {
418
+ /**
419
+ * Creates the proxy server with specified options.
420
+ * @param options - Config object passed to the proxy
421
+ */
422
+ constructor(options?: ServerOptions$1);
423
+ /**
424
+ * Used for proxying regular HTTP(S) requests
425
+ * @param req - Client request.
426
+ * @param res - Client response.
427
+ * @param options - Additional options.
428
+ * @param callback - Error callback.
429
+ */
430
+ web(req: http.IncomingMessage, res: http.ServerResponse, options?: ServerOptions$1, callback?: ErrorCallback): void;
431
+ /**
432
+ * Used for proxying regular HTTP(S) requests
433
+ * @param req - Client request.
434
+ * @param socket - Client socket.
435
+ * @param head - Client head.
436
+ * @param options - Additional options.
437
+ * @param callback - Error callback.
438
+ */
439
+ ws(req: http.IncomingMessage, socket: unknown, head: unknown, options?: ServerOptions$1, callback?: ErrorCallback): void;
440
+ /**
441
+ * A function that wraps the object in a webserver, for your convenience
442
+ * @param port - Port to listen on
443
+ */
444
+ listen(port: number): Server;
445
+ /**
446
+ * A function that closes the inner webserver and stops listening on given port
447
+ */
448
+ close(callback?: () => void): void;
449
+ /**
450
+ * Creates the proxy server with specified options.
451
+ * @param options - Config object passed to the proxy
452
+ * @returns Proxy object with handlers for `ws` and `web` requests
453
+ */
454
+ static createProxyServer(options?: ServerOptions$1): Server;
455
+ /**
456
+ * Creates the proxy server with specified options.
457
+ * @param options - Config object passed to the proxy
458
+ * @returns Proxy object with handlers for `ws` and `web` requests
459
+ */
460
+ static createServer(options?: ServerOptions$1): Server;
461
+ /**
462
+ * Creates the proxy server with specified options.
463
+ * @param options - Config object passed to the proxy
464
+ * @returns Proxy object with handlers for `ws` and `web` requests
465
+ */
466
+ static createProxy(options?: ServerOptions$1): Server;
467
+ addListener(event: string, listener: () => void): this;
468
+ on(event: string, listener: () => void): this;
469
+ on(event: 'error', listener: ErrorCallback): this;
470
+ on(event: 'start', listener: (req: http.IncomingMessage, res: http.ServerResponse, target: ProxyTargetUrl) => void): this;
471
+ on(event: 'proxyReq', listener: (proxyReq: http.ClientRequest, req: http.IncomingMessage, res: http.ServerResponse, options: ServerOptions$1) => void): this;
472
+ on(event: 'proxyRes', listener: (proxyRes: http.IncomingMessage, req: http.IncomingMessage, res: http.ServerResponse) => void): this;
473
+ on(event: 'proxyReqWs', listener: (proxyReq: http.ClientRequest, req: http.IncomingMessage, socket: net.Socket, options: ServerOptions$1, head: any) => void): this;
474
+ on(event: 'econnreset', listener: (err: Error, req: http.IncomingMessage, res: http.ServerResponse, target: ProxyTargetUrl) => void): this;
475
+ on(event: 'end', listener: (req: http.IncomingMessage, res: http.ServerResponse, proxyRes: http.IncomingMessage) => void): this;
476
+ on(event: 'close', listener: (proxyRes: http.IncomingMessage, proxySocket: net.Socket, proxyHead: any) => void): this;
477
+ once(event: string, listener: () => void): this;
478
+ removeListener(event: string, listener: () => void): this;
479
+ removeAllListeners(event?: string): this;
480
+ getMaxListeners(): number;
481
+ setMaxListeners(n: number): this;
482
+ listeners(event: string): Array<() => void>;
483
+ emit(event: string, ...args: any[]): boolean;
484
+ listenerCount(type: string): number;
485
+ }
486
+ export interface ServerOptions {
487
+ /** URL string to be parsed with the url module. */
488
+ target?: ProxyTarget | undefined;
489
+ /** URL string to be parsed with the url module. */
490
+ forward?: ProxyTargetUrl | undefined;
491
+ /** Object to be passed to http(s).request. */
492
+ agent?: any;
493
+ /** Object to be passed to https.createServer(). */
494
+ ssl?: any;
495
+ /** If you want to proxy websockets. */
496
+ ws?: boolean | undefined;
497
+ /** Adds x- forward headers. */
498
+ xfwd?: boolean | undefined;
499
+ /** Verify SSL certificate. */
500
+ secure?: boolean | undefined;
501
+ /** Explicitly specify if we are proxying to another proxy. */
502
+ toProxy?: boolean | undefined;
503
+ /** Specify whether you want to prepend the target's path to the proxy path. */
504
+ prependPath?: boolean | undefined;
505
+ /** Specify whether you want to ignore the proxy path of the incoming request. */
506
+ ignorePath?: boolean | undefined;
507
+ /** Local interface string to bind for outgoing connections. */
508
+ localAddress?: string | undefined;
509
+ /** Changes the origin of the host header to the target URL. */
510
+ changeOrigin?: boolean | undefined;
511
+ /** specify whether you want to keep letter case of response header key */
512
+ preserveHeaderKeyCase?: boolean | undefined;
513
+ /** Basic authentication i.e. 'user:password' to compute an Authorization header. */
514
+ auth?: string | undefined;
515
+ /** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
516
+ hostRewrite?: string | undefined;
517
+ /** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
518
+ autoRewrite?: boolean | undefined;
519
+ /** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
520
+ protocolRewrite?: string | undefined;
521
+ /** rewrites domain of set-cookie headers. */
522
+ cookieDomainRewrite?: false | string | {
523
+ [oldDomain: string]: string;
524
+ } | undefined;
525
+ /** rewrites path of set-cookie headers. Default: false */
526
+ cookiePathRewrite?: false | string | {
527
+ [oldPath: string]: string;
528
+ } | undefined;
529
+ /** object with extra headers to be added to target requests. */
530
+ headers?: {
531
+ [header: string]: string;
532
+ } | undefined;
533
+ /** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
534
+ proxyTimeout?: number | undefined;
535
+ /** Timeout (in milliseconds) for incoming requests */
536
+ timeout?: number | undefined;
537
+ /** Specify whether you want to follow redirects. Default: false */
538
+ followRedirects?: boolean | undefined;
539
+ /** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
540
+ selfHandleResponse?: boolean | undefined;
541
+ /** Buffer */
542
+ buffer?: stream.Stream | undefined;
543
+ }
544
+ }
545
+ interface ProxyOptions extends HttpProxy.ServerOptions {
546
+ /**
547
+ * rewrite path
548
+ */
549
+ rewrite?: (path: string) => string;
550
+ /**
551
+ * configure the proxy server (e.g. listen to events)
552
+ */
553
+ configure?: (proxy: HttpProxy.Server, options: ProxyOptions) => void;
554
+ /**
555
+ * webpack-dev-server style bypass function
556
+ */
557
+ bypass?: (req: http.IncomingMessage, res: http.ServerResponse, options: ProxyOptions) => void | null | undefined | false | string;
558
+ /**
559
+ * rewrite the Origin header of a WebSocket request to match the the target
560
+ *
561
+ * **Exercise caution as rewriting the Origin can leave the proxying open to [CSRF attacks](https://owasp.org/www-community/attacks/csrf).**
562
+ */
563
+ rewriteWsOrigin?: boolean | undefined;
564
+ }
565
+ type LogType = 'error' | 'warn' | 'info';
566
+ type LogLevel = LogType | 'silent';
567
+ interface Logger {
568
+ info(msg: string, options?: LogOptions): void;
569
+ warn(msg: string, options?: LogOptions): void;
570
+ warnOnce(msg: string, options?: LogOptions): void;
571
+ error(msg: string, options?: LogErrorOptions): void;
572
+ clearScreen(type: LogType): void;
573
+ hasErrorLogged(error: Error | RollupError): boolean;
574
+ hasWarned: boolean;
575
+ }
576
+ interface LogOptions {
577
+ clear?: boolean;
578
+ timestamp?: boolean;
579
+ }
580
+ interface LogErrorOptions extends LogOptions {
581
+ error?: Error | RollupError | null;
582
+ }
583
+ interface CommonServerOptions {
584
+ /**
585
+ * Specify server port. Note if the port is already being used, Vite will
586
+ * automatically try the next available port so this may not be the actual
587
+ * port the server ends up listening on.
588
+ */
589
+ port?: number;
590
+ /**
591
+ * If enabled, vite will exit if specified port is already in use
592
+ */
593
+ strictPort?: boolean;
594
+ /**
595
+ * Specify which IP addresses the server should listen on.
596
+ * Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
597
+ */
598
+ host?: string | boolean;
599
+ /**
600
+ * The hostnames that Vite is allowed to respond to.
601
+ * `localhost` and subdomains under `.localhost` and all IP addresses are allowed by default.
602
+ * When using HTTPS, this check is skipped.
603
+ *
604
+ * If a string starts with `.`, it will allow that hostname without the `.` and all subdomains under the hostname.
605
+ * For example, `.example.com` will allow `example.com`, `foo.example.com`, and `foo.bar.example.com`.
606
+ *
607
+ * If set to `true`, the server is allowed to respond to requests for any hosts.
608
+ * This is not recommended as it will be vulnerable to DNS rebinding attacks.
609
+ */
610
+ allowedHosts?: string[] | true;
611
+ /**
612
+ * Enable TLS + HTTP/2.
613
+ * Note: this downgrades to TLS only when the proxy option is also used.
614
+ */
615
+ https?: ServerOptions;
616
+ /**
617
+ * Open browser window on startup
618
+ */
619
+ open?: boolean | string;
620
+ /**
621
+ * Configure custom proxy rules for the dev server. Expects an object
622
+ * of `{ key: options }` pairs.
623
+ * Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
624
+ * Full options [here](https://github.com/http-party/node-http-proxy#options).
625
+ *
626
+ * Example `vite.config.js`:
627
+ * ``` js
628
+ * module.exports = {
629
+ * proxy: {
630
+ * // string shorthand: /foo -> http://localhost:4567/foo
631
+ * '/foo': 'http://localhost:4567',
632
+ * // with options
633
+ * '/api': {
634
+ * target: 'http://jsonplaceholder.typicode.com',
635
+ * changeOrigin: true,
636
+ * rewrite: path => path.replace(/^\/api/, '')
637
+ * }
638
+ * }
639
+ * }
640
+ * ```
641
+ */
642
+ proxy?: Record<string, string | ProxyOptions>;
643
+ /**
644
+ * Configure CORS for the dev server.
645
+ * Uses https://github.com/expressjs/cors.
646
+ *
647
+ * When enabling this option, **we recommend setting a specific value
648
+ * rather than `true`** to avoid exposing the source code to untrusted origins.
649
+ *
650
+ * Set to `true` to allow all methods from any origin, or configure separately
651
+ * using an object.
652
+ *
653
+ * @default false
654
+ */
655
+ cors?: CorsOptions | boolean;
656
+ /**
657
+ * Specify server response headers.
658
+ */
659
+ headers?: OutgoingHttpHeaders;
660
+ }
661
+ /**
662
+ * https://github.com/expressjs/cors#configuration-options
663
+ */
664
+ interface CorsOptions {
665
+ /**
666
+ * Configures the Access-Control-Allow-Origin CORS header.
667
+ *
668
+ * **We recommend setting a specific value rather than
669
+ * `true`** to avoid exposing the source code to untrusted origins.
670
+ */
671
+ origin?: CorsOrigin | ((origin: string | undefined, cb: (err: Error, origins: CorsOrigin) => void) => void);
672
+ methods?: string | string[];
673
+ allowedHeaders?: string | string[];
674
+ exposedHeaders?: string | string[];
675
+ credentials?: boolean;
676
+ maxAge?: number;
677
+ preflightContinue?: boolean;
678
+ optionsSuccessStatus?: number;
679
+ }
680
+ type CorsOrigin = boolean | string | RegExp | (string | RegExp)[];
681
+ interface PreviewOptions extends CommonServerOptions {}
682
+ interface ResolvedPreviewOptions extends PreviewOptions {}
683
+ interface PreviewServer {
684
+ /**
685
+ * The resolved vite config object
686
+ */
687
+ config: ResolvedConfig;
688
+ /**
689
+ * Stop the server.
690
+ */
691
+ close(): Promise<void>;
692
+ /**
693
+ * A connect app instance.
694
+ * - Can be used to attach custom middlewares to the preview server.
695
+ * - Can also be used as the handler function of a custom http server
696
+ * or as a middleware in any connect-style Node.js frameworks
697
+ *
698
+ * https://github.com/senchalabs/connect#use-middleware
699
+ */
700
+ middlewares: Connect.Server;
701
+ /**
702
+ * native Node http server instance
703
+ */
704
+ httpServer: HttpServer;
705
+ /**
706
+ * The resolved urls Vite prints on the CLI.
707
+ * null before server is listening.
708
+ */
709
+ resolvedUrls: ResolvedServerUrls | null;
710
+ /**
711
+ * Print server urls
712
+ */
713
+ printUrls(): void;
714
+ /**
715
+ * Bind CLI shortcuts
716
+ */
717
+ bindCLIShortcuts(options?: BindCLIShortcutsOptions<PreviewServer>): void;
718
+ }
719
+ type PreviewServerHook = (this: void, server: PreviewServer) => (() => void) | void | Promise<(() => void) | void>;
720
+ /**
721
+ * Starts the Vite server in preview mode, to simulate a production deployment
722
+ */
723
+ type BindCLIShortcutsOptions<Server = ViteDevServer | PreviewServer> = {
724
+ /**
725
+ * Print a one-line shortcuts "help" hint to the terminal
726
+ */
727
+ print?: boolean;
728
+ /**
729
+ * Custom shortcuts to run when a key is pressed. These shortcuts take priority
730
+ * over the default shortcuts if they have the same keys (except the `h` key).
731
+ * To disable a default shortcut, define the same key but with `action: undefined`.
732
+ */
733
+ customShortcuts?: CLIShortcut<Server>[];
734
+ };
735
+ type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
736
+ key: string;
737
+ description: string;
738
+ action?(server: Server): void | Promise<void>;
739
+ };
740
+ interface TransformResult {
741
+ code: string;
742
+ map: SourceMap | {
743
+ mappings: '';
744
+ } | null;
745
+ etag?: string;
746
+ deps?: string[];
747
+ dynamicDeps?: string[];
748
+ }
749
+ interface TransformOptions {
750
+ ssr?: boolean;
751
+ html?: boolean;
752
+ }
753
+ declare class ModuleNode {
754
+ /**
755
+ * Public served url path, starts with /
756
+ */
757
+ url: string;
758
+ /**
759
+ * Resolved file system path + query
760
+ */
761
+ id: string | null;
762
+ file: string | null;
763
+ type: 'js' | 'css';
764
+ info?: ModuleInfo;
765
+ meta?: Record<string, any>;
766
+ importers: Set<ModuleNode>;
767
+ clientImportedModules: Set<ModuleNode>;
768
+ ssrImportedModules: Set<ModuleNode>;
769
+ acceptedHmrDeps: Set<ModuleNode>;
770
+ acceptedHmrExports: Set<string> | null;
771
+ importedBindings: Map<string, Set<string>> | null;
772
+ isSelfAccepting?: boolean;
773
+ transformResult: TransformResult | null;
774
+ ssrTransformResult: TransformResult | null;
775
+ ssrModule: Record<string, any> | null;
776
+ ssrError: Error | null;
777
+ lastHMRTimestamp: number;
778
+ lastInvalidationTimestamp: number;
779
+ /**
780
+ * @param setIsSelfAccepting - set `false` to set `isSelfAccepting` later. e.g. #7870
781
+ */
782
+ constructor(url: string, setIsSelfAccepting?: boolean);
783
+ get importedModules(): Set<ModuleNode>;
784
+ }
785
+ type ResolvedUrl = [url: string, resolvedId: string, meta: object | null | undefined];
786
+ declare class ModuleGraph {
787
+ private resolveId;
788
+ urlToModuleMap: Map<string, ModuleNode>;
789
+ idToModuleMap: Map<string, ModuleNode>;
790
+ etagToModuleMap: Map<string, ModuleNode>;
791
+ fileToModulesMap: Map<string, Set<ModuleNode>>;
792
+ safeModulesPath: Set<string>;
793
+ constructor(resolveId: (url: string, ssr: boolean) => Promise<PartialResolvedId | null>);
794
+ getModuleByUrl(rawUrl: string, ssr?: boolean): Promise<ModuleNode | undefined>;
795
+ getModuleById(id: string): ModuleNode | undefined;
796
+ getModulesByFile(file: string): Set<ModuleNode> | undefined;
797
+ onFileChange(file: string): void;
798
+ onFileDelete(file: string): void;
799
+ invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean): void;
800
+ invalidateAll(): void;
801
+ /**
802
+ * Update the module graph based on a module's updated imports information
803
+ * If there are dependencies that no longer have any importers, they are
804
+ * returned as a Set.
805
+ *
806
+ * @param staticImportedUrls Subset of `importedModules` where they're statically imported in code.
807
+ * This is only used for soft invalidations so `undefined` is fine but may cause more runtime processing.
808
+ */
809
+ updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, importedBindings: Map<string, Set<string>> | null, acceptedModules: Set<string | ModuleNode>, acceptedExports: Set<string> | null, isSelfAccepting: boolean, ssr?: boolean): Promise<Set<ModuleNode> | undefined>;
810
+ ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>;
811
+ createFileOnlyEntry(file: string): ModuleNode;
812
+ resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
813
+ updateModuleTransformResult(mod: ModuleNode, result: TransformResult | null, ssr: boolean): void;
814
+ getModuleByEtag(etag: string): ModuleNode | undefined;
815
+ }
816
+ /**
817
+ * This file is refactored into TypeScript based on
818
+ * https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/rollup-plugin-container.js
819
+ */
820
+ declare class PluginContainer {
821
+ config: ResolvedConfig;
822
+ moduleGraph?: ModuleGraph | undefined;
823
+ watcher?: FSWatcher | undefined;
824
+ plugins: readonly Plugin<any>[];
825
+ private _pluginContextMap;
826
+ private _pluginContextMapSsr;
827
+ private _resolvedRollupOptions?;
828
+ private _processesing;
829
+ private _seenResolves;
830
+ private _closed;
831
+ private _moduleNodeToLoadAddedImports;
832
+ getSortedPluginHooks: PluginHookUtils['getSortedPluginHooks'];
833
+ getSortedPlugins: PluginHookUtils['getSortedPlugins'];
834
+ watchFiles: Set<string>;
835
+ minimalContext: MinimalPluginContext;
836
+ private _updateModuleLoadAddedImports;
837
+ private _getAddedImports;
838
+ getModuleInfo(id: string): ModuleInfo | null;
839
+ private handleHookPromise;
840
+ get options(): InputOptions;
841
+ resolveRollupOptions(): Promise<InputOptions>;
842
+ private _getPluginContext;
843
+ private hookParallel;
844
+ buildStart(_options?: InputOptions): Promise<void>;
845
+ resolveId(rawId: string, importer?: string | undefined, options?: {
846
+ attributes?: Record<string, string>;
847
+ custom?: CustomPluginOptions;
848
+ skip?: Set<Plugin>;
849
+ ssr?: boolean;
850
+ isEntry?: boolean;
851
+ }): Promise<PartialResolvedId | null>;
852
+ load(id: string, options?: {
853
+ ssr?: boolean;
854
+ }): Promise<LoadResult | null>;
855
+ transform(code: string, id: string, options?: {
856
+ ssr?: boolean;
857
+ inMap?: SourceDescription['map'];
858
+ }): Promise<{
859
+ code: string;
860
+ map: SourceMap | {
861
+ mappings: '';
862
+ } | null;
863
+ }>;
864
+ watchChange(id: string, change: {
865
+ event: 'create' | 'update' | 'delete';
866
+ }): Promise<void>;
867
+ close(): Promise<void>;
868
+ } // Modified and inlined to avoid extra dependency
869
+ // Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ws/index.d.ts
870
+ declare const WebSocketAlias: typeof WebSocket$1;
871
+ interface WebSocketAlias extends WebSocket$1 {} // WebSocket socket.
872
+ declare class WebSocket$1 extends EventEmitter {
873
+ /** The connection is not yet open. */
874
+ static readonly CONNECTING: 0;
875
+ /** The connection is open and ready to communicate. */
876
+ static readonly OPEN: 1;
877
+ /** The connection is in the process of closing. */
878
+ static readonly CLOSING: 2;
879
+ /** The connection is closed. */
880
+ static readonly CLOSED: 3;
881
+ binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments';
882
+ readonly bufferedAmount: number;
883
+ readonly extensions: string;
884
+ /** Indicates whether the websocket is paused */
885
+ readonly isPaused: boolean;
886
+ readonly protocol: string;
887
+ /** The current state of the connection */
888
+ readonly readyState: typeof WebSocket$1.CONNECTING | typeof WebSocket$1.OPEN | typeof WebSocket$1.CLOSING | typeof WebSocket$1.CLOSED;
889
+ readonly url: string;
890
+ /** The connection is not yet open. */
891
+ readonly CONNECTING: 0;
892
+ /** The connection is open and ready to communicate. */
893
+ readonly OPEN: 1;
894
+ /** The connection is in the process of closing. */
895
+ readonly CLOSING: 2;
896
+ /** The connection is closed. */
897
+ readonly CLOSED: 3;
898
+ onopen: ((event: WebSocket$1.Event) => void) | null;
899
+ onerror: ((event: WebSocket$1.ErrorEvent) => void) | null;
900
+ onclose: ((event: WebSocket$1.CloseEvent) => void) | null;
901
+ onmessage: ((event: WebSocket$1.MessageEvent) => void) | null;
902
+ constructor(address: null);
903
+ constructor(address: string | URL, options?: WebSocket$1.ClientOptions | ClientRequestArgs);
904
+ constructor(address: string | URL, protocols?: string | string[], options?: WebSocket$1.ClientOptions | ClientRequestArgs);
905
+ close(code?: number, data?: string | Buffer): void;
906
+ ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
907
+ pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
908
+ send(data: any, cb?: (err?: Error) => void): void;
909
+ send(data: any, options: {
910
+ mask?: boolean | undefined;
911
+ binary?: boolean | undefined;
912
+ compress?: boolean | undefined;
913
+ fin?: boolean | undefined;
914
+ }, cb?: (err?: Error) => void): void;
915
+ terminate(): void;
916
+ /**
917
+ * Pause the websocket causing it to stop emitting events. Some events can still be
918
+ * emitted after this is called, until all buffered data is consumed. This method
919
+ * is a noop if the ready state is `CONNECTING` or `CLOSED`.
920
+ */
921
+ pause(): void;
922
+ /**
923
+ * Make a paused socket resume emitting events. This method is a noop if the ready
924
+ * state is `CONNECTING` or `CLOSED`.
925
+ */
926
+ resume(): void; // HTML5 WebSocket events
927
+ addEventListener(method: 'message', cb: (event: WebSocket$1.MessageEvent) => void, options?: WebSocket$1.EventListenerOptions): void;
928
+ addEventListener(method: 'close', cb: (event: WebSocket$1.CloseEvent) => void, options?: WebSocket$1.EventListenerOptions): void;
929
+ addEventListener(method: 'error', cb: (event: WebSocket$1.ErrorEvent) => void, options?: WebSocket$1.EventListenerOptions): void;
930
+ addEventListener(method: 'open', cb: (event: WebSocket$1.Event) => void, options?: WebSocket$1.EventListenerOptions): void;
931
+ removeEventListener(method: 'message', cb: (event: WebSocket$1.MessageEvent) => void): void;
932
+ removeEventListener(method: 'close', cb: (event: WebSocket$1.CloseEvent) => void): void;
933
+ removeEventListener(method: 'error', cb: (event: WebSocket$1.ErrorEvent) => void): void;
934
+ removeEventListener(method: 'open', cb: (event: WebSocket$1.Event) => void): void; // Events
935
+ on(event: 'close', listener: (this: WebSocket$1, code: number, reason: Buffer) => void): this;
936
+ on(event: 'error', listener: (this: WebSocket$1, err: Error) => void): this;
937
+ on(event: 'upgrade', listener: (this: WebSocket$1, request: IncomingMessage) => void): this;
938
+ on(event: 'message', listener: (this: WebSocket$1, data: WebSocket$1.RawData, isBinary: boolean) => void): this;
939
+ on(event: 'open', listener: (this: WebSocket$1) => void): this;
940
+ on(event: 'ping' | 'pong', listener: (this: WebSocket$1, data: Buffer) => void): this;
941
+ on(event: 'unexpected-response', listener: (this: WebSocket$1, request: ClientRequest, response: IncomingMessage) => void): this;
942
+ on(event: string | symbol, listener: (this: WebSocket$1, ...args: any[]) => void): this;
943
+ once(event: 'close', listener: (this: WebSocket$1, code: number, reason: Buffer) => void): this;
944
+ once(event: 'error', listener: (this: WebSocket$1, err: Error) => void): this;
945
+ once(event: 'upgrade', listener: (this: WebSocket$1, request: IncomingMessage) => void): this;
946
+ once(event: 'message', listener: (this: WebSocket$1, data: WebSocket$1.RawData, isBinary: boolean) => void): this;
947
+ once(event: 'open', listener: (this: WebSocket$1) => void): this;
948
+ once(event: 'ping' | 'pong', listener: (this: WebSocket$1, data: Buffer) => void): this;
949
+ once(event: 'unexpected-response', listener: (this: WebSocket$1, request: ClientRequest, response: IncomingMessage) => void): this;
950
+ once(event: string | symbol, listener: (this: WebSocket$1, ...args: any[]) => void): this;
951
+ off(event: 'close', listener: (this: WebSocket$1, code: number, reason: Buffer) => void): this;
952
+ off(event: 'error', listener: (this: WebSocket$1, err: Error) => void): this;
953
+ off(event: 'upgrade', listener: (this: WebSocket$1, request: IncomingMessage) => void): this;
954
+ off(event: 'message', listener: (this: WebSocket$1, data: WebSocket$1.RawData, isBinary: boolean) => void): this;
955
+ off(event: 'open', listener: (this: WebSocket$1) => void): this;
956
+ off(event: 'ping' | 'pong', listener: (this: WebSocket$1, data: Buffer) => void): this;
957
+ off(event: 'unexpected-response', listener: (this: WebSocket$1, request: ClientRequest, response: IncomingMessage) => void): this;
958
+ off(event: string | symbol, listener: (this: WebSocket$1, ...args: any[]) => void): this;
959
+ addListener(event: 'close', listener: (code: number, reason: Buffer) => void): this;
960
+ addListener(event: 'error', listener: (err: Error) => void): this;
961
+ addListener(event: 'upgrade', listener: (request: IncomingMessage) => void): this;
962
+ addListener(event: 'message', listener: (data: WebSocket$1.RawData, isBinary: boolean) => void): this;
963
+ addListener(event: 'open', listener: () => void): this;
964
+ addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this;
965
+ addListener(event: 'unexpected-response', listener: (request: ClientRequest, response: IncomingMessage) => void): this;
966
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
967
+ removeListener(event: 'close', listener: (code: number, reason: Buffer) => void): this;
968
+ removeListener(event: 'error', listener: (err: Error) => void): this;
969
+ removeListener(event: 'upgrade', listener: (request: IncomingMessage) => void): this;
970
+ removeListener(event: 'message', listener: (data: WebSocket$1.RawData, isBinary: boolean) => void): this;
971
+ removeListener(event: 'open', listener: () => void): this;
972
+ removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this;
973
+ removeListener(event: 'unexpected-response', listener: (request: ClientRequest, response: IncomingMessage) => void): this;
974
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
975
+ }
976
+ declare namespace WebSocket$1 {
977
+ /**
978
+ * Data represents the raw message payload received over the WebSocket.
979
+ */
980
+ type RawData = Buffer | ArrayBuffer | Buffer[];
981
+ /**
982
+ * Data represents the message payload received over the WebSocket.
983
+ */
984
+ type Data = string | Buffer | ArrayBuffer | Buffer[];
985
+ /**
986
+ * CertMeta represents the accepted types for certificate & key data.
987
+ */
988
+ type CertMeta = string | string[] | Buffer | Buffer[];
989
+ /**
990
+ * VerifyClientCallbackSync is a synchronous callback used to inspect the
991
+ * incoming message. The return value (boolean) of the function determines
992
+ * whether or not to accept the handshake.
993
+ */
994
+ type VerifyClientCallbackSync = (info: {
995
+ origin: string;
996
+ secure: boolean;
997
+ req: IncomingMessage;
998
+ }) => boolean;
999
+ /**
1000
+ * VerifyClientCallbackAsync is an asynchronous callback used to inspect the
1001
+ * incoming message. The return value (boolean) of the function determines
1002
+ * whether or not to accept the handshake.
1003
+ */
1004
+ type VerifyClientCallbackAsync = (info: {
1005
+ origin: string;
1006
+ secure: boolean;
1007
+ req: IncomingMessage;
1008
+ }, callback: (res: boolean, code?: number, message?: string, headers?: OutgoingHttpHeaders) => void) => void;
1009
+ interface ClientOptions extends SecureContextOptions {
1010
+ protocol?: string | undefined;
1011
+ followRedirects?: boolean | undefined;
1012
+ generateMask?(mask: Buffer): void;
1013
+ handshakeTimeout?: number | undefined;
1014
+ maxRedirects?: number | undefined;
1015
+ perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
1016
+ localAddress?: string | undefined;
1017
+ protocolVersion?: number | undefined;
1018
+ headers?: {
1019
+ [key: string]: string;
1020
+ } | undefined;
1021
+ origin?: string | undefined;
1022
+ agent?: Agent | undefined;
1023
+ host?: string | undefined;
1024
+ family?: number | undefined;
1025
+ checkServerIdentity?(servername: string, cert: CertMeta): boolean;
1026
+ rejectUnauthorized?: boolean | undefined;
1027
+ maxPayload?: number | undefined;
1028
+ skipUTF8Validation?: boolean | undefined;
1029
+ }
1030
+ interface PerMessageDeflateOptions {
1031
+ serverNoContextTakeover?: boolean | undefined;
1032
+ clientNoContextTakeover?: boolean | undefined;
1033
+ serverMaxWindowBits?: number | undefined;
1034
+ clientMaxWindowBits?: number | undefined;
1035
+ zlibDeflateOptions?: {
1036
+ flush?: number | undefined;
1037
+ finishFlush?: number | undefined;
1038
+ chunkSize?: number | undefined;
1039
+ windowBits?: number | undefined;
1040
+ level?: number | undefined;
1041
+ memLevel?: number | undefined;
1042
+ strategy?: number | undefined;
1043
+ dictionary?: Buffer | Buffer[] | DataView | undefined;
1044
+ info?: boolean | undefined;
1045
+ } | undefined;
1046
+ zlibInflateOptions?: ZlibOptions | undefined;
1047
+ threshold?: number | undefined;
1048
+ concurrencyLimit?: number | undefined;
1049
+ }
1050
+ interface Event {
1051
+ type: string;
1052
+ target: WebSocket$1;
1053
+ }
1054
+ interface ErrorEvent {
1055
+ error: any;
1056
+ message: string;
1057
+ type: string;
1058
+ target: WebSocket$1;
1059
+ }
1060
+ interface CloseEvent {
1061
+ wasClean: boolean;
1062
+ code: number;
1063
+ reason: string;
1064
+ type: string;
1065
+ target: WebSocket$1;
1066
+ }
1067
+ interface MessageEvent {
1068
+ data: Data;
1069
+ type: string;
1070
+ target: WebSocket$1;
1071
+ }
1072
+ interface EventListenerOptions {
1073
+ once?: boolean | undefined;
1074
+ }
1075
+ interface ServerOptions {
1076
+ host?: string | undefined;
1077
+ port?: number | undefined;
1078
+ backlog?: number | undefined;
1079
+ server?: Server | Server$1 | undefined;
1080
+ verifyClient?: VerifyClientCallbackAsync | VerifyClientCallbackSync | undefined;
1081
+ handleProtocols?: (protocols: Set<string>, request: IncomingMessage) => string | false;
1082
+ path?: string | undefined;
1083
+ noServer?: boolean | undefined;
1084
+ clientTracking?: boolean | undefined;
1085
+ perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
1086
+ maxPayload?: number | undefined;
1087
+ skipUTF8Validation?: boolean | undefined;
1088
+ WebSocket?: typeof WebSocket$1.WebSocket | undefined;
1089
+ }
1090
+ interface AddressInfo {
1091
+ address: string;
1092
+ family: string;
1093
+ port: number;
1094
+ } // WebSocket Server
1095
+ class Server<T extends WebSocket$1 = WebSocket$1> extends EventEmitter {
1096
+ options: ServerOptions$1;
1097
+ path: string;
1098
+ clients: Set<T>;
1099
+ constructor(options?: ServerOptions$1, callback?: () => void);
1100
+ address(): AddressInfo | string;
1101
+ close(cb?: (err?: Error) => void): void;
1102
+ handleUpgrade(request: IncomingMessage, socket: Duplex, upgradeHead: Buffer, callback: (client: T, request: IncomingMessage) => void): void;
1103
+ shouldHandle(request: IncomingMessage): boolean | Promise<boolean>; // Events
1104
+ on(event: 'connection', cb: (this: Server<T>, socket: T, request: IncomingMessage) => void): this;
1105
+ on(event: 'error', cb: (this: Server<T>, error: Error) => void): this;
1106
+ on(event: 'headers', cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void): this;
1107
+ on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this;
1108
+ on(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
1109
+ once(event: 'connection', cb: (this: Server<T>, socket: T, request: IncomingMessage) => void): this;
1110
+ once(event: 'error', cb: (this: Server<T>, error: Error) => void): this;
1111
+ once(event: 'headers', cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void): this;
1112
+ once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this;
1113
+ once(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
1114
+ off(event: 'connection', cb: (this: Server<T>, socket: T, request: IncomingMessage) => void): this;
1115
+ off(event: 'error', cb: (this: Server<T>, error: Error) => void): this;
1116
+ off(event: 'headers', cb: (this: Server<T>, headers: string[], request: IncomingMessage) => void): this;
1117
+ off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this;
1118
+ off(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
1119
+ addListener(event: 'connection', cb: (client: T, request: IncomingMessage) => void): this;
1120
+ addListener(event: 'error', cb: (err: Error) => void): this;
1121
+ addListener(event: 'headers', cb: (headers: string[], request: IncomingMessage) => void): this;
1122
+ addListener(event: 'close' | 'listening', cb: () => void): this;
1123
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
1124
+ removeListener(event: 'connection', cb: (client: T) => void): this;
1125
+ removeListener(event: 'error', cb: (err: Error) => void): this;
1126
+ removeListener(event: 'headers', cb: (headers: string[], request: IncomingMessage) => void): this;
1127
+ removeListener(event: 'close' | 'listening', cb: () => void): this;
1128
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
1129
+ }
1130
+ const WebSocketServer: typeof Server;
1131
+ interface WebSocketServer extends Server {}
1132
+ const WebSocket: typeof WebSocketAlias;
1133
+ interface WebSocket extends WebSocketAlias {} // WebSocket stream
1134
+ function createWebSocketStream(websocket: WebSocket$1, options?: DuplexOptions): Duplex;
1135
+ }
1136
+ interface HmrOptions {
1137
+ protocol?: string;
1138
+ host?: string;
1139
+ port?: number;
1140
+ clientPort?: number;
1141
+ path?: string;
1142
+ timeout?: number;
1143
+ overlay?: boolean;
1144
+ server?: HttpServer;
1145
+ }
1146
+ interface HmrContext {
1147
+ file: string;
1148
+ timestamp: number;
1149
+ modules: Array<ModuleNode>;
1150
+ read: () => string | Promise<string>;
1151
+ server: ViteDevServer;
1152
+ }
1153
+ interface HMRBroadcasterClient {
1154
+ /**
1155
+ * Send event to the client
1156
+ */
1157
+ send(payload: HMRPayload): void;
1158
+ /**
1159
+ * Send custom event
1160
+ */
1161
+ send(event: string, payload?: CustomPayload['data']): void;
1162
+ }
1163
+ interface HMRChannel {
1164
+ /**
1165
+ * Unique channel name
1166
+ */
1167
+ name: string;
1168
+ /**
1169
+ * Broadcast events to all clients
1170
+ */
1171
+ send(payload: HMRPayload): void;
1172
+ /**
1173
+ * Send custom event
1174
+ */
1175
+ send<T extends string>(event: T, payload?: InferCustomEventPayload<T>): void;
1176
+ /**
1177
+ * Handle custom event emitted by `import.meta.hot.send`
1178
+ */
1179
+ on<T extends string>(event: T, listener: (data: InferCustomEventPayload<T>, client: HMRBroadcasterClient, ...args: any[]) => void): void;
1180
+ on(event: 'connection', listener: () => void): void;
1181
+ /**
1182
+ * Unregister event listener
1183
+ */
1184
+ off(event: string, listener: Function): void;
1185
+ /**
1186
+ * Start listening for messages
1187
+ */
1188
+ listen(): void;
1189
+ /**
1190
+ * Disconnect all clients, called when server is closed or restarted.
1191
+ */
1192
+ close(): void;
1193
+ }
1194
+ interface HMRBroadcaster extends Omit<HMRChannel, 'close' | 'name'> {
1195
+ /**
1196
+ * All registered channels. Always has websocket channel.
1197
+ */
1198
+ readonly channels: HMRChannel[];
1199
+ /**
1200
+ * Add a new third-party channel.
1201
+ */
1202
+ addChannel(connection: HMRChannel): HMRBroadcaster;
1203
+ close(): Promise<unknown[]>;
1204
+ }
1205
+ type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
1206
+ interface WebSocketServer extends HMRChannel {
1207
+ /**
1208
+ * Listen on port and host
1209
+ */
1210
+ listen(): void;
1211
+ /**
1212
+ * Get all connected clients.
1213
+ */
1214
+ clients: Set<WebSocketClient>;
1215
+ /**
1216
+ * Disconnect all clients and terminate the server.
1217
+ */
1218
+ close(): Promise<void>;
1219
+ /**
1220
+ * Handle custom event emitted by `import.meta.hot.send`
1221
+ */
1222
+ on: WebSocket$1.Server['on'] & {
1223
+ <T extends string>(event: T, listener: WebSocketCustomListener<InferCustomEventPayload<T>>): void;
1224
+ };
1225
+ /**
1226
+ * Unregister event listener.
1227
+ */
1228
+ off: WebSocket$1.Server['off'] & {
1229
+ (event: string, listener: Function): void;
1230
+ };
1231
+ }
1232
+ interface WebSocketClient {
1233
+ /**
1234
+ * Send event to the client
1235
+ */
1236
+ send(payload: HMRPayload): void;
1237
+ /**
1238
+ * Send custom event
1239
+ */
1240
+ send(event: string, payload?: CustomPayload['data']): void;
1241
+ /**
1242
+ * The raw WebSocket instance
1243
+ * @advanced
1244
+ */
1245
+ socket: WebSocket$1;
1246
+ }
1247
+ interface ServerOptions$1 extends CommonServerOptions {
1248
+ /**
1249
+ * Configure HMR-specific options (port, host, path & protocol)
1250
+ */
1251
+ hmr?: HmrOptions | boolean;
1252
+ /**
1253
+ * Do not start the websocket connection.
1254
+ * @experimental
1255
+ */
1256
+ ws?: false;
1257
+ /**
1258
+ * Warm-up files to transform and cache the results in advance. This improves the
1259
+ * initial page load during server starts and prevents transform waterfalls.
1260
+ */
1261
+ warmup?: {
1262
+ /**
1263
+ * The files to be transformed and used on the client-side. Supports glob patterns.
1264
+ */
1265
+ clientFiles?: string[];
1266
+ /**
1267
+ * The files to be transformed and used in SSR. Supports glob patterns.
1268
+ */
1269
+ ssrFiles?: string[];
1270
+ };
1271
+ /**
1272
+ * chokidar watch options or null to disable FS watching
1273
+ * https://github.com/paulmillr/chokidar#api
1274
+ */
1275
+ watch?: WatchOptions | null;
1276
+ /**
1277
+ * Create Vite dev server to be used as a middleware in an existing server
1278
+ * @default false
1279
+ */
1280
+ middlewareMode?: boolean | {
1281
+ /**
1282
+ * Parent server instance to attach to
1283
+ *
1284
+ * This is needed to proxy WebSocket connections to the parent server.
1285
+ */
1286
+ server: HttpServer;
1287
+ };
1288
+ /**
1289
+ * Options for files served via '/\@fs/'.
1290
+ */
1291
+ fs?: FileSystemServeOptions;
1292
+ /**
1293
+ * Origin for the generated asset URLs.
1294
+ *
1295
+ * @example `http://127.0.0.1:8080`
1296
+ */
1297
+ origin?: string;
1298
+ /**
1299
+ * Pre-transform known direct imports
1300
+ * @default true
1301
+ */
1302
+ preTransformRequests?: boolean;
1303
+ /**
1304
+ * Whether or not to ignore-list source files in the dev server sourcemap, used to populate
1305
+ * the [`x_google_ignoreList` source map extension](https://developer.chrome.com/blog/devtools-better-angular-debugging/#the-x_google_ignorelist-source-map-extension).
1306
+ *
1307
+ * By default, it excludes all paths containing `node_modules`. You can pass `false` to
1308
+ * disable this behavior, or, for full control, a function that takes the source path and
1309
+ * sourcemap path and returns whether to ignore the source path.
1310
+ */
1311
+ sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
1312
+ }
1313
+ interface ResolvedServerOptions extends Omit<ServerOptions$1, 'fs' | 'middlewareMode' | 'sourcemapIgnoreList'> {
1314
+ fs: Required<FileSystemServeOptions>;
1315
+ middlewareMode: NonNullable<ServerOptions$1['middlewareMode']>;
1316
+ sourcemapIgnoreList: Exclude<ServerOptions$1['sourcemapIgnoreList'], false | undefined>;
1317
+ }
1318
+ interface FileSystemServeOptions {
1319
+ /**
1320
+ * Strictly restrict file accessing outside of allowing paths.
1321
+ *
1322
+ * Set to `false` to disable the warning
1323
+ *
1324
+ * @default true
1325
+ */
1326
+ strict?: boolean;
1327
+ /**
1328
+ * Restrict accessing files outside the allowed directories.
1329
+ *
1330
+ * Accepts absolute path or a path relative to project root.
1331
+ * Will try to search up for workspace root by default.
1332
+ */
1333
+ allow?: string[];
1334
+ /**
1335
+ * Restrict accessing files that matches the patterns.
1336
+ *
1337
+ * This will have higher priority than `allow`.
1338
+ * picomatch patterns are supported.
1339
+ *
1340
+ * @default ['.env', '.env.*', '*.crt', '*.pem']
1341
+ */
1342
+ deny?: string[];
1343
+ /**
1344
+ * Enable caching of fs calls. It is enabled by default if no custom watch ignored patterns are provided.
1345
+ *
1346
+ * @experimental
1347
+ * @default undefined
1348
+ */
1349
+ cachedChecks?: boolean;
1350
+ }
1351
+ type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
1352
+ type HttpServer = http.Server | Http2SecureServer;
1353
+ interface ViteDevServer {
1354
+ /**
1355
+ * The resolved vite config object
1356
+ */
1357
+ config: ResolvedConfig;
1358
+ /**
1359
+ * A connect app instance.
1360
+ * - Can be used to attach custom middlewares to the dev server.
1361
+ * - Can also be used as the handler function of a custom http server
1362
+ * or as a middleware in any connect-style Node.js frameworks
1363
+ *
1364
+ * https://github.com/senchalabs/connect#use-middleware
1365
+ */
1366
+ middlewares: Connect.Server;
1367
+ /**
1368
+ * native Node http server instance
1369
+ * will be null in middleware mode
1370
+ */
1371
+ httpServer: HttpServer | null;
1372
+ /**
1373
+ * chokidar watcher instance
1374
+ * https://github.com/paulmillr/chokidar#api
1375
+ */
1376
+ watcher: FSWatcher;
1377
+ /**
1378
+ * web socket server with `send(payload)` method
1379
+ */
1380
+ ws: WebSocketServer;
1381
+ /**
1382
+ * HMR broadcaster that can be used to send custom HMR messages to the client
1383
+ *
1384
+ * Always sends a message to at least a WebSocket client. Any third party can
1385
+ * add a channel to the broadcaster to process messages
1386
+ * @deprecated will be replaced with the environment api in v6.
1387
+ */
1388
+ hot: HMRBroadcaster;
1389
+ /**
1390
+ * Rollup plugin container that can run plugin hooks on a given file
1391
+ */
1392
+ pluginContainer: PluginContainer;
1393
+ /**
1394
+ * Module graph that tracks the import relationships, url to file mapping
1395
+ * and hmr state.
1396
+ */
1397
+ moduleGraph: ModuleGraph;
1398
+ /**
1399
+ * The resolved urls Vite prints on the CLI. null in middleware mode or
1400
+ * before `server.listen` is called.
1401
+ */
1402
+ resolvedUrls: ResolvedServerUrls | null;
1403
+ /**
1404
+ * Programmatically resolve, load and transform a URL and get the result
1405
+ * without going through the http request pipeline.
1406
+ */
1407
+ transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
1408
+ /**
1409
+ * Same as `transformRequest` but only warm up the URLs so the next request
1410
+ * will already be cached. The function will never throw as it handles and
1411
+ * reports errors internally.
1412
+ */
1413
+ warmupRequest(url: string, options?: TransformOptions): Promise<void>;
1414
+ /**
1415
+ * Apply vite built-in HTML transforms and any plugin HTML transforms.
1416
+ */
1417
+ transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
1418
+ /**
1419
+ * Transform module code into SSR format.
1420
+ */
1421
+ ssrTransform(code: string, inMap: SourceMap | {
1422
+ mappings: '';
1423
+ } | null, url: string, originalCode?: string): Promise<TransformResult | null>;
1424
+ /**
1425
+ * Load a given URL as an instantiated module for SSR.
1426
+ */
1427
+ ssrLoadModule(url: string, opts?: {
1428
+ fixStacktrace?: boolean;
1429
+ }): Promise<Record<string, any>>;
1430
+ /**
1431
+ * Fetch information about the module for Vite SSR runtime.
1432
+ * @experimental
1433
+ */
1434
+ ssrFetchModule(id: string, importer?: string): Promise<FetchResult>;
1435
+ /**
1436
+ * Returns a fixed version of the given stack
1437
+ */
1438
+ ssrRewriteStacktrace(stack: string): string;
1439
+ /**
1440
+ * Mutates the given SSR error by rewriting the stacktrace
1441
+ */
1442
+ ssrFixStacktrace(e: Error): void;
1443
+ /**
1444
+ * Triggers HMR for a module in the module graph. You can use the `server.moduleGraph`
1445
+ * API to retrieve the module to be reloaded. If `hmr` is false, this is a no-op.
1446
+ */
1447
+ reloadModule(module: ModuleNode): Promise<void>;
1448
+ /**
1449
+ * Start the server.
1450
+ */
1451
+ listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
1452
+ /**
1453
+ * Stop the server.
1454
+ */
1455
+ close(): Promise<void>;
1456
+ /**
1457
+ * Print server urls
1458
+ */
1459
+ printUrls(): void;
1460
+ /**
1461
+ * Bind CLI shortcuts
1462
+ */
1463
+ bindCLIShortcuts(options?: BindCLIShortcutsOptions<ViteDevServer>): void;
1464
+ /**
1465
+ * Restart the server.
1466
+ *
1467
+ * @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
1468
+ */
1469
+ restart(forceOptimize?: boolean): Promise<void>;
1470
+ /**
1471
+ * Open browser
1472
+ */
1473
+ openBrowser(): void;
1474
+ /**
1475
+ * Calling `await server.waitForRequestsIdle(id)` will wait until all static imports
1476
+ * are processed. If called from a load or transform plugin hook, the id needs to be
1477
+ * passed as a parameter to avoid deadlocks. Calling this function after the first
1478
+ * static imports section of the module graph has been processed will resolve immediately.
1479
+ * @experimental
1480
+ */
1481
+ waitForRequestsIdle: (ignoredId?: string) => Promise<void>;
1482
+ }
1483
+ interface ResolvedServerUrls {
1484
+ local: string[];
1485
+ network: string[];
1486
+ }
1487
+ /** Cache for package.json resolution and package.json contents */
1488
+ type PackageCache = Map<string, PackageData>;
1489
+ interface PackageData {
1490
+ dir: string;
1491
+ hasSideEffects: (id: string) => boolean | 'no-treeshake' | null;
1492
+ webResolvedImports: Record<string, string | undefined>;
1493
+ nodeResolvedImports: Record<string, string | undefined>;
1494
+ setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
1495
+ getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
1496
+ data: {
1497
+ [field: string]: any;
1498
+ name: string;
1499
+ type: string;
1500
+ version: string;
1501
+ main: string;
1502
+ module: string;
1503
+ browser: string | Record<string, string | false>;
1504
+ exports: string | Record<string, any> | string[];
1505
+ imports: Record<string, any>;
1506
+ dependencies: Record<string, string>;
1507
+ };
1508
+ }
1509
+ interface RollupCommonJSOptions {
1510
+ /**
1511
+ * A minimatch pattern, or array of patterns, which specifies the files in
1512
+ * the build the plugin should operate on. By default, all files with
1513
+ * extension `".cjs"` or those in `extensions` are included, but you can
1514
+ * narrow this list by only including specific files. These files will be
1515
+ * analyzed and transpiled if either the analysis does not find ES module
1516
+ * specific statements or `transformMixedEsModules` is `true`.
1517
+ * @default undefined
1518
+ */
1519
+ include?: string | RegExp | readonly (string | RegExp)[];
1520
+ /**
1521
+ * A minimatch pattern, or array of patterns, which specifies the files in
1522
+ * the build the plugin should _ignore_. By default, all files with
1523
+ * extensions other than those in `extensions` or `".cjs"` are ignored, but you
1524
+ * can exclude additional files. See also the `include` option.
1525
+ * @default undefined
1526
+ */
1527
+ exclude?: string | RegExp | readonly (string | RegExp)[];
1528
+ /**
1529
+ * For extensionless imports, search for extensions other than .js in the
1530
+ * order specified. Note that you need to make sure that non-JavaScript files
1531
+ * are transpiled by another plugin first.
1532
+ * @default [ '.js' ]
1533
+ */
1534
+ extensions?: ReadonlyArray<string>;
1535
+ /**
1536
+ * If true then uses of `global` won't be dealt with by this plugin
1537
+ * @default false
1538
+ */
1539
+ ignoreGlobal?: boolean;
1540
+ /**
1541
+ * If false, skips source map generation for CommonJS modules. This will
1542
+ * improve performance.
1543
+ * @default true
1544
+ */
1545
+ sourceMap?: boolean;
1546
+ /**
1547
+ * Some `require` calls cannot be resolved statically to be translated to
1548
+ * imports.
1549
+ * When this option is set to `false`, the generated code will either
1550
+ * directly throw an error when such a call is encountered or, when
1551
+ * `dynamicRequireTargets` is used, when such a call cannot be resolved with a
1552
+ * configured dynamic require target.
1553
+ * Setting this option to `true` will instead leave the `require` call in the
1554
+ * code or use it as a fallback for `dynamicRequireTargets`.
1555
+ * @default false
1556
+ */
1557
+ ignoreDynamicRequires?: boolean;
1558
+ /**
1559
+ * Instructs the plugin whether to enable mixed module transformations. This
1560
+ * is useful in scenarios with modules that contain a mix of ES `import`
1561
+ * statements and CommonJS `require` expressions. Set to `true` if `require`
1562
+ * calls should be transformed to imports in mixed modules, or `false` if the
1563
+ * `require` expressions should survive the transformation. The latter can be
1564
+ * important if the code contains environment detection, or you are coding
1565
+ * for an environment with special treatment for `require` calls such as
1566
+ * ElectronJS. See also the `ignore` option.
1567
+ * @default false
1568
+ */
1569
+ transformMixedEsModules?: boolean;
1570
+ /**
1571
+ * By default, this plugin will try to hoist `require` statements as imports
1572
+ * to the top of each file. While this works well for many code bases and
1573
+ * allows for very efficient ESM output, it does not perfectly capture
1574
+ * CommonJS semantics as the order of side effects like log statements may
1575
+ * change. But it is especially problematic when there are circular `require`
1576
+ * calls between CommonJS modules as those often rely on the lazy execution of
1577
+ * nested `require` calls.
1578
+ *
1579
+ * Setting this option to `true` will wrap all CommonJS files in functions
1580
+ * which are executed when they are required for the first time, preserving
1581
+ * NodeJS semantics. Note that this can have an impact on the size and
1582
+ * performance of the generated code.
1583
+ *
1584
+ * The default value of `"auto"` will only wrap CommonJS files when they are
1585
+ * part of a CommonJS dependency cycle, e.g. an index file that is required by
1586
+ * many of its dependencies. All other CommonJS files are hoisted. This is the
1587
+ * recommended setting for most code bases.
1588
+ *
1589
+ * `false` will entirely prevent wrapping and hoist all files. This may still
1590
+ * work depending on the nature of cyclic dependencies but will often cause
1591
+ * problems.
1592
+ *
1593
+ * You can also provide a minimatch pattern, or array of patterns, to only
1594
+ * specify a subset of files which should be wrapped in functions for proper
1595
+ * `require` semantics.
1596
+ *
1597
+ * `"debug"` works like `"auto"` but after bundling, it will display a warning
1598
+ * containing a list of ids that have been wrapped which can be used as
1599
+ * minimatch pattern for fine-tuning.
1600
+ * @default "auto"
1601
+ */
1602
+ strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[];
1603
+ /**
1604
+ * Sometimes you have to leave require statements unconverted. Pass an array
1605
+ * containing the IDs or a `id => boolean` function.
1606
+ * @default []
1607
+ */
1608
+ ignore?: ReadonlyArray<string> | ((id: string) => boolean);
1609
+ /**
1610
+ * In most cases, where `require` calls are inside a `try-catch` clause,
1611
+ * they should be left unconverted as it requires an optional dependency
1612
+ * that may or may not be installed beside the rolled up package.
1613
+ * Due to the conversion of `require` to a static `import` - the call is
1614
+ * hoisted to the top of the file, outside the `try-catch` clause.
1615
+ *
1616
+ * - `true`: Default. All `require` calls inside a `try` will be left unconverted.
1617
+ * - `false`: All `require` calls inside a `try` will be converted as if the
1618
+ * `try-catch` clause is not there.
1619
+ * - `remove`: Remove all `require` calls from inside any `try` block.
1620
+ * - `string[]`: Pass an array containing the IDs to left unconverted.
1621
+ * - `((id: string) => boolean|'remove')`: Pass a function that controls
1622
+ * individual IDs.
1623
+ *
1624
+ * @default true
1625
+ */
1626
+ ignoreTryCatch?: boolean | 'remove' | ReadonlyArray<string> | ((id: string) => boolean | 'remove');
1627
+ /**
1628
+ * Controls how to render imports from external dependencies. By default,
1629
+ * this plugin assumes that all external dependencies are CommonJS. This
1630
+ * means they are rendered as default imports to be compatible with e.g.
1631
+ * NodeJS where ES modules can only import a default export from a CommonJS
1632
+ * dependency.
1633
+ *
1634
+ * If you set `esmExternals` to `true`, this plugin assumes that all
1635
+ * external dependencies are ES modules and respect the
1636
+ * `requireReturnsDefault` option. If that option is not set, they will be
1637
+ * rendered as namespace imports.
1638
+ *
1639
+ * You can also supply an array of ids to be treated as ES modules, or a
1640
+ * function that will be passed each external id to determine whether it is
1641
+ * an ES module.
1642
+ * @default false
1643
+ */
1644
+ esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean);
1645
+ /**
1646
+ * Controls what is returned when requiring an ES module from a CommonJS file.
1647
+ * When using the `esmExternals` option, this will also apply to external
1648
+ * modules. By default, this plugin will render those imports as namespace
1649
+ * imports i.e.
1650
+ *
1651
+ * ```js
1652
+ * // input
1653
+ * const foo = require('foo');
1654
+ *
1655
+ * // output
1656
+ * import * as foo from 'foo';
1657
+ * ```
1658
+ *
1659
+ * However, there are some situations where this may not be desired.
1660
+ * For these situations, you can change Rollup's behaviour either globally or
1661
+ * per module. To change it globally, set the `requireReturnsDefault` option
1662
+ * to one of the following values:
1663
+ *
1664
+ * - `false`: This is the default, requiring an ES module returns its
1665
+ * namespace. This is the only option that will also add a marker
1666
+ * `__esModule: true` to the namespace to support interop patterns in
1667
+ * CommonJS modules that are transpiled ES modules.
1668
+ * - `"namespace"`: Like `false`, requiring an ES module returns its
1669
+ * namespace, but the plugin does not add the `__esModule` marker and thus
1670
+ * creates more efficient code. For external dependencies when using
1671
+ * `esmExternals: true`, no additional interop code is generated.
1672
+ * - `"auto"`: This is complementary to how `output.exports: "auto"` works in
1673
+ * Rollup: If a module has a default export and no named exports, requiring
1674
+ * that module returns the default export. In all other cases, the namespace
1675
+ * is returned. For external dependencies when using `esmExternals: true`, a
1676
+ * corresponding interop helper is added.
1677
+ * - `"preferred"`: If a module has a default export, requiring that module
1678
+ * always returns the default export, no matter whether additional named
1679
+ * exports exist. This is similar to how previous versions of this plugin
1680
+ * worked. Again for external dependencies when using `esmExternals: true`,
1681
+ * an interop helper is added.
1682
+ * - `true`: This will always try to return the default export on require
1683
+ * without checking if it actually exists. This can throw at build time if
1684
+ * there is no default export. This is how external dependencies are handled
1685
+ * when `esmExternals` is not used. The advantage over the other options is
1686
+ * that, like `false`, this does not add an interop helper for external
1687
+ * dependencies, keeping the code lean.
1688
+ *
1689
+ * To change this for individual modules, you can supply a function for
1690
+ * `requireReturnsDefault` instead. This function will then be called once for
1691
+ * each required ES module or external dependency with the corresponding id
1692
+ * and allows you to return different values for different modules.
1693
+ * @default false
1694
+ */
1695
+ requireReturnsDefault?: boolean | 'auto' | 'preferred' | 'namespace' | ((id: string) => boolean | 'auto' | 'preferred' | 'namespace');
1696
+ /**
1697
+ * @default "auto"
1698
+ */
1699
+ defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto');
1700
+ /**
1701
+ * Some modules contain dynamic `require` calls, or require modules that
1702
+ * contain circular dependencies, which are not handled well by static
1703
+ * imports. Including those modules as `dynamicRequireTargets` will simulate a
1704
+ * CommonJS (NodeJS-like) environment for them with support for dynamic
1705
+ * dependencies. It also enables `strictRequires` for those modules.
1706
+ *
1707
+ * Note: In extreme cases, this feature may result in some paths being
1708
+ * rendered as absolute in the final bundle. The plugin tries to avoid
1709
+ * exposing paths from the local machine, but if you are `dynamicRequirePaths`
1710
+ * with paths that are far away from your project's folder, that may require
1711
+ * replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
1712
+ */
1713
+ dynamicRequireTargets?: string | ReadonlyArray<string>;
1714
+ /**
1715
+ * To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
1716
+ * that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
1717
+ * may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
1718
+ * home directory name. By default, it uses the current working directory.
1719
+ */
1720
+ dynamicRequireRoot?: string;
1721
+ }
1722
+ interface RollupDynamicImportVarsOptions {
1723
+ /**
1724
+ * Files to include in this plugin (default all).
1725
+ * @default []
1726
+ */
1727
+ include?: string | RegExp | (string | RegExp)[];
1728
+ /**
1729
+ * Files to exclude in this plugin (default none).
1730
+ * @default []
1731
+ */
1732
+ exclude?: string | RegExp | (string | RegExp)[];
1733
+ /**
1734
+ * By default, the plugin quits the build process when it encounters an error. If you set this option to true, it will throw a warning instead and leave the code untouched.
1735
+ * @default false
1736
+ */
1737
+ warnOnError?: boolean;
1738
+ } // Modified and inlined to avoid extra dependency
1739
+ // Source: https://github.com/terser/terser/blob/master/tools/terser.d.ts
1740
+ // BSD Licensed https://github.com/terser/terser/blob/master/LICENSE
1741
+ declare namespace Terser {
1742
+ export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020;
1743
+ export type ConsoleProperty = keyof typeof console;
1744
+ type DropConsoleOption = boolean | ConsoleProperty[];
1745
+ export interface ParseOptions {
1746
+ bare_returns?: boolean;
1747
+ /** @deprecated legacy option. Currently, all supported EcmaScript is valid to parse. */
1748
+ ecma?: ECMA;
1749
+ html5_comments?: boolean;
1750
+ shebang?: boolean;
1751
+ }
1752
+ export interface CompressOptions {
1753
+ arguments?: boolean;
1754
+ arrows?: boolean;
1755
+ booleans_as_integers?: boolean;
1756
+ booleans?: boolean;
1757
+ collapse_vars?: boolean;
1758
+ comparisons?: boolean;
1759
+ computed_props?: boolean;
1760
+ conditionals?: boolean;
1761
+ dead_code?: boolean;
1762
+ defaults?: boolean;
1763
+ directives?: boolean;
1764
+ drop_console?: DropConsoleOption;
1765
+ drop_debugger?: boolean;
1766
+ ecma?: ECMA;
1767
+ evaluate?: boolean;
1768
+ expression?: boolean;
1769
+ global_defs?: object;
1770
+ hoist_funs?: boolean;
1771
+ hoist_props?: boolean;
1772
+ hoist_vars?: boolean;
1773
+ ie8?: boolean;
1774
+ if_return?: boolean;
1775
+ inline?: boolean | InlineFunctions;
1776
+ join_vars?: boolean;
1777
+ keep_classnames?: boolean | RegExp;
1778
+ keep_fargs?: boolean;
1779
+ keep_fnames?: boolean | RegExp;
1780
+ keep_infinity?: boolean;
1781
+ loops?: boolean;
1782
+ module?: boolean;
1783
+ negate_iife?: boolean;
1784
+ passes?: number;
1785
+ properties?: boolean;
1786
+ pure_funcs?: string[];
1787
+ pure_new?: boolean;
1788
+ pure_getters?: boolean | 'strict';
1789
+ reduce_funcs?: boolean;
1790
+ reduce_vars?: boolean;
1791
+ sequences?: boolean | number;
1792
+ side_effects?: boolean;
1793
+ switches?: boolean;
1794
+ toplevel?: boolean;
1795
+ top_retain?: null | string | string[] | RegExp;
1796
+ typeofs?: boolean;
1797
+ unsafe_arrows?: boolean;
1798
+ unsafe?: boolean;
1799
+ unsafe_comps?: boolean;
1800
+ unsafe_Function?: boolean;
1801
+ unsafe_math?: boolean;
1802
+ unsafe_symbols?: boolean;
1803
+ unsafe_methods?: boolean;
1804
+ unsafe_proto?: boolean;
1805
+ unsafe_regexp?: boolean;
1806
+ unsafe_undefined?: boolean;
1807
+ unused?: boolean;
1808
+ }
1809
+ export enum InlineFunctions {
1810
+ Disabled = 0,
1811
+ SimpleFunctions = 1,
1812
+ WithArguments = 2,
1813
+ WithArgumentsAndVariables = 3
1814
+ }
1815
+ export interface MangleOptions {
1816
+ eval?: boolean;
1817
+ keep_classnames?: boolean | RegExp;
1818
+ keep_fnames?: boolean | RegExp;
1819
+ module?: boolean;
1820
+ nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler;
1821
+ properties?: boolean | ManglePropertiesOptions;
1822
+ reserved?: string[];
1823
+ safari10?: boolean;
1824
+ toplevel?: boolean;
1825
+ }
1826
+ /**
1827
+ * An identifier mangler for which the output is invariant with respect to the source code.
1828
+ */
1829
+ export interface SimpleIdentifierMangler {
1830
+ /**
1831
+ * Obtains the nth most favored (usually shortest) identifier to rename a variable to.
1832
+ * The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word.
1833
+ * This function is expected to be stable; Evaluating get(n) === get(n) should always return true.
1834
+ * @param n The ordinal of the identifier.
1835
+ */
1836
+ get(n: number): string;
1837
+ }
1838
+ /**
1839
+ * An identifier mangler that leverages character frequency analysis to determine identifier precedence.
1840
+ */
1841
+ export interface WeightedIdentifierMangler extends SimpleIdentifierMangler {
1842
+ /**
1843
+ * Modifies the internal weighting of the input characters by the specified delta.
1844
+ * Will be invoked on the entire printed AST, and then deduct mangleable identifiers.
1845
+ * @param chars The characters to modify the weighting of.
1846
+ * @param delta The numeric weight to add to the characters.
1847
+ */
1848
+ consider(chars: string, delta: number): number;
1849
+ /**
1850
+ * Resets character weights.
1851
+ */
1852
+ reset(): void;
1853
+ /**
1854
+ * Sorts identifiers by character frequency, in preparation for calls to get(n).
1855
+ */
1856
+ sort(): void;
1857
+ }
1858
+ export interface ManglePropertiesOptions {
1859
+ builtins?: boolean;
1860
+ debug?: boolean;
1861
+ keep_quoted?: boolean | 'strict';
1862
+ nth_identifier?: SimpleIdentifierMangler | WeightedIdentifierMangler;
1863
+ regex?: RegExp | string;
1864
+ reserved?: string[];
1865
+ }
1866
+ export interface FormatOptions {
1867
+ ascii_only?: boolean;
1868
+ /** @deprecated Not implemented anymore */
1869
+ beautify?: boolean;
1870
+ braces?: boolean;
1871
+ comments?: boolean | 'all' | 'some' | RegExp | ((node: any, comment: {
1872
+ value: string;
1873
+ type: 'comment1' | 'comment2' | 'comment3' | 'comment4';
1874
+ pos: number;
1875
+ line: number;
1876
+ col: number;
1877
+ }) => boolean);
1878
+ ecma?: ECMA;
1879
+ ie8?: boolean;
1880
+ keep_numbers?: boolean;
1881
+ indent_level?: number;
1882
+ indent_start?: number;
1883
+ inline_script?: boolean;
1884
+ keep_quoted_props?: boolean;
1885
+ max_line_len?: number | false;
1886
+ preamble?: string;
1887
+ preserve_annotations?: boolean;
1888
+ quote_keys?: boolean;
1889
+ quote_style?: OutputQuoteStyle;
1890
+ safari10?: boolean;
1891
+ semicolons?: boolean;
1892
+ shebang?: boolean;
1893
+ shorthand?: boolean;
1894
+ source_map?: SourceMapOptions;
1895
+ webkit?: boolean;
1896
+ width?: number;
1897
+ wrap_iife?: boolean;
1898
+ wrap_func_args?: boolean;
1899
+ }
1900
+ export enum OutputQuoteStyle {
1901
+ PreferDouble = 0,
1902
+ AlwaysSingle = 1,
1903
+ AlwaysDouble = 2,
1904
+ AlwaysOriginal = 3
1905
+ }
1906
+ export interface MinifyOptions {
1907
+ compress?: boolean | CompressOptions;
1908
+ ecma?: ECMA;
1909
+ enclose?: boolean | string;
1910
+ ie8?: boolean;
1911
+ keep_classnames?: boolean | RegExp;
1912
+ keep_fnames?: boolean | RegExp;
1913
+ mangle?: boolean | MangleOptions;
1914
+ module?: boolean;
1915
+ nameCache?: object;
1916
+ format?: FormatOptions;
1917
+ /** @deprecated */
1918
+ output?: FormatOptions;
1919
+ parse?: ParseOptions;
1920
+ safari10?: boolean;
1921
+ sourceMap?: boolean | SourceMapOptions;
1922
+ toplevel?: boolean;
1923
+ }
1924
+ export interface MinifyOutput {
1925
+ code?: string;
1926
+ map?: object | string;
1927
+ decoded_map?: object | null;
1928
+ }
1929
+ export interface SourceMapOptions {
1930
+ /** Source map object, 'inline' or source map file content */
1931
+ content?: object | string;
1932
+ includeSources?: boolean;
1933
+ filename?: string;
1934
+ root?: string;
1935
+ asObject?: boolean;
1936
+ url?: string | 'inline';
1937
+ }
1938
+ }
1939
+ interface TerserOptions extends Terser.MinifyOptions {
1940
+ /**
1941
+ * Vite-specific option to specify the max number of workers to spawn
1942
+ * when minifying files with terser.
1943
+ *
1944
+ * @default number of CPUs minus 1
1945
+ */
1946
+ maxWorkers?: number;
1947
+ }
1948
+ interface BuildOptions {
1949
+ /**
1950
+ * Compatibility transform target. The transform is performed with esbuild
1951
+ * and the lowest supported target is es2015/es6. Note this only handles
1952
+ * syntax transformation and does not cover polyfills (except for dynamic
1953
+ * import)
1954
+ *
1955
+ * Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
1956
+ * transpile targeting browsers that natively support dynamic es module imports.
1957
+ * https://caniuse.com/es6-module-dynamic-import
1958
+ *
1959
+ * Another special value is 'esnext' - which only performs minimal transpiling
1960
+ * (for minification compat) and assumes native dynamic imports support.
1961
+ *
1962
+ * For custom targets, see https://esbuild.github.io/api/#target and
1963
+ * https://esbuild.github.io/content-types/#javascript for more details.
1964
+ * @default 'modules'
1965
+ */
1966
+ target?: 'modules' | TransformOptions$1['target'] | false;
1967
+ /**
1968
+ * whether to inject module preload polyfill.
1969
+ * Note: does not apply to library mode.
1970
+ * @default true
1971
+ * @deprecated use `modulePreload.polyfill` instead
1972
+ */
1973
+ polyfillModulePreload?: boolean;
1974
+ /**
1975
+ * Configure module preload
1976
+ * Note: does not apply to library mode.
1977
+ * @default true
1978
+ */
1979
+ modulePreload?: boolean | ModulePreloadOptions;
1980
+ /**
1981
+ * Directory relative from `root` where build output will be placed. If the
1982
+ * directory exists, it will be removed before the build.
1983
+ * @default 'dist'
1984
+ */
1985
+ outDir?: string;
1986
+ /**
1987
+ * Directory relative from `outDir` where the built js/css/image assets will
1988
+ * be placed.
1989
+ * @default 'assets'
1990
+ */
1991
+ assetsDir?: string;
1992
+ /**
1993
+ * Static asset files smaller than this number (in bytes) will be inlined as
1994
+ * base64 strings. Default limit is `4096` (4 KiB). Set to `0` to disable.
1995
+ * @default 4096
1996
+ */
1997
+ assetsInlineLimit?: number | ((filePath: string, content: Buffer) => boolean | undefined);
1998
+ /**
1999
+ * Whether to code-split CSS. When enabled, CSS in async chunks will be
2000
+ * inlined as strings in the chunk and inserted via dynamically created
2001
+ * style tags when the chunk is loaded.
2002
+ * @default true
2003
+ */
2004
+ cssCodeSplit?: boolean;
2005
+ /**
2006
+ * An optional separate target for CSS minification.
2007
+ * As esbuild only supports configuring targets to mainstream
2008
+ * browsers, users may need this option when they are targeting
2009
+ * a niche browser that comes with most modern JavaScript features
2010
+ * but has poor CSS support, e.g. Android WeChat WebView, which
2011
+ * doesn't support the #RGBA syntax.
2012
+ * @default target
2013
+ */
2014
+ cssTarget?: TransformOptions$1['target'] | false;
2015
+ /**
2016
+ * Override CSS minification specifically instead of defaulting to `build.minify`,
2017
+ * so you can configure minification for JS and CSS separately.
2018
+ * @default 'esbuild'
2019
+ */
2020
+ cssMinify?: boolean | 'esbuild' | 'lightningcss';
2021
+ /**
2022
+ * If `true`, a separate sourcemap file will be created. If 'inline', the
2023
+ * sourcemap will be appended to the resulting output file as data URI.
2024
+ * 'hidden' works like `true` except that the corresponding sourcemap
2025
+ * comments in the bundled files are suppressed.
2026
+ * @default false
2027
+ */
2028
+ sourcemap?: boolean | 'inline' | 'hidden';
2029
+ /**
2030
+ * Set to `false` to disable minification, or specify the minifier to use.
2031
+ * Available options are 'terser' or 'esbuild'.
2032
+ * @default 'esbuild'
2033
+ */
2034
+ minify?: boolean | 'terser' | 'esbuild';
2035
+ /**
2036
+ * Options for terser
2037
+ * https://terser.org/docs/api-reference#minify-options
2038
+ *
2039
+ * In addition, you can also pass a `maxWorkers: number` option to specify the
2040
+ * max number of workers to spawn. Defaults to the number of CPUs minus 1.
2041
+ */
2042
+ terserOptions?: TerserOptions;
2043
+ /**
2044
+ * Will be merged with internal rollup options.
2045
+ * https://rollupjs.org/configuration-options/
2046
+ */
2047
+ rollupOptions?: RollupOptions;
2048
+ /**
2049
+ * Options to pass on to `@rollup/plugin-commonjs`
2050
+ */
2051
+ commonjsOptions?: RollupCommonJSOptions;
2052
+ /**
2053
+ * Options to pass on to `@rollup/plugin-dynamic-import-vars`
2054
+ */
2055
+ dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
2056
+ /**
2057
+ * Whether to write bundle to disk
2058
+ * @default true
2059
+ */
2060
+ write?: boolean;
2061
+ /**
2062
+ * Empty outDir on write.
2063
+ * @default true when outDir is a sub directory of project root
2064
+ */
2065
+ emptyOutDir?: boolean | null;
2066
+ /**
2067
+ * Copy the public directory to outDir on write.
2068
+ * @default true
2069
+ */
2070
+ copyPublicDir?: boolean;
2071
+ /**
2072
+ * Whether to emit a .vite/manifest.json under assets dir to map hash-less filenames
2073
+ * to their hashed versions. Useful when you want to generate your own HTML
2074
+ * instead of using the one generated by Vite.
2075
+ *
2076
+ * Example:
2077
+ *
2078
+ * ```json
2079
+ * {
2080
+ * "main.js": {
2081
+ * "file": "main.68fe3fad.js",
2082
+ * "css": "main.e6b63442.css",
2083
+ * "imports": [...],
2084
+ * "dynamicImports": [...]
2085
+ * }
2086
+ * }
2087
+ * ```
2088
+ * @default false
2089
+ */
2090
+ manifest?: boolean | string;
2091
+ /**
2092
+ * Build in library mode. The value should be the global name of the lib in
2093
+ * UMD mode. This will produce esm + cjs + umd bundle formats with default
2094
+ * configurations that are suitable for distributing libraries.
2095
+ * @default false
2096
+ */
2097
+ lib?: LibraryOptions | false;
2098
+ /**
2099
+ * Produce SSR oriented build. Note this requires specifying SSR entry via
2100
+ * `rollupOptions.input`.
2101
+ * @default false
2102
+ */
2103
+ ssr?: boolean | string;
2104
+ /**
2105
+ * Generate SSR manifest for determining style links and asset preload
2106
+ * directives in production.
2107
+ * @default false
2108
+ */
2109
+ ssrManifest?: boolean | string;
2110
+ /**
2111
+ * Emit assets during SSR.
2112
+ * @default false
2113
+ */
2114
+ ssrEmitAssets?: boolean;
2115
+ /**
2116
+ * Set to false to disable reporting compressed chunk sizes.
2117
+ * Can slightly improve build speed.
2118
+ * @default true
2119
+ */
2120
+ reportCompressedSize?: boolean;
2121
+ /**
2122
+ * Adjust chunk size warning limit (in kB).
2123
+ * @default 500
2124
+ */
2125
+ chunkSizeWarningLimit?: number;
2126
+ /**
2127
+ * Rollup watch options
2128
+ * https://rollupjs.org/configuration-options/#watch
2129
+ * @default null
2130
+ */
2131
+ watch?: WatcherOptions | null;
2132
+ }
2133
+ interface LibraryOptions {
2134
+ /**
2135
+ * Path of library entry
2136
+ */
2137
+ entry: InputOption;
2138
+ /**
2139
+ * The name of the exposed global variable. Required when the `formats` option includes
2140
+ * `umd` or `iife`
2141
+ */
2142
+ name?: string;
2143
+ /**
2144
+ * Output bundle formats
2145
+ * @default ['es', 'umd']
2146
+ */
2147
+ formats?: LibraryFormats[];
2148
+ /**
2149
+ * The name of the package file output. The default file name is the name option
2150
+ * of the project package.json. It can also be defined as a function taking the
2151
+ * format as an argument.
2152
+ */
2153
+ fileName?: string | ((format: ModuleFormat, entryName: string) => string);
2154
+ }
2155
+ type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife' | 'system';
2156
+ interface ModulePreloadOptions {
2157
+ /**
2158
+ * Whether to inject a module preload polyfill.
2159
+ * Note: does not apply to library mode.
2160
+ * @default true
2161
+ */
2162
+ polyfill?: boolean;
2163
+ /**
2164
+ * Resolve the list of dependencies to preload for a given dynamic import
2165
+ * @experimental
2166
+ */
2167
+ resolveDependencies?: ResolveModulePreloadDependenciesFn;
2168
+ }
2169
+ interface ResolvedModulePreloadOptions {
2170
+ polyfill: boolean;
2171
+ resolveDependencies?: ResolveModulePreloadDependenciesFn;
2172
+ }
2173
+ type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: {
2174
+ hostId: string;
2175
+ hostType: 'html' | 'js';
2176
+ }) => string[];
2177
+ interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> {
2178
+ modulePreload: false | ResolvedModulePreloadOptions;
2179
+ }
2180
+ /**
2181
+ * Bundles the app for production.
2182
+ * Returns a Promise containing the build result.
2183
+ */
2184
+ type RenderBuiltAssetUrl = (filename: string, type: {
2185
+ type: 'asset' | 'public';
2186
+ hostId: string;
2187
+ hostType: 'js' | 'css' | 'html';
2188
+ ssr: boolean;
2189
+ }) => string | {
2190
+ relative?: boolean;
2191
+ runtime?: string;
2192
+ } | undefined;
2193
+ interface ESBuildOptions extends TransformOptions$1 {
2194
+ include?: string | RegExp | string[] | RegExp[];
2195
+ exclude?: string | RegExp | string[] | RegExp[];
2196
+ jsxInject?: string;
2197
+ /**
2198
+ * This option is not respected. Use `build.minify` instead.
2199
+ */
2200
+ minify?: never;
2201
+ }
2202
+ type ExportsData = {
2203
+ hasModuleSyntax: boolean;
2204
+ exports: readonly string[];
2205
+ jsxLoader?: boolean;
2206
+ };
2207
+ interface DepsOptimizer {
2208
+ metadata: DepOptimizationMetadata;
2209
+ scanProcessing?: Promise<void>;
2210
+ registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
2211
+ run: () => void;
2212
+ isOptimizedDepFile: (id: string) => boolean;
2213
+ isOptimizedDepUrl: (url: string) => boolean;
2214
+ getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
2215
+ close: () => Promise<void>;
2216
+ options: DepOptimizationOptions;
2217
+ }
2218
+ interface DepOptimizationConfig {
2219
+ /**
2220
+ * Force optimize listed dependencies (must be resolvable import paths,
2221
+ * cannot be globs).
2222
+ */
2223
+ include?: string[];
2224
+ /**
2225
+ * Do not optimize these dependencies (must be resolvable import paths,
2226
+ * cannot be globs).
2227
+ */
2228
+ exclude?: string[];
2229
+ /**
2230
+ * Forces ESM interop when importing these dependencies. Some legacy
2231
+ * packages advertise themselves as ESM but use `require` internally
2232
+ * @experimental
2233
+ */
2234
+ needsInterop?: string[];
2235
+ /**
2236
+ * Options to pass to esbuild during the dep scanning and optimization
2237
+ *
2238
+ * Certain options are omitted since changing them would not be compatible
2239
+ * with Vite's dep optimization.
2240
+ *
2241
+ * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
2242
+ * - `plugins` are merged with Vite's dep plugin
2243
+ *
2244
+ * https://esbuild.github.io/api
2245
+ */
2246
+ esbuildOptions?: Omit<BuildOptions$1, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
2247
+ /**
2248
+ * List of file extensions that can be optimized. A corresponding esbuild
2249
+ * plugin must exist to handle the specific extension.
2250
+ *
2251
+ * By default, Vite can optimize `.mjs`, `.js`, `.ts`, and `.mts` files. This option
2252
+ * allows specifying additional extensions.
2253
+ *
2254
+ * @experimental
2255
+ */
2256
+ extensions?: string[];
2257
+ /**
2258
+ * Deps optimization during build was removed in Vite 5.1. This option is
2259
+ * now redundant and will be removed in a future version. Switch to using
2260
+ * `optimizeDeps.noDiscovery` and an empty or undefined `optimizeDeps.include`.
2261
+ * true or 'dev' disables the optimizer, false or 'build' leaves it enabled.
2262
+ * @default 'build'
2263
+ * @deprecated
2264
+ * @experimental
2265
+ */
2266
+ disabled?: boolean | 'build' | 'dev';
2267
+ /**
2268
+ * Automatic dependency discovery. When `noDiscovery` is true, only dependencies
2269
+ * listed in `include` will be optimized. The scanner isn't run for cold start
2270
+ * in this case. CJS-only dependencies must be present in `include` during dev.
2271
+ * @default false
2272
+ * @experimental
2273
+ */
2274
+ noDiscovery?: boolean;
2275
+ /**
2276
+ * When enabled, it will hold the first optimized deps results until all static
2277
+ * imports are crawled on cold start. This avoids the need for full-page reloads
2278
+ * when new dependencies are discovered and they trigger the generation of new
2279
+ * common chunks. If all dependencies are found by the scanner plus the explicitly
2280
+ * defined ones in `include`, it is better to disable this option to let the
2281
+ * browser process more requests in parallel.
2282
+ * @default true
2283
+ * @experimental
2284
+ */
2285
+ holdUntilCrawlEnd?: boolean;
2286
+ }
2287
+ type DepOptimizationOptions = DepOptimizationConfig & {
2288
+ /**
2289
+ * By default, Vite will crawl your `index.html` to detect dependencies that
2290
+ * need to be pre-bundled. If `build.rollupOptions.input` is specified, Vite
2291
+ * will crawl those entry points instead.
2292
+ *
2293
+ * If neither of these fit your needs, you can specify custom entries using
2294
+ * this option - the value should be a fast-glob pattern or array of patterns
2295
+ * (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
2296
+ * vite project root. This will overwrite default entries inference.
2297
+ */
2298
+ entries?: string | string[];
2299
+ /**
2300
+ * Force dep pre-optimization regardless of whether deps have changed.
2301
+ * @experimental
2302
+ */
2303
+ force?: boolean;
2304
+ };
2305
+ interface OptimizedDepInfo {
2306
+ id: string;
2307
+ file: string;
2308
+ src?: string;
2309
+ needsInterop?: boolean;
2310
+ browserHash?: string;
2311
+ fileHash?: string;
2312
+ /**
2313
+ * During optimization, ids can still be resolved to their final location
2314
+ * but the bundles may not yet be saved to disk
2315
+ */
2316
+ processing?: Promise<void>;
2317
+ /**
2318
+ * ExportData cache, discovered deps will parse the src entry to get exports
2319
+ * data used both to define if interop is needed and when pre-bundling
2320
+ */
2321
+ exportsData?: Promise<ExportsData>;
2322
+ }
2323
+ interface DepOptimizationMetadata {
2324
+ /**
2325
+ * The main hash is determined by user config and dependency lockfiles.
2326
+ * This is checked on server startup to avoid unnecessary re-bundles.
2327
+ */
2328
+ hash: string;
2329
+ /**
2330
+ * This hash is determined by dependency lockfiles.
2331
+ * This is checked on server startup to avoid unnecessary re-bundles.
2332
+ */
2333
+ lockfileHash: string;
2334
+ /**
2335
+ * This hash is determined by user config.
2336
+ * This is checked on server startup to avoid unnecessary re-bundles.
2337
+ */
2338
+ configHash: string;
2339
+ /**
2340
+ * The browser hash is determined by the main hash plus additional dependencies
2341
+ * discovered at runtime. This is used to invalidate browser requests to
2342
+ * optimized deps.
2343
+ */
2344
+ browserHash: string;
2345
+ /**
2346
+ * Metadata for each already optimized dependency
2347
+ */
2348
+ optimized: Record<string, OptimizedDepInfo>;
2349
+ /**
2350
+ * Metadata for non-entry optimized chunks and dynamic imports
2351
+ */
2352
+ chunks: Record<string, OptimizedDepInfo>;
2353
+ /**
2354
+ * Metadata for each newly discovered dependency after processing
2355
+ */
2356
+ discovered: Record<string, OptimizedDepInfo>;
2357
+ /**
2358
+ * OptimizedDepInfo list
2359
+ */
2360
+ depInfoList: OptimizedDepInfo[];
2361
+ }
2362
+ /**
2363
+ * Scan and optimize dependencies within a project.
2364
+ * Used by Vite CLI when running `vite optimize`.
2365
+ */
2366
+ type SSRTarget = 'node' | 'webworker';
2367
+ type SsrDepOptimizationOptions = DepOptimizationConfig;
2368
+ interface SSROptions {
2369
+ noExternal?: string | RegExp | (string | RegExp)[] | true;
2370
+ external?: string[] | true;
2371
+ /**
2372
+ * Define the target for the ssr build. The browser field in package.json
2373
+ * is ignored for node but used if webworker is the target
2374
+ * @default 'node'
2375
+ */
2376
+ target?: SSRTarget;
2377
+ /**
2378
+ * Control over which dependencies are optimized during SSR and esbuild options
2379
+ * During build:
2380
+ * no external CJS dependencies are optimized by default
2381
+ * During dev:
2382
+ * explicit no external CJS dependencies are optimized by default
2383
+ * @experimental
2384
+ */
2385
+ optimizeDeps?: SsrDepOptimizationOptions;
2386
+ resolve?: {
2387
+ /**
2388
+ * Conditions that are used in the plugin pipeline. The default value is the root config's `resolve.conditions`.
2389
+ *
2390
+ * Use this to override the default ssr conditions for the ssr build.
2391
+ *
2392
+ * @default rootConfig.resolve.conditions
2393
+ */
2394
+ conditions?: string[];
2395
+ /**
2396
+ * Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies.
2397
+ *
2398
+ * @default []
2399
+ */
2400
+ externalConditions?: string[];
2401
+ };
2402
+ }
2403
+ interface ResolvedSSROptions extends SSROptions {
2404
+ target: SSRTarget;
2405
+ optimizeDeps: SsrDepOptimizationOptions;
2406
+ }
2407
+ interface FsUtils {
2408
+ existsSync: (path: string) => boolean;
2409
+ isDirectory: (path: string) => boolean;
2410
+ tryResolveRealFile: (path: string, preserveSymlinks?: boolean) => string | undefined;
2411
+ tryResolveRealFileWithExtensions: (path: string, extensions: string[], preserveSymlinks?: boolean) => string | undefined;
2412
+ tryResolveRealFileOrType: (path: string, preserveSymlinks?: boolean) => {
2413
+ path?: string;
2414
+ type: 'directory' | 'file';
2415
+ } | undefined;
2416
+ initWatcher?: (watcher: FSWatcher) => void;
2417
+ }
2418
+ interface ResolveOptions {
2419
+ /**
2420
+ * @default ['browser', 'module', 'jsnext:main', 'jsnext']
2421
+ */
2422
+ mainFields?: string[];
2423
+ conditions?: string[];
2424
+ /**
2425
+ * @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
2426
+ */
2427
+ extensions?: string[];
2428
+ dedupe?: string[];
2429
+ /**
2430
+ * @default false
2431
+ */
2432
+ preserveSymlinks?: boolean;
2433
+ }
2434
+ interface InternalResolveOptions extends Required<ResolveOptions> {
2435
+ root: string;
2436
+ isBuild: boolean;
2437
+ isProduction: boolean;
2438
+ ssrConfig?: SSROptions;
2439
+ packageCache?: PackageCache;
2440
+ fsUtils?: FsUtils;
2441
+ /**
2442
+ * src code mode also attempts the following:
2443
+ * - resolving /xxx as URLs
2444
+ * - resolving bare imports from optimized deps
2445
+ */
2446
+ asSrc?: boolean;
2447
+ tryIndex?: boolean;
2448
+ tryPrefix?: string;
2449
+ preferRelative?: boolean;
2450
+ isRequire?: boolean;
2451
+ isFromTsImporter?: boolean;
2452
+ tryEsmOnly?: boolean;
2453
+ scan?: boolean;
2454
+ ssrOptimizeCheck?: boolean;
2455
+ getDepsOptimizer?: (ssr: boolean) => DepsOptimizer | undefined;
2456
+ shouldExternalize?: (id: string, importer?: string) => boolean | undefined;
2457
+ } // This file is autogenerated by build-prefixes.js. DO NOT EDIT!
2458
+ interface Targets {
2459
+ android?: number;
2460
+ chrome?: number;
2461
+ edge?: number;
2462
+ firefox?: number;
2463
+ ie?: number;
2464
+ ios_saf?: number;
2465
+ opera?: number;
2466
+ safari?: number;
2467
+ samsung?: number;
2468
+ }
2469
+ interface Drafts {
2470
+ /** Whether to enable @custom-media rules. */
2471
+ customMedia?: boolean;
2472
+ }
2473
+ interface NonStandard {
2474
+ /** Whether to enable the non-standard >>> and /deep/ selector combinators used by Angular and Vue. */
2475
+ deepSelectorCombinator?: boolean;
2476
+ }
2477
+ interface PseudoClasses {
2478
+ hover?: string;
2479
+ active?: string;
2480
+ focus?: string;
2481
+ focusVisible?: string;
2482
+ focusWithin?: string;
2483
+ }
2484
+ interface CSSModulesConfig {
2485
+ /** The pattern to use when renaming class names and other identifiers. Default is `[hash]_[local]`. */
2486
+ pattern?: string;
2487
+ /** Whether to rename dashed identifiers, e.g. custom properties. */
2488
+ dashedIdents?: boolean;
2489
+ }
2490
+ /**
2491
+ * Options are spread, so you can also use options that are not typed here like
2492
+ * visitor (not exposed because it would impact too much the bundle size)
2493
+ */
2494
+ type LightningCSSOptions = {
2495
+ targets?: Targets;
2496
+ include?: number;
2497
+ exclude?: number;
2498
+ drafts?: Drafts;
2499
+ nonStandard?: NonStandard;
2500
+ pseudoClasses?: PseudoClasses;
2501
+ unusedSymbols?: string[];
2502
+ cssModules?: CSSModulesConfig;
2503
+ errorRecovery?: boolean;
2504
+ };
2505
+ interface CSSOptions {
2506
+ /**
2507
+ * Using lightningcss is an experimental option to handle CSS modules,
2508
+ * assets and imports via Lightning CSS. It requires to install it as a
2509
+ * peer dependency. This is incompatible with the use of preprocessors.
2510
+ *
2511
+ * @default 'postcss'
2512
+ * @experimental
2513
+ */
2514
+ transformer?: 'postcss' | 'lightningcss';
2515
+ /**
2516
+ * https://github.com/css-modules/postcss-modules
2517
+ */
2518
+ modules?: CSSModulesOptions | false;
2519
+ /**
2520
+ * Options for preprocessors.
2521
+ *
2522
+ * In addition to options specific to each processors, Vite supports `additionalData` option.
2523
+ * The `additionalData` option can be used to inject extra code for each style content.
2524
+ */
2525
+ preprocessorOptions?: Record<string, any>;
2526
+ /**
2527
+ * If this option is set, preprocessors will run in workers when possible.
2528
+ * `true` means the number of CPUs minus 1.
2529
+ *
2530
+ * @default 0
2531
+ * @experimental
2532
+ */
2533
+ preprocessorMaxWorkers?: number | true;
2534
+ postcss?: string | (undefined & {
2535
+ plugins?: undefined[];
2536
+ });
2537
+ /**
2538
+ * Enables css sourcemaps during dev
2539
+ * @default false
2540
+ * @experimental
2541
+ */
2542
+ devSourcemap?: boolean;
2543
+ /**
2544
+ * @experimental
2545
+ */
2546
+ lightningcss?: LightningCSSOptions;
2547
+ }
2548
+ interface CSSModulesOptions {
2549
+ getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
2550
+ scopeBehaviour?: 'global' | 'local';
2551
+ globalModulePaths?: RegExp[];
2552
+ exportGlobals?: boolean;
2553
+ generateScopedName?: string | ((name: string, filename: string, css: string) => string);
2554
+ hashPrefix?: string;
2555
+ /**
2556
+ * default: undefined
2557
+ */
2558
+ localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | ((originalClassName: string, generatedClassName: string, inputFile: string) => string);
2559
+ }
2560
+ type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & {
2561
+ lightningcss?: LightningCSSOptions & {
2562
+ targets: LightningCSSOptions['targets'];
2563
+ };
2564
+ };
2565
+ interface HtmlTagDescriptor {
2566
+ tag: string;
2567
+ attrs?: Record<string, string | boolean | undefined>;
2568
+ children?: string | HtmlTagDescriptor[];
2569
+ /**
2570
+ * default: 'head-prepend'
2571
+ */
2572
+ injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
2573
+ }
2574
+ type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | {
2575
+ html: string;
2576
+ tags: HtmlTagDescriptor[];
2577
+ };
2578
+ interface IndexHtmlTransformContext {
2579
+ /**
2580
+ * public path when served
2581
+ */
2582
+ path: string;
2583
+ /**
2584
+ * filename on disk
2585
+ */
2586
+ filename: string;
2587
+ server?: ViteDevServer;
2588
+ bundle?: OutputBundle;
2589
+ chunk?: OutputChunk;
2590
+ originalUrl?: string;
2591
+ }
2592
+ type IndexHtmlTransformHook = (this: void, html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>;
2593
+ type IndexHtmlTransform = IndexHtmlTransformHook | {
2594
+ order?: 'pre' | 'post' | null;
2595
+ /**
2596
+ * @deprecated renamed to `order`
2597
+ */
2598
+ enforce?: 'pre' | 'post';
2599
+ /**
2600
+ * @deprecated renamed to `handler`
2601
+ */
2602
+ transform: IndexHtmlTransformHook;
2603
+ } | {
2604
+ order?: 'pre' | 'post' | null;
2605
+ /**
2606
+ * @deprecated renamed to `order`
2607
+ */
2608
+ enforce?: 'pre' | 'post';
2609
+ handler: IndexHtmlTransformHook;
2610
+ };
2611
+ /**
2612
+ * Vite plugins extends the Rollup plugin interface with a few extra
2613
+ * vite-specific options. A valid vite plugin is also a valid Rollup plugin.
2614
+ * On the contrary, a Rollup plugin may or may NOT be a valid vite universal
2615
+ * plugin, since some Rollup features do not make sense in an unbundled
2616
+ * dev server context. That said, as long as a rollup plugin doesn't have strong
2617
+ * coupling between its bundle phase and output phase hooks then it should
2618
+ * just work (that means, most of them).
2619
+ *
2620
+ * By default, the plugins are run during both serve and build. When a plugin
2621
+ * is applied during serve, it will only run **non output plugin hooks** (see
2622
+ * rollup type definition of {@link rollup#PluginHooks}). You can think of the
2623
+ * dev server as only running `const bundle = rollup.rollup()` but never calling
2624
+ * `bundle.generate()`.
2625
+ *
2626
+ * A plugin that expects to have different behavior depending on serve/build can
2627
+ * export a factory function that receives the command being run via options.
2628
+ *
2629
+ * If a plugin should be applied only for server or build, a function format
2630
+ * config file can be used to conditional determine the plugins to use.
2631
+ */
2632
+ interface Plugin<A = any> extends Plugin$1<A> {
2633
+ /**
2634
+ * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
2635
+ * is still subject to the `order` property in the hook object.
2636
+ *
2637
+ * Plugin invocation order:
2638
+ * - alias resolution
2639
+ * - `enforce: 'pre'` plugins
2640
+ * - vite core plugins
2641
+ * - normal plugins
2642
+ * - vite build plugins
2643
+ * - `enforce: 'post'` plugins
2644
+ * - vite build post plugins
2645
+ */
2646
+ enforce?: 'pre' | 'post';
2647
+ /**
2648
+ * Apply the plugin only for serve or build, or on certain conditions.
2649
+ */
2650
+ apply?: 'serve' | 'build' | ((this: void, config: UserConfig, env: ConfigEnv) => boolean);
2651
+ /**
2652
+ * Modify vite config before it's resolved. The hook can either mutate the
2653
+ * passed-in config directly, or return a partial config object that will be
2654
+ * deeply merged into existing config.
2655
+ *
2656
+ * Note: User plugins are resolved before running this hook so injecting other
2657
+ * plugins inside the `config` hook will have no effect.
2658
+ */
2659
+ config?: ObjectHook<(this: void, config: UserConfig, env: ConfigEnv) => Omit<UserConfig, 'plugins'> | null | void | Promise<Omit<UserConfig, 'plugins'> | null | void>>;
2660
+ /**
2661
+ * Use this hook to read and store the final resolved vite config.
2662
+ */
2663
+ configResolved?: ObjectHook<(this: void, config: ResolvedConfig) => void | Promise<void>>;
2664
+ /**
2665
+ * Configure the vite server. The hook receives the {@link ViteDevServer}
2666
+ * instance. This can also be used to store a reference to the server
2667
+ * for use in other hooks.
2668
+ *
2669
+ * The hooks will be called before internal middlewares are applied. A hook
2670
+ * can return a post hook that will be called after internal middlewares
2671
+ * are applied. Hook can be async functions and will be called in series.
2672
+ */
2673
+ configureServer?: ObjectHook<ServerHook>;
2674
+ /**
2675
+ * Configure the preview server. The hook receives the {@link PreviewServer}
2676
+ * instance. This can also be used to store a reference to the server
2677
+ * for use in other hooks.
2678
+ *
2679
+ * The hooks are called before other middlewares are applied. A hook can
2680
+ * return a post hook that will be called after other middlewares are
2681
+ * applied. Hooks can be async functions and will be called in series.
2682
+ */
2683
+ configurePreviewServer?: ObjectHook<PreviewServerHook>;
2684
+ /**
2685
+ * Transform index.html.
2686
+ * The hook receives the following arguments:
2687
+ *
2688
+ * - html: string
2689
+ * - ctx?: vite.ServerContext (only present during serve)
2690
+ * - bundle?: rollup.OutputBundle (only present during build)
2691
+ *
2692
+ * It can either return a transformed string, or a list of html tag
2693
+ * descriptors that will be injected into the `<head>` or `<body>`.
2694
+ *
2695
+ * By default the transform is applied **after** vite's internal html
2696
+ * transform. If you need to apply the transform before vite, use an object:
2697
+ * `{ order: 'pre', handler: hook }`
2698
+ */
2699
+ transformIndexHtml?: IndexHtmlTransform;
2700
+ /**
2701
+ * Perform custom handling of HMR updates.
2702
+ * The handler receives a context containing changed filename, timestamp, a
2703
+ * list of modules affected by the file change, and the dev server instance.
2704
+ *
2705
+ * - The hook can return a filtered list of modules to narrow down the update.
2706
+ * e.g. for a Vue SFC, we can narrow down the part to update by comparing
2707
+ * the descriptors.
2708
+ *
2709
+ * - The hook can also return an empty array and then perform custom updates
2710
+ * by sending a custom hmr payload via server.ws.send().
2711
+ *
2712
+ * - If the hook doesn't return a value, the hmr update will be performed as
2713
+ * normal.
2714
+ */
2715
+ handleHotUpdate?: ObjectHook<(this: void, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
2716
+ /**
2717
+ * extend hooks with ssr flag
2718
+ */
2719
+ resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
2720
+ attributes: Record<string, string>;
2721
+ custom?: CustomPluginOptions;
2722
+ ssr?: boolean;
2723
+ isEntry: boolean;
2724
+ }) => Promise<ResolveIdResult> | ResolveIdResult>;
2725
+ load?: ObjectHook<(this: PluginContext, id: string, options?: {
2726
+ ssr?: boolean;
2727
+ }) => Promise<LoadResult> | LoadResult>;
2728
+ transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
2729
+ ssr?: boolean;
2730
+ }) => Promise<TransformResult$1> | TransformResult$1>;
2731
+ }
2732
+ type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
2733
+ type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & { [P in K]: NonNullable<Plugin[P]> };
2734
+ interface JsonOptions {
2735
+ /**
2736
+ * Generate a named export for every property of the JSON object
2737
+ * @default true
2738
+ */
2739
+ namedExports?: boolean;
2740
+ /**
2741
+ * Generate performant output as JSON.parse("stringified").
2742
+ * Enabling this will disable namedExports.
2743
+ * @default false
2744
+ */
2745
+ stringify?: boolean;
2746
+ }
2747
+ interface ConfigEnv {
2748
+ /**
2749
+ * 'serve': during dev (`vite` command)
2750
+ * 'build': when building for production (`vite build` command)
2751
+ */
2752
+ command: 'build' | 'serve';
2753
+ mode: string;
2754
+ isSsrBuild?: boolean;
2755
+ isPreview?: boolean;
2756
+ }
2757
+ /**
2758
+ * spa: include SPA fallback middleware and configure sirv with `single: true` in preview
2759
+ *
2760
+ * mpa: only include non-SPA HTML middlewares
2761
+ *
2762
+ * custom: don't include HTML middlewares
2763
+ */
2764
+ type AppType = 'spa' | 'mpa' | 'custom';
2765
+ type PluginOption = Plugin | false | null | undefined | PluginOption[] | Promise<Plugin | false | null | undefined | PluginOption[]>;
2766
+ interface UserConfig {
2767
+ /**
2768
+ * Project root directory. Can be an absolute path, or a path relative from
2769
+ * the location of the config file itself.
2770
+ * @default process.cwd()
2771
+ */
2772
+ root?: string;
2773
+ /**
2774
+ * Base public path when served in development or production.
2775
+ * @default '/'
2776
+ */
2777
+ base?: string;
2778
+ /**
2779
+ * Directory to serve as plain static assets. Files in this directory are
2780
+ * served and copied to build dist dir as-is without transform. The value
2781
+ * can be either an absolute file system path or a path relative to project root.
2782
+ *
2783
+ * Set to `false` or an empty string to disable copied static assets to build dist dir.
2784
+ * @default 'public'
2785
+ */
2786
+ publicDir?: string | false;
2787
+ /**
2788
+ * Directory to save cache files. Files in this directory are pre-bundled
2789
+ * deps or some other cache files that generated by vite, which can improve
2790
+ * the performance. You can use `--force` flag or manually delete the directory
2791
+ * to regenerate the cache files. The value can be either an absolute file
2792
+ * system path or a path relative to project root.
2793
+ * Default to `.vite` when no `package.json` is detected.
2794
+ * @default 'node_modules/.vite'
2795
+ */
2796
+ cacheDir?: string;
2797
+ /**
2798
+ * Explicitly set a mode to run in. This will override the default mode for
2799
+ * each command, and can be overridden by the command line --mode option.
2800
+ */
2801
+ mode?: string;
2802
+ /**
2803
+ * Define global variable replacements.
2804
+ * Entries will be defined on `window` during dev and replaced during build.
2805
+ */
2806
+ define?: Record<string, any>;
2807
+ /**
2808
+ * Array of vite plugins to use.
2809
+ */
2810
+ plugins?: PluginOption[];
2811
+ /**
2812
+ * Configure resolver
2813
+ */
2814
+ resolve?: ResolveOptions & {
2815
+ alias?: AliasOptions;
2816
+ };
2817
+ /**
2818
+ * HTML related options
2819
+ */
2820
+ html?: HTMLOptions;
2821
+ /**
2822
+ * CSS related options (preprocessors and CSS modules)
2823
+ */
2824
+ css?: CSSOptions;
2825
+ /**
2826
+ * JSON loading options
2827
+ */
2828
+ json?: JsonOptions;
2829
+ /**
2830
+ * Transform options to pass to esbuild.
2831
+ * Or set to `false` to disable esbuild.
2832
+ */
2833
+ esbuild?: ESBuildOptions | false;
2834
+ /**
2835
+ * Specify additional picomatch patterns to be treated as static assets.
2836
+ */
2837
+ assetsInclude?: string | RegExp | (string | RegExp)[];
2838
+ /**
2839
+ * Server specific options, e.g. host, port, https...
2840
+ */
2841
+ server?: ServerOptions$1;
2842
+ /**
2843
+ * Build specific options
2844
+ */
2845
+ build?: BuildOptions;
2846
+ /**
2847
+ * Preview specific options, e.g. host, port, https...
2848
+ */
2849
+ preview?: PreviewOptions;
2850
+ /**
2851
+ * Dep optimization options
2852
+ */
2853
+ optimizeDeps?: DepOptimizationOptions;
2854
+ /**
2855
+ * SSR specific options
2856
+ */
2857
+ ssr?: SSROptions;
2858
+ /**
2859
+ * Experimental features
2860
+ *
2861
+ * Features under this field could change in the future and might NOT follow semver.
2862
+ * Please be careful and always pin Vite's version when using them.
2863
+ * @experimental
2864
+ */
2865
+ experimental?: ExperimentalOptions;
2866
+ /**
2867
+ * Legacy options
2868
+ *
2869
+ * Features under this field only follow semver for patches, they could be removed in a
2870
+ * future minor version. Please always pin Vite's version to a minor when using them.
2871
+ */
2872
+ legacy?: LegacyOptions;
2873
+ /**
2874
+ * Log level.
2875
+ * @default 'info'
2876
+ */
2877
+ logLevel?: LogLevel;
2878
+ /**
2879
+ * Custom logger.
2880
+ */
2881
+ customLogger?: Logger;
2882
+ /**
2883
+ * @default true
2884
+ */
2885
+ clearScreen?: boolean;
2886
+ /**
2887
+ * Environment files directory. Can be an absolute path, or a path relative from
2888
+ * root.
2889
+ * @default root
2890
+ */
2891
+ envDir?: string;
2892
+ /**
2893
+ * Env variables starts with `envPrefix` will be exposed to your client source code via import.meta.env.
2894
+ * @default 'VITE_'
2895
+ */
2896
+ envPrefix?: string | string[];
2897
+ /**
2898
+ * Worker bundle options
2899
+ */
2900
+ worker?: {
2901
+ /**
2902
+ * Output format for worker bundle
2903
+ * @default 'iife'
2904
+ */
2905
+ format?: 'es' | 'iife';
2906
+ /**
2907
+ * Vite plugins that apply to worker bundle. The plugins returned by this function
2908
+ * should be new instances every time it is called, because they are used for each
2909
+ * rollup worker bundling process.
2910
+ */
2911
+ plugins?: () => PluginOption[];
2912
+ /**
2913
+ * Rollup options to build worker bundle
2914
+ */
2915
+ rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>;
2916
+ };
2917
+ /**
2918
+ * Whether your application is a Single Page Application (SPA),
2919
+ * a Multi-Page Application (MPA), or Custom Application (SSR
2920
+ * and frameworks with custom HTML handling)
2921
+ * @default 'spa'
2922
+ */
2923
+ appType?: AppType;
2924
+ }
2925
+ interface HTMLOptions {
2926
+ /**
2927
+ * A nonce value placeholder that will be used when generating script/style tags.
2928
+ *
2929
+ * Make sure that this placeholder will be replaced with a unique value for each request by the server.
2930
+ */
2931
+ cspNonce?: string;
2932
+ }
2933
+ interface ExperimentalOptions {
2934
+ /**
2935
+ * Append fake `&lang.(ext)` when queries are specified, to preserve the file extension for following plugins to process.
2936
+ *
2937
+ * @experimental
2938
+ * @default false
2939
+ */
2940
+ importGlobRestoreExtension?: boolean;
2941
+ /**
2942
+ * Allow finegrain control over assets and public files paths
2943
+ *
2944
+ * @experimental
2945
+ */
2946
+ renderBuiltUrl?: RenderBuiltAssetUrl;
2947
+ /**
2948
+ * Enables support of HMR partial accept via `import.meta.hot.acceptExports`.
2949
+ *
2950
+ * @experimental
2951
+ * @default false
2952
+ */
2953
+ hmrPartialAccept?: boolean;
2954
+ /**
2955
+ * Skips SSR transform to make it easier to use Vite with Node ESM loaders.
2956
+ * @warning Enabling this will break normal operation of Vite's SSR in development mode.
2957
+ *
2958
+ * @experimental
2959
+ * @default false
2960
+ */
2961
+ skipSsrTransform?: boolean;
2962
+ }
2963
+ interface LegacyOptions {
2964
+ /**
2965
+ * In Vite 4, SSR-externalized modules (modules not bundled and loaded by Node.js at runtime)
2966
+ * are implicitly proxied in dev to automatically handle `default` and `__esModule` access.
2967
+ * However, this does not correctly reflect how it works in the Node.js runtime, causing
2968
+ * inconsistencies between dev and prod.
2969
+ *
2970
+ * In Vite 5, the proxy is removed so dev and prod are consistent, but if you still require
2971
+ * the old behaviour, you can enable this option. If so, please leave your feedback at
2972
+ * https://github.com/vitejs/vite/discussions/14697.
2973
+ */
2974
+ proxySsrExternalModules?: boolean;
2975
+ /**
2976
+ * In Vite 6.0.8 / 5.4.11 and below, WebSocket server was able to connect from any web pages. However,
2977
+ * that could be exploited by a malicious web page.
2978
+ *
2979
+ * In Vite 6.0.9+ / 5.4.12+, the WebSocket server now requires a token to connect from a web page.
2980
+ * But this may break some plugins and frameworks that connects to the WebSocket server
2981
+ * on their own. Enabling this option will make Vite skip the token check.
2982
+ *
2983
+ * **We do not recommend enabling this option unless you are sure that you are fine with
2984
+ * that security weakness.**
2985
+ */
2986
+ skipWebSocketTokenCheck?: boolean;
2987
+ }
2988
+ interface ResolvedWorkerOptions {
2989
+ format: 'es' | 'iife';
2990
+ plugins: (bundleChain: string[]) => Promise<Plugin[]>;
2991
+ rollupOptions: RollupOptions;
2992
+ }
2993
+ interface InlineConfig extends UserConfig {
2994
+ configFile?: string | false;
2995
+ envFile?: false;
2996
+ }
2997
+ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build'> & {
2998
+ configFile: string | undefined;
2999
+ configFileDependencies: string[];
3000
+ inlineConfig: InlineConfig;
3001
+ root: string;
3002
+ base: string;
3003
+ publicDir: string;
3004
+ cacheDir: string;
3005
+ command: 'build' | 'serve';
3006
+ mode: string;
3007
+ isWorker: boolean;
3008
+ isProduction: boolean;
3009
+ envDir: string;
3010
+ env: Record<string, any>;
3011
+ resolve: Required<ResolveOptions> & {
3012
+ alias: Alias[];
3013
+ };
3014
+ plugins: readonly Plugin[];
3015
+ css: ResolvedCSSOptions;
3016
+ esbuild: ESBuildOptions | false;
3017
+ server: ResolvedServerOptions;
3018
+ build: ResolvedBuildOptions;
3019
+ preview: ResolvedPreviewOptions;
3020
+ ssr: ResolvedSSROptions;
3021
+ assetsInclude: (file: string) => boolean;
3022
+ logger: Logger;
3023
+ createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
3024
+ optimizeDeps: DepOptimizationOptions;
3025
+ worker: ResolvedWorkerOptions;
3026
+ appType: AppType;
3027
+ experimental: ExperimentalOptions;
3028
+ /**
3029
+ * The token to connect to the WebSocket server from browsers.
3030
+ *
3031
+ * We recommend using `import.meta.hot` rather than connecting
3032
+ * to the WebSocket server directly.
3033
+ * If you have a usecase that requires connecting to the WebSocket
3034
+ * server, please create an issue so that we can discuss.
3035
+ *
3036
+ * @deprecated
3037
+ */
3038
+ webSocketToken: string;
3039
+ } & PluginHookUtils>;
3040
+ interface PluginHookUtils {
3041
+ getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[];
3042
+ getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[];
3043
+ }
3044
+ type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
3045
+ //#endregion
4
3046
  //#region src/vite.d.ts
5
- declare const _default: (options: Options) => vite0.Plugin<any> | vite0.Plugin<any>[];
3047
+ declare const _default: (options: Options) => Plugin<any> | Plugin<any>[];
6
3048
  //#endregion
7
3049
  export { _default as default };