@depup/vite 8.2.2-depup.0 → 8.3.1-depup.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.
@@ -1,88 +1,37 @@
1
1
  /// <reference types="node" />
2
2
  import { t as ModuleRunnerTransport } from "./chunks/moduleRunnerTransport.js";
3
- import { ConnectedPayload, CustomPayload, CustomPayload as hmrPayload_CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, HotPayload, HotPayload as hmrPayload_HotPayload, PrunePayload, Update, UpdatePayload } from "#types/hmrPayload";
4
3
  import { CustomEventMap, InferCustomEventPayload, InferCustomEventPayload as hmrPayload_InferCustomEventPayload, InvalidatePayload } from "#types/customEvent";
4
+ import { ConnectedPayload, CustomPayload, CustomPayload as hmrPayload_CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, HotPayload, HotPayload as hmrPayload_HotPayload, PrunePayload, Update, UpdatePayload } from "#types/hmrPayload";
5
5
  import * as Rolldown from "rolldown";
6
6
  import { CustomPluginOptions, ExistingRawSourceMap, FunctionPluginHooks, ImportKind, InputOption, InputOptions, LoadResult, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleType, ModuleTypeFilter, ObjectHook, OutputBundle, OutputChunk, OutputOptions, PartialResolvedId, PluginContext, PluginContextMeta, ResolveIdResult, RolldownOptions, RolldownOutput, RolldownWatcher, RollupError, RollupLog, SourceDescription, SourceMap, SourceMapInput, TransformPluginContext, VERSION as rolldownVersion, WatcherOptions } from "rolldown";
7
7
  import { parseAst as parseAst$1, parseAstAsync as parseAstAsync$1 } from "rolldown/parseAst";
8
8
  import * as Rollup from "#types/internal/rollupTypeCompat";
9
9
  import { esmExternalRequirePlugin } from "rolldown/plugins";
10
10
  import { ESTree, MinifyOptions, MinifyResult, ParseResult, ParserOptions, TransformOptions as rolldown_utils_TransformOptions, TransformResult as rolldown_utils_TransformResult, Visitor, VisitorObject, minify, minifySync, parse, parseSync } from "rolldown/utils";
11
+ import { DevToolsConfig, ResolvedDevToolsConfig } from "#types/internal/devtoolsOptions";
12
+ import { DepsOptimizerEsbuildOptions, EsbuildTarget, EsbuildTransformOptions, EsbuildTransformOptions as esbuildOptions_EsbuildTransformOptions, EsbuildTransformResult } from "#types/internal/esbuildOptions";
13
+ import { ChunkMetadata, CustomPluginOptionsVite } from "#types/metadata";
11
14
  import * as http from "node:http";
12
15
  import { Agent, ClientRequest, ClientRequestArgs, OutgoingHttpHeaders, ServerResponse } from "node:http";
13
16
  import { Http2SecureServer } from "node:http2";
14
- import * as fs from "node:fs";
15
17
  import { EventEmitter } from "node:events";
18
+ import * as fs from "node:fs";
16
19
  import { Server as HttpsServer, ServerOptions as HttpsServerOptions } from "node:https";
17
20
  import * as net from "node:net";
18
21
  import { Duplex, DuplexOptions, Stream } from "node:stream";
19
22
  import { FetchFunction, FetchFunctionOptions, FetchResult, FetchResult as moduleRunner_FetchResult, ModuleEvaluator, ModuleRunner, ModuleRunnerHmr, ModuleRunnerOptions } from "vite/module-runner";
20
- import { DepsOptimizerEsbuildOptions, EsbuildTarget, EsbuildTransformOptions, EsbuildTransformOptions as esbuildOptions_EsbuildTransformOptions, EsbuildTransformResult } from "#types/internal/esbuildOptions";
21
23
  import { SecureContextOptions } from "node:tls";
22
24
  import { URL as url_URL } from "node:url";
23
25
  import { ZlibOptions } from "node:zlib";
24
- import { ChunkMetadata, CustomPluginOptionsVite } from "#types/metadata";
26
+ import { DevWatchOptions } from "rolldown/experimental";
25
27
  import { Terser, TerserMinifyOptions } from "#types/internal/terserOptions";
26
28
  import * as PostCSS from "postcss";
27
29
  import { ProcessOptions, Processor, Transformer } from "postcss";
28
- import { LightningCSSOptions, LightningCSSOptions as lightningcssOptions_LightningCSSOptions } from "#types/internal/lightningcssOptions";
29
30
  import { LessPreprocessorBaseOptions, SassModernPreprocessBaseOptions, StylusPreprocessorBaseOptions } from "#types/internal/cssPreprocessorOptions";
31
+ import { LightningCSSOptions, LightningCSSOptions as lightningcssOptions_LightningCSSOptions } from "#types/internal/lightningcssOptions";
30
32
  import { withFilter } from "rolldown/filter";
31
33
  import { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownAsTypeMap, KnownQueryTypeMap } from "#types/importGlob";
32
34
  //#endregion
33
- //#region ../../node_modules/.pnpm/@vitejs+devtools@0.4.12_crossws@0.4.10_srvx@0.12.5_typescript@6.0.3_vite@packages+vite/node_modules/@vitejs/devtools/dist/cli-commands.d.ts
34
- //#region src/node/cli-commands.d.ts
35
- interface StartOptions {
36
- root?: string;
37
- config?: string;
38
- host: string;
39
- port?: string | number;
40
- open?: boolean;
41
- }
42
- //#endregion
43
- //#region ../../node_modules/.pnpm/@vitejs+devtools@0.4.12_crossws@0.4.10_srvx@0.12.5_typescript@6.0.3_vite@packages+vite/node_modules/@vitejs/devtools/dist/config.d.ts
44
- //#region src/node/config.d.ts
45
- interface DevToolsConfig extends Partial<StartOptions> {
46
- enabled: boolean;
47
- /**
48
- * Vite environments to enable DevTools for. Defaults to all environments.
49
- */
50
- environments?: string[];
51
- /**
52
- * Disable client authentication.
53
- *
54
- * Beware that if you disable client authentication,
55
- * any browsers can connect to the devtools and access to your server and filesystem.
56
- * (including other devices, if you open server `host` option to LAN or WAN)
57
- *
58
- * @default true
59
- */
60
- clientAuth?: boolean;
61
- /**
62
- * Pre-configured auth tokens that are automatically trusted.
63
- *
64
- * Clients connecting with an auth token matching one of these
65
- * will be auto-approved without a terminal prompt.
66
- */
67
- clientAuthTokens?: string[];
68
- /**
69
- * Origins allowed to open the DevTools WebSocket connection, in addition to the built-in
70
- * loopback allowlist (`localhost`, `127.0.0.1`, etc).
71
- *
72
- * The loopback check is a plain string match against the `Origin` header, not a DNS/hosts-file
73
- * resolution — a custom dev hostname that resolves to loopback via `/etc/hosts` or a local DNS
74
- * override (e.g. `dev-my-app.example.com`) is invisible to it and gets rejected. List such
75
- * hostnames here explicitly.
76
- */
77
- allowedOrigins?: string[];
78
- }
79
- interface ResolvedDevToolsConfig {
80
- config: Omit<DevToolsConfig, 'enabled'> & {
81
- host: string;
82
- };
83
- enabled: boolean;
84
- }
85
- //#endregion
86
35
  //#region src/types/alias.d.ts
87
36
  interface Alias {
88
37
  find: string | RegExp;
@@ -114,124 +63,385 @@ type AliasOptions = readonly Alias[] | {
114
63
  [find: string]: string;
115
64
  };
116
65
  //#endregion
117
- //#region src/types/anymatch.d.ts
118
- type AnymatchFn = (testString: string) => boolean;
119
- type AnymatchPattern = string | RegExp | AnymatchFn;
120
- type AnymatchMatcher = AnymatchPattern | AnymatchPattern[];
121
- //#endregion
122
- //#region src/types/chokidar.d.ts
123
- declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
124
- options: WatchOptions;
125
- /**
126
- * Constructs a new FSWatcher instance with optional WatchOptions parameter.
127
- */
128
- constructor(options?: WatchOptions);
129
- /**
130
- * When called, requests that the Node.js event loop not exit so long as the fs.FSWatcher is active.
131
- * Calling watcher.ref() multiple times will have no effect.
132
- */
133
- ref(): this;
66
+ //#region src/node/assetSource.d.ts
67
+ /**
68
+ * Defines which attributes of an HTML element should be treated as asset sources.
69
+ * Used in `html.additionalAssetSources` configuration.
70
+ */
71
+ interface HtmlAssetSource {
134
72
  /**
135
- * When called, the active fs.FSWatcher object will not require the Node.js event loop to remain active.
136
- * If there is no other activity keeping the event loop running, the process may exit before the fs.FSWatcher object's callback is invoked.
137
- * Calling watcher.unref() multiple times will have no effect.
73
+ * Attributes that contain a single asset URL.
74
+ * @example ['src', 'data-src-dark']
138
75
  */
139
- unref(): this;
76
+ srcAttributes?: string[];
140
77
  /**
141
- * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
142
- * string.
78
+ * Attributes that contain srcset-format URLs.
79
+ * @example ['srcset', 'imagesrcset']
143
80
  */
144
- add(paths: string | ReadonlyArray<string>): this;
81
+ srcsetAttributes?: string[];
145
82
  /**
146
- * Stop watching files, directories, or glob patterns. Takes an array of strings or just one
147
- * string.
83
+ * Called before handling an attribute to determine if it should be processed.
148
84
  */
149
- unwatch(paths: string | ReadonlyArray<string>): this;
85
+ filter?: (data: HtmlAssetSourceFilterData) => boolean;
86
+ }
87
+ interface HtmlAssetSourceFilterData {
88
+ key: string;
89
+ value: string;
90
+ attributes: Record<string, string>;
91
+ }
92
+ //#endregion
93
+ //#region src/types/commonjs.d.ts
94
+
95
+ interface RollupCommonJSOptions {
150
96
  /**
151
- * Returns an object representing all the paths on the file system being watched by this
152
- * `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
153
- * the `cwd` option was used), and the values are arrays of the names of the items contained in
154
- * each directory.
97
+ * A minimatch pattern, or array of patterns, which specifies the files in
98
+ * the build the plugin should operate on. By default, all files with
99
+ * extension `".cjs"` or those in `extensions` are included, but you can
100
+ * narrow this list by only including specific files. These files will be
101
+ * analyzed and transpiled if either the analysis does not find ES module
102
+ * specific statements or `transformMixedEsModules` is `true`.
103
+ * @default undefined
155
104
  */
156
- getWatched(): {
157
- [directory: string]: string[];
158
- };
105
+ include?: string | RegExp | readonly (string | RegExp)[];
159
106
  /**
160
- * Removes all listeners from watched files.
107
+ * A minimatch pattern, or array of patterns, which specifies the files in
108
+ * the build the plugin should _ignore_. By default, all files with
109
+ * extensions other than those in `extensions` or `".cjs"` are ignored, but you
110
+ * can exclude additional files. See also the `include` option.
111
+ * @default undefined
161
112
  */
162
- close(): Promise<void>;
163
- on(event: 'add' | 'addDir' | 'change', listener: (path: string, stats?: fs.Stats) => void): this;
164
- on(event: 'all', listener: (eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', path: string, stats?: fs.Stats) => void): this;
113
+ exclude?: string | RegExp | readonly (string | RegExp)[];
165
114
  /**
166
- * Error occurred
115
+ * For extensionless imports, search for extensions other than .js in the
116
+ * order specified. Note that you need to make sure that non-JavaScript files
117
+ * are transpiled by another plugin first.
118
+ * @default [ '.js' ]
167
119
  */
168
- on(event: 'error', listener: (error: Error) => void): this;
120
+ extensions?: ReadonlyArray<string>;
169
121
  /**
170
- * Exposes the native Node `fs.FSWatcher events`
122
+ * If true then uses of `global` won't be dealt with by this plugin
123
+ * @default false
171
124
  */
172
- on(event: 'raw', listener: (eventName: string, path: string, details: any) => void): this;
125
+ ignoreGlobal?: boolean;
173
126
  /**
174
- * Fires when the initial scan is complete
127
+ * If false, skips source map generation for CommonJS modules. This will
128
+ * improve performance.
129
+ * @default true
175
130
  */
176
- on(event: 'ready', listener: () => void): this;
177
- on(event: 'unlink' | 'unlinkDir', listener: (path: string) => void): this;
178
- on(event: string, listener: (...args: any[]) => void): this;
179
- }
180
- interface WatchOptions {
131
+ sourceMap?: boolean;
181
132
  /**
182
- * Indicates whether the process should continue to run as long as files are being watched. If
183
- * set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`,
184
- * even if the process continues to run.
133
+ * Some `require` calls cannot be resolved statically to be translated to
134
+ * imports.
135
+ * When this option is set to `false`, the generated code will either
136
+ * directly throw an error when such a call is encountered or, when
137
+ * `dynamicRequireTargets` is used, when such a call cannot be resolved with a
138
+ * configured dynamic require target.
139
+ * Setting this option to `true` will instead leave the `require` call in the
140
+ * code or use it as a fallback for `dynamicRequireTargets`.
141
+ * @default false
185
142
  */
186
- persistent?: boolean;
143
+ ignoreDynamicRequires?: boolean;
187
144
  /**
188
- * ([anymatch](https://github.com/micromatch/anymatch)-compatible definition) Defines files/paths to
189
- * be ignored. The whole relative or absolute path is tested, not just filename. If a function
190
- * with two arguments is provided, it gets called twice per path - once with a single argument
191
- * (the path), second time with two arguments (the path and the
192
- * [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
145
+ * Instructs the plugin whether to enable mixed module transformations. This
146
+ * is useful in scenarios with modules that contain a mix of ES `import`
147
+ * statements and CommonJS `require` expressions. Set to `true` if `require`
148
+ * calls should be transformed to imports in mixed modules, or `false` if the
149
+ * `require` expressions should survive the transformation. The latter can be
150
+ * important if the code contains environment detection, or you are coding
151
+ * for an environment with special treatment for `require` calls such as
152
+ * ElectronJS. See also the `ignore` option.
153
+ * @default false
193
154
  */
194
- ignored?: AnymatchMatcher;
155
+ transformMixedEsModules?: boolean;
195
156
  /**
196
- * If set to `false` then `add`/`addDir` events are also emitted for matching paths while
197
- * instantiating the watching as chokidar discovers these file paths (before the `ready` event).
157
+ * By default, this plugin will try to hoist `require` statements as imports
158
+ * to the top of each file. While this works well for many code bases and
159
+ * allows for very efficient ESM output, it does not perfectly capture
160
+ * CommonJS semantics as the order of side effects like log statements may
161
+ * change. But it is especially problematic when there are circular `require`
162
+ * calls between CommonJS modules as those often rely on the lazy execution of
163
+ * nested `require` calls.
164
+ *
165
+ * Setting this option to `true` will wrap all CommonJS files in functions
166
+ * which are executed when they are required for the first time, preserving
167
+ * NodeJS semantics. Note that this can have an impact on the size and
168
+ * performance of the generated code.
169
+ *
170
+ * The default value of `"auto"` will only wrap CommonJS files when they are
171
+ * part of a CommonJS dependency cycle, e.g. an index file that is required by
172
+ * many of its dependencies. All other CommonJS files are hoisted. This is the
173
+ * recommended setting for most code bases.
174
+ *
175
+ * `false` will entirely prevent wrapping and hoist all files. This may still
176
+ * work depending on the nature of cyclic dependencies but will often cause
177
+ * problems.
178
+ *
179
+ * You can also provide a minimatch pattern, or array of patterns, to only
180
+ * specify a subset of files which should be wrapped in functions for proper
181
+ * `require` semantics.
182
+ *
183
+ * `"debug"` works like `"auto"` but after bundling, it will display a warning
184
+ * containing a list of ids that have been wrapped which can be used as
185
+ * minimatch pattern for fine-tuning.
186
+ * @default "auto"
198
187
  */
199
- ignoreInitial?: boolean;
188
+ strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[];
200
189
  /**
201
- * When `false`, only the symlinks themselves will be watched for changes instead of following
202
- * the link references and bubbling events through the link's path.
190
+ * Sometimes you have to leave require statements unconverted. Pass an array
191
+ * containing the IDs or a `id => boolean` function.
192
+ * @default []
203
193
  */
204
- followSymlinks?: boolean;
194
+ ignore?: ReadonlyArray<string> | ((id: string) => boolean);
205
195
  /**
206
- * The base directory from which watch `paths` are to be derived. Paths emitted with events will
207
- * be relative to this.
196
+ * In most cases, where `require` calls are inside a `try-catch` clause,
197
+ * they should be left unconverted as it requires an optional dependency
198
+ * that may or may not be installed beside the rolled up package.
199
+ * Due to the conversion of `require` to a static `import` - the call is
200
+ * hoisted to the top of the file, outside the `try-catch` clause.
201
+ *
202
+ * - `true`: Default. All `require` calls inside a `try` will be left unconverted.
203
+ * - `false`: All `require` calls inside a `try` will be converted as if the
204
+ * `try-catch` clause is not there.
205
+ * - `remove`: Remove all `require` calls from inside any `try` block.
206
+ * - `string[]`: Pass an array containing the IDs to left unconverted.
207
+ * - `((id: string) => boolean|'remove')`: Pass a function that controls
208
+ * individual IDs.
209
+ *
210
+ * @default true
208
211
  */
209
- cwd?: string;
212
+ ignoreTryCatch?: boolean | 'remove' | ReadonlyArray<string> | ((id: string) => boolean | 'remove');
210
213
  /**
211
- * If set to true then the strings passed to .watch() and .add() are treated as literal path
212
- * names, even if they look like globs.
214
+ * Controls how to render imports from external dependencies. By default,
215
+ * this plugin assumes that all external dependencies are CommonJS. This
216
+ * means they are rendered as default imports to be compatible with e.g.
217
+ * NodeJS where ES modules can only import a default export from a CommonJS
218
+ * dependency.
219
+ *
220
+ * If you set `esmExternals` to `true`, this plugin assumes that all
221
+ * external dependencies are ES modules and respect the
222
+ * `requireReturnsDefault` option. If that option is not set, they will be
223
+ * rendered as namespace imports.
213
224
  *
225
+ * You can also supply an array of ids to be treated as ES modules, or a
226
+ * function that will be passed each external id to determine whether it is
227
+ * an ES module.
214
228
  * @default false
215
229
  */
216
- disableGlobbing?: boolean;
217
- /**
218
- * Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU
219
- * utilization, consider setting this to `false`. It is typically necessary to **set this to
220
- * `true` to successfully watch files over a network**, and it may be necessary to successfully
221
- * watch files in other non-standard situations. Setting to `true` explicitly on OS X overrides
222
- * the `useFsEvents` default.
223
- */
224
- usePolling?: boolean;
225
- /**
226
- * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
227
- * and `fsevents` is available this supersedes the `usePolling` setting. When set to `false` on
228
- * OS X, `usePolling: true` becomes the default.
229
- */
230
- useFsEvents?: boolean;
230
+ esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean);
231
231
  /**
232
- * If relying upon the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that
233
- * may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is
234
- * provided even in cases where it wasn't already available from the underlying watch events.
232
+ * Controls what is returned when requiring an ES module from a CommonJS file.
233
+ * When using the `esmExternals` option, this will also apply to external
234
+ * modules. By default, this plugin will render those imports as namespace
235
+ * imports i.e.
236
+ *
237
+ * ```js
238
+ * // input
239
+ * const foo = require('foo');
240
+ *
241
+ * // output
242
+ * import * as foo from 'foo';
243
+ * ```
244
+ *
245
+ * However, there are some situations where this may not be desired.
246
+ * For these situations, you can change Rollup's behaviour either globally or
247
+ * per module. To change it globally, set the `requireReturnsDefault` option
248
+ * to one of the following values:
249
+ *
250
+ * - `false`: This is the default, requiring an ES module returns its
251
+ * namespace. This is the only option that will also add a marker
252
+ * `__esModule: true` to the namespace to support interop patterns in
253
+ * CommonJS modules that are transpiled ES modules.
254
+ * - `"namespace"`: Like `false`, requiring an ES module returns its
255
+ * namespace, but the plugin does not add the `__esModule` marker and thus
256
+ * creates more efficient code. For external dependencies when using
257
+ * `esmExternals: true`, no additional interop code is generated.
258
+ * - `"auto"`: This is complementary to how `output.exports: "auto"` works in
259
+ * Rollup: If a module has a default export and no named exports, requiring
260
+ * that module returns the default export. In all other cases, the namespace
261
+ * is returned. For external dependencies when using `esmExternals: true`, a
262
+ * corresponding interop helper is added.
263
+ * - `"preferred"`: If a module has a default export, requiring that module
264
+ * always returns the default export, no matter whether additional named
265
+ * exports exist. This is similar to how previous versions of this plugin
266
+ * worked. Again for external dependencies when using `esmExternals: true`,
267
+ * an interop helper is added.
268
+ * - `true`: This will always try to return the default export on require
269
+ * without checking if it actually exists. This can throw at build time if
270
+ * there is no default export. This is how external dependencies are handled
271
+ * when `esmExternals` is not used. The advantage over the other options is
272
+ * that, like `false`, this does not add an interop helper for external
273
+ * dependencies, keeping the code lean.
274
+ *
275
+ * To change this for individual modules, you can supply a function for
276
+ * `requireReturnsDefault` instead. This function will then be called once for
277
+ * each required ES module or external dependency with the corresponding id
278
+ * and allows you to return different values for different modules.
279
+ * @default false
280
+ */
281
+ requireReturnsDefault?: boolean | 'auto' | 'preferred' | 'namespace' | ((id: string) => boolean | 'auto' | 'preferred' | 'namespace');
282
+ /**
283
+ * @default "auto"
284
+ */
285
+ defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto');
286
+ /**
287
+ * Some modules contain dynamic `require` calls, or require modules that
288
+ * contain circular dependencies, which are not handled well by static
289
+ * imports. Including those modules as `dynamicRequireTargets` will simulate a
290
+ * CommonJS (NodeJS-like) environment for them with support for dynamic
291
+ * dependencies. It also enables `strictRequires` for those modules.
292
+ *
293
+ * Note: In extreme cases, this feature may result in some paths being
294
+ * rendered as absolute in the final bundle. The plugin tries to avoid
295
+ * exposing paths from the local machine, but if you are `dynamicRequirePaths`
296
+ * with paths that are far away from your project's folder, that may require
297
+ * replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
298
+ */
299
+ dynamicRequireTargets?: string | ReadonlyArray<string>;
300
+ /**
301
+ * To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
302
+ * that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
303
+ * may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
304
+ * home directory name. By default, it uses the current working directory.
305
+ */
306
+ dynamicRequireRoot?: string;
307
+ }
308
+ //#endregion
309
+ //#region src/types/dynamicImportVars.d.ts
310
+ interface RollupDynamicImportVarsOptions {
311
+ /**
312
+ * Files to include in this plugin (default all).
313
+ * @default []
314
+ */
315
+ include?: string | RegExp | (string | RegExp)[];
316
+ /**
317
+ * Files to exclude in this plugin (default none).
318
+ * @default []
319
+ */
320
+ exclude?: string | RegExp | (string | RegExp)[];
321
+ /**
322
+ * @deprecated This option is no-op and will be removed in future versions.
323
+ */
324
+ warnOnError?: boolean;
325
+ }
326
+ //#endregion
327
+ //#region src/types/anymatch.d.ts
328
+ type AnymatchFn = (testString: string) => boolean;
329
+ type AnymatchPattern = string | RegExp | AnymatchFn;
330
+ type AnymatchMatcher = AnymatchPattern | AnymatchPattern[];
331
+ //#endregion
332
+ //#region src/types/chokidar.d.ts
333
+ declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
334
+ options: WatchOptions;
335
+ /**
336
+ * Constructs a new FSWatcher instance with optional WatchOptions parameter.
337
+ */
338
+ constructor(options?: WatchOptions);
339
+ /**
340
+ * When called, requests that the Node.js event loop not exit so long as the fs.FSWatcher is active.
341
+ * Calling watcher.ref() multiple times will have no effect.
342
+ */
343
+ ref(): this;
344
+ /**
345
+ * When called, the active fs.FSWatcher object will not require the Node.js event loop to remain active.
346
+ * If there is no other activity keeping the event loop running, the process may exit before the fs.FSWatcher object's callback is invoked.
347
+ * Calling watcher.unref() multiple times will have no effect.
348
+ */
349
+ unref(): this;
350
+ /**
351
+ * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
352
+ * string.
353
+ */
354
+ add(paths: string | ReadonlyArray<string>): this;
355
+ /**
356
+ * Stop watching files, directories, or glob patterns. Takes an array of strings or just one
357
+ * string.
358
+ */
359
+ unwatch(paths: string | ReadonlyArray<string>): this;
360
+ /**
361
+ * Returns an object representing all the paths on the file system being watched by this
362
+ * `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
363
+ * the `cwd` option was used), and the values are arrays of the names of the items contained in
364
+ * each directory.
365
+ */
366
+ getWatched(): {
367
+ [directory: string]: string[];
368
+ };
369
+ /**
370
+ * Removes all listeners from watched files.
371
+ */
372
+ close(): Promise<void>;
373
+ on(event: 'add' | 'addDir' | 'change', listener: (path: string, stats?: fs.Stats) => void): this;
374
+ on(event: 'all', listener: (eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', path: string, stats?: fs.Stats) => void): this;
375
+ /**
376
+ * Error occurred
377
+ */
378
+ on(event: 'error', listener: (error: Error) => void): this;
379
+ /**
380
+ * Exposes the native Node `fs.FSWatcher events`
381
+ */
382
+ on(event: 'raw', listener: (eventName: string, path: string, details: any) => void): this;
383
+ /**
384
+ * Fires when the initial scan is complete
385
+ */
386
+ on(event: 'ready', listener: () => void): this;
387
+ on(event: 'unlink' | 'unlinkDir', listener: (path: string) => void): this;
388
+ on(event: string, listener: (...args: any[]) => void): this;
389
+ }
390
+ interface WatchOptions {
391
+ /**
392
+ * Indicates whether the process should continue to run as long as files are being watched. If
393
+ * set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`,
394
+ * even if the process continues to run.
395
+ */
396
+ persistent?: boolean;
397
+ /**
398
+ * ([anymatch](https://github.com/micromatch/anymatch)-compatible definition) Defines files/paths to
399
+ * be ignored. The whole relative or absolute path is tested, not just filename. If a function
400
+ * with two arguments is provided, it gets called twice per path - once with a single argument
401
+ * (the path), second time with two arguments (the path and the
402
+ * [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
403
+ */
404
+ ignored?: AnymatchMatcher;
405
+ /**
406
+ * If set to `false` then `add`/`addDir` events are also emitted for matching paths while
407
+ * instantiating the watching as chokidar discovers these file paths (before the `ready` event).
408
+ */
409
+ ignoreInitial?: boolean;
410
+ /**
411
+ * When `false`, only the symlinks themselves will be watched for changes instead of following
412
+ * the link references and bubbling events through the link's path.
413
+ */
414
+ followSymlinks?: boolean;
415
+ /**
416
+ * The base directory from which watch `paths` are to be derived. Paths emitted with events will
417
+ * be relative to this.
418
+ */
419
+ cwd?: string;
420
+ /**
421
+ * If set to true then the strings passed to .watch() and .add() are treated as literal path
422
+ * names, even if they look like globs.
423
+ *
424
+ * @default false
425
+ */
426
+ disableGlobbing?: boolean;
427
+ /**
428
+ * Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU
429
+ * utilization, consider setting this to `false`. It is typically necessary to **set this to
430
+ * `true` to successfully watch files over a network**, and it may be necessary to successfully
431
+ * watch files in other non-standard situations. Setting to `true` explicitly on OS X overrides
432
+ * the `useFsEvents` default.
433
+ */
434
+ usePolling?: boolean;
435
+ /**
436
+ * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
437
+ * and `fsevents` is available this supersedes the `usePolling` setting. When set to `false` on
438
+ * OS X, `usePolling: true` becomes the default.
439
+ */
440
+ useFsEvents?: boolean;
441
+ /**
442
+ * If relying upon the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that
443
+ * may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is
444
+ * provided even in cases where it wasn't already available from the underlying watch events.
235
445
  */
236
446
  alwaysStat?: boolean;
237
447
  /**
@@ -345,6 +555,18 @@ declare namespace Connect {
345
555
  }
346
556
  }
347
557
  //#endregion
558
+ //#region src/shared/forwardConsole.d.ts
559
+ type ForwardConsoleLogLevel = "error" | "warn" | "info" | "log" | "debug" | (string & {});
560
+ interface ForwardConsoleOptions {
561
+ unhandledErrors?: boolean;
562
+ logLevels?: ForwardConsoleLogLevel[];
563
+ }
564
+ interface ResolvedForwardConsoleOptions {
565
+ enabled: boolean;
566
+ unhandledErrors: boolean;
567
+ logLevels: ForwardConsoleLogLevel[];
568
+ }
569
+ //#endregion
348
570
  //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3_ms@2.1.3/node_modules/http-proxy-3/dist/lib/http-proxy/index.d.ts
349
571
  interface ProxyTargetDetailed {
350
572
  host: string;
@@ -576,34 +798,6 @@ interface ProxyOptions extends ServerOptions$3 {
576
798
  rewriteWsOrigin?: boolean | undefined;
577
799
  }
578
800
  //#endregion
579
- //#region src/node/logger.d.ts
580
- type LogType = "error" | "warn" | "info";
581
- type LogLevel = LogType | "silent";
582
- interface Logger {
583
- info(msg: string, options?: LogOptions): void;
584
- warn(msg: string, options?: LogOptions): void;
585
- warnOnce(msg: string, options?: LogOptions): void;
586
- error(msg: string, options?: LogErrorOptions): void;
587
- clearScreen(type: LogType): void;
588
- hasErrorLogged(error: Error | RollupError): boolean;
589
- hasWarned: boolean;
590
- }
591
- interface LogOptions {
592
- clear?: boolean;
593
- timestamp?: boolean;
594
- environment?: string;
595
- }
596
- interface LogErrorOptions extends LogOptions {
597
- error?: Error | RollupError | null;
598
- }
599
- interface LoggerOptions {
600
- prefix?: string;
601
- allowClearScreen?: boolean;
602
- customLogger?: Logger;
603
- console?: Console;
604
- }
605
- export declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
606
- //#endregion
607
801
  //#region src/node/http.d.ts
608
802
  interface CommonServerOptions {
609
803
  /**
@@ -704,120 +898,6 @@ interface CorsOptions {
704
898
  }
705
899
  type CorsOrigin = boolean | string | RegExp | (string | RegExp)[];
706
900
  //#endregion
707
- //#region src/shared/forwardConsole.d.ts
708
- type ForwardConsoleLogLevel = "error" | "warn" | "info" | "log" | "debug" | (string & {});
709
- interface ForwardConsoleOptions {
710
- unhandledErrors?: boolean;
711
- logLevels?: ForwardConsoleLogLevel[];
712
- }
713
- interface ResolvedForwardConsoleOptions {
714
- enabled: boolean;
715
- unhandledErrors: boolean;
716
- logLevels: ForwardConsoleLogLevel[];
717
- }
718
- //#endregion
719
- //#region src/node/typeUtils.d.ts
720
- type RequiredExceptFor<T, K extends keyof T> = Pick<T, K> & Required<Omit<T, K>>;
721
- //#endregion
722
- //#region src/node/preview.d.ts
723
- interface PreviewOptions extends CommonServerOptions {}
724
- interface ResolvedPreviewOptions extends RequiredExceptFor<PreviewOptions, "host" | "https" | "proxy"> {}
725
- interface PreviewServer {
726
- /**
727
- * The resolved vite config object
728
- */
729
- config: ResolvedConfig;
730
- /**
731
- * Stop the server.
732
- */
733
- close(): Promise<void>;
734
- /**
735
- * A connect app instance.
736
- * - Can be used to attach custom middlewares to the preview server.
737
- * - Can also be used as the handler function of a custom http server
738
- * or as a middleware in any connect-style Node.js frameworks
739
- *
740
- * https://github.com/senchalabs/connect#use-middleware
741
- */
742
- middlewares: Connect.Server;
743
- /**
744
- * native Node http server instance
745
- */
746
- httpServer: HttpServer;
747
- /**
748
- * The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
749
- * if the server is not listening on any port.
750
- */
751
- resolvedUrls: ResolvedServerUrls | null;
752
- /**
753
- * Print server urls
754
- */
755
- printUrls(): void;
756
- /**
757
- * Bind CLI shortcuts
758
- */
759
- bindCLIShortcuts(options?: BindCLIShortcutsOptions<PreviewServer>): void;
760
- }
761
- type PreviewServerHook = (this: MinimalPluginContextWithoutEnvironment, server: PreviewServer) => (() => void) | void | Promise<(() => void) | void>;
762
- /**
763
- * Starts the Vite server in preview mode, to simulate a production deployment
764
- */
765
- export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewServer>;
766
- //#endregion
767
- //#region src/node/shortcuts.d.ts
768
- type BindCLIShortcutsOptions<Server = ViteDevServer | PreviewServer> = {
769
- /**
770
- * Print a one-line shortcuts "help" hint to the terminal
771
- */
772
- print?: boolean;
773
- /**
774
- * Custom shortcuts to run when a key is pressed. These shortcuts take priority
775
- * over the default shortcuts if they have the same keys (except the `h` key).
776
- * To disable a default shortcut, define the same key but with `action: undefined`.
777
- */
778
- customShortcuts?: CLIShortcut<Server>[];
779
- };
780
- type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
781
- key: string;
782
- description: string;
783
- action?(server: Server): void | Promise<void>;
784
- };
785
- //#endregion
786
- //#region src/node/baseEnvironment.d.ts
787
- declare class PartialEnvironment {
788
- name: string;
789
- getTopLevelConfig(): ResolvedConfig;
790
- config: ResolvedConfig & ResolvedEnvironmentOptions;
791
- logger: Logger;
792
- constructor(name: string, topLevelConfig: ResolvedConfig, options?: ResolvedEnvironmentOptions);
793
- }
794
- declare class BaseEnvironment extends PartialEnvironment {
795
- get plugins(): readonly Plugin[];
796
- constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
797
- }
798
- /**
799
- * This class discourages users from inversely checking the `mode`
800
- * to determine the type of environment, e.g.
801
- *
802
- * ```js
803
- * const isDev = environment.mode !== 'build' // bad
804
- * const isDev = environment.mode === 'dev' // good
805
- * ```
806
- *
807
- * You should also not check against `"unknown"` specifically. It's
808
- * a placeholder for more possible environment types.
809
- */
810
- declare class UnknownEnvironment extends BaseEnvironment {
811
- mode: "unknown";
812
- }
813
- //#endregion
814
- //#region src/node/optimizer/scan.d.ts
815
- declare class ScanEnvironment extends BaseEnvironment {
816
- mode: "scan";
817
- get pluginContainer(): EnvironmentPluginContainer;
818
- init(): Promise<void>;
819
- }
820
- //#endregion
821
901
  //#region src/node/optimizer/index.d.ts
822
902
  type ExportsData = {
823
903
  hasModuleSyntax: boolean;
@@ -826,6 +906,7 @@ type ExportsData = {
826
906
  };
827
907
  interface DepsOptimizer {
828
908
  init: () => Promise<void>;
909
+ initState: "idle" | "initializing" | "initialized";
829
910
  metadata: DepOptimizationMetadata;
830
911
  scanProcessing?: Promise<void>;
831
912
  registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
@@ -838,8 +919,8 @@ interface DepsOptimizer {
838
919
  }
839
920
  interface DepOptimizationConfig {
840
921
  /**
841
- * Force optimize listed dependencies (must be resolvable import paths,
842
- * cannot be globs).
922
+ * Force optimize listed dependencies (must be resolvable import paths).
923
+ * Supports experimental glob patterns for deep imports.
843
924
  */
844
925
  include?: string[];
845
926
  /**
@@ -1015,6 +1096,59 @@ interface DepOptimizationMetadata {
1015
1096
  */
1016
1097
  export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
1017
1098
  //#endregion
1099
+ //#region src/node/server/bundledDev.d.ts
1100
+ type MemoryFile = {
1101
+ source: string | Uint8Array;
1102
+ etag?: string;
1103
+ };
1104
+ declare class MemoryFiles {
1105
+ private files;
1106
+ get size(): number;
1107
+ get(file: string): MemoryFile | undefined;
1108
+ set(file: string, content: MemoryFile | (() => MemoryFile)): void;
1109
+ has(file: string): boolean;
1110
+ clear(): void;
1111
+ }
1112
+ declare class BundledDev {
1113
+ private environment;
1114
+ private _devEngine;
1115
+ private viteRuntime?;
1116
+ private initialBuildCompleted;
1117
+ private _closed;
1118
+ private clients;
1119
+ private debouncedFullReload;
1120
+ private fullReloadPending;
1121
+ private reloadNeededClientIds;
1122
+ private debouncedReloadNeededFlush;
1123
+ private lastBuildError;
1124
+ memoryFiles: MemoryFiles;
1125
+ constructor(environment: DevEnvironment);
1126
+ private get devEngine();
1127
+ private pendingPayloadFilenames;
1128
+ get hasBuildOutput(): boolean;
1129
+ listen(): Promise<void>;
1130
+ private waitForInitialBuildFinish;
1131
+ private ensureOutputAndFlushReloadNeeded;
1132
+ triggerBundleRegenerationIfStale(): Promise<boolean>;
1133
+ triggerLazyBundling(moduleId: string | null, clientId: string | null): Promise<{
1134
+ code: string;
1135
+ filename: string;
1136
+ } | undefined>;
1137
+ /**
1138
+ * Called when the client reports that it evaluated a payload (the line appended
1139
+ * by `payloadDeliveredAck`). Only then is the payload recorded on the server's
1140
+ * per-client ship map, so later chunks may omit a module only if the client
1141
+ * already registered it.
1142
+ *
1143
+ * Note: the payload filename is unique across all clients.
1144
+ */
1145
+ markPayloadDelivered(filename: string): void;
1146
+ close(): Promise<void>;
1147
+ private storeOutputFiles;
1148
+ private getRolldownOptions;
1149
+ private handleHmrOutput;
1150
+ }
1151
+ //#endregion
1018
1152
  //#region src/node/server/transformRequest.d.ts
1019
1153
  interface TransformResult {
1020
1154
  code: string;
@@ -1308,101 +1442,209 @@ type ServerHotChannel = HotChannel<ServerHotChannelApi>;
1308
1442
  type NormalizedServerHotChannel = NormalizedHotChannel<ServerHotChannelApi>;
1309
1443
  export declare function createServerHotChannel(): ServerHotChannel;
1310
1444
  //#endregion
1311
- //#region src/types/ws.d.ts
1312
- // WebSocket socket.
1313
- declare class WebSocket extends EventEmitter {
1314
- /** The connection is not yet open. */
1315
- static readonly CONNECTING: 0;
1316
- /** The connection is open and ready to communicate. */
1317
- static readonly OPEN: 1;
1318
- /** The connection is in the process of closing. */
1319
- static readonly CLOSING: 2;
1320
- /** The connection is closed. */
1321
- static readonly CLOSED: 3;
1322
- binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments';
1323
- readonly bufferedAmount: number;
1324
- readonly extensions: string;
1325
- /** Indicates whether the websocket is paused */
1326
- readonly isPaused: boolean;
1327
- readonly protocol: string;
1328
- /** The current state of the connection */
1329
- readonly readyState: typeof WebSocket.CONNECTING | typeof WebSocket.OPEN | typeof WebSocket.CLOSING | typeof WebSocket.CLOSED;
1330
- readonly url: string;
1331
- /** The connection is not yet open. */
1332
- readonly CONNECTING: 0;
1333
- /** The connection is open and ready to communicate. */
1334
- readonly OPEN: 1;
1335
- /** The connection is in the process of closing. */
1336
- readonly CLOSING: 2;
1337
- /** The connection is closed. */
1338
- readonly CLOSED: 3;
1339
- onopen: ((event: WebSocket.Event) => void) | null;
1340
- onerror: ((event: WebSocket.ErrorEvent) => void) | null;
1341
- onclose: ((event: WebSocket.CloseEvent) => void) | null;
1342
- onmessage: ((event: WebSocket.MessageEvent) => void) | null;
1343
- constructor(address: null);
1344
- constructor(address: string | url_URL, options?: WebSocket.ClientOptions | ClientRequestArgs);
1345
- constructor(address: string | url_URL, protocols?: string | string[], options?: WebSocket.ClientOptions | ClientRequestArgs);
1346
- close(code?: number, data?: string | Buffer): void;
1347
- ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
1348
- pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
1349
- send(data: any, cb?: (err?: Error) => void): void;
1350
- send(data: any, options: {
1351
- mask?: boolean | undefined;
1352
- binary?: boolean | undefined;
1353
- compress?: boolean | undefined;
1354
- fin?: boolean | undefined;
1355
- }, cb?: (err?: Error) => void): void;
1356
- terminate(): void;
1357
- /**
1358
- * Pause the websocket causing it to stop emitting events. Some events can still be
1359
- * emitted after this is called, until all buffered data is consumed. This method
1360
- * is a noop if the ready state is `CONNECTING` or `CLOSED`.
1361
- */
1362
- pause(): void;
1363
- /**
1364
- * Make a paused socket resume emitting events. This method is a noop if the ready
1365
- * state is `CONNECTING` or `CLOSED`.
1366
- */
1367
- resume(): void;
1368
- // HTML5 WebSocket events
1369
- addEventListener(method: 'message', cb: (event: WebSocket.MessageEvent) => void, options?: WebSocket.EventListenerOptions): void;
1370
- addEventListener(method: 'close', cb: (event: WebSocket.CloseEvent) => void, options?: WebSocket.EventListenerOptions): void;
1371
- addEventListener(method: 'error', cb: (event: WebSocket.ErrorEvent) => void, options?: WebSocket.EventListenerOptions): void;
1372
- addEventListener(method: 'open', cb: (event: WebSocket.Event) => void, options?: WebSocket.EventListenerOptions): void;
1373
- removeEventListener(method: 'message', cb: (event: WebSocket.MessageEvent) => void): void;
1374
- removeEventListener(method: 'close', cb: (event: WebSocket.CloseEvent) => void): void;
1375
- removeEventListener(method: 'error', cb: (event: WebSocket.ErrorEvent) => void): void;
1376
- removeEventListener(method: 'open', cb: (event: WebSocket.Event) => void): void;
1377
- // Events
1378
- on(event: 'close', listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
1379
- on(event: 'error', listener: (this: WebSocket, err: Error) => void): this;
1380
- on(event: 'upgrade', listener: (this: WebSocket, request: http.IncomingMessage) => void): this;
1381
- on(event: 'message', listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
1382
- on(event: 'open', listener: (this: WebSocket) => void): this;
1383
- on(event: 'ping' | 'pong', listener: (this: WebSocket, data: Buffer) => void): this;
1384
- on(event: 'unexpected-response', listener: (this: WebSocket, request: ClientRequest, response: http.IncomingMessage) => void): this;
1385
- on(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
1386
- once(event: 'close', listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
1387
- once(event: 'error', listener: (this: WebSocket, err: Error) => void): this;
1388
- once(event: 'upgrade', listener: (this: WebSocket, request: http.IncomingMessage) => void): this;
1389
- once(event: 'message', listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
1390
- once(event: 'open', listener: (this: WebSocket) => void): this;
1391
- once(event: 'ping' | 'pong', listener: (this: WebSocket, data: Buffer) => void): this;
1392
- once(event: 'unexpected-response', listener: (this: WebSocket, request: ClientRequest, response: http.IncomingMessage) => void): this;
1393
- once(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
1394
- off(event: 'close', listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
1395
- off(event: 'error', listener: (this: WebSocket, err: Error) => void): this;
1396
- off(event: 'upgrade', listener: (this: WebSocket, request: http.IncomingMessage) => void): this;
1397
- off(event: 'message', listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
1398
- off(event: 'open', listener: (this: WebSocket) => void): this;
1399
- off(event: 'ping' | 'pong', listener: (this: WebSocket, data: Buffer) => void): this;
1400
- off(event: 'unexpected-response', listener: (this: WebSocket, request: ClientRequest, response: http.IncomingMessage) => void): this;
1401
- off(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
1402
- addListener(event: 'close', listener: (code: number, reason: Buffer) => void): this;
1403
- addListener(event: 'error', listener: (err: Error) => void): this;
1404
- addListener(event: 'upgrade', listener: (request: http.IncomingMessage) => void): this;
1405
- addListener(event: 'message', listener: (data: WebSocket.RawData, isBinary: boolean) => void): this;
1445
+ //#region src/node/server/pluginContainer.d.ts
1446
+ type SkipInformation = {
1447
+ id: string;
1448
+ importer: string | undefined;
1449
+ plugin: Plugin;
1450
+ called?: boolean;
1451
+ };
1452
+ declare class EnvironmentPluginContainer<Env extends Environment = Environment> {
1453
+ private _pluginContextMap;
1454
+ private _resolvedRolldownOptions?;
1455
+ private _processesing;
1456
+ private _seenResolves;
1457
+ private _moduleNodeToLoadAddedImports;
1458
+ getSortedPluginHooks: PluginHookUtils["getSortedPluginHooks"];
1459
+ getSortedPlugins: PluginHookUtils["getSortedPlugins"];
1460
+ moduleGraph: EnvironmentModuleGraph | undefined;
1461
+ watchFiles: Set<string>;
1462
+ minimalContext: MinimalPluginContext$1<Env>;
1463
+ private _started;
1464
+ private _buildStartPromise;
1465
+ private _closed;
1466
+ private _updateModuleLoadAddedImports;
1467
+ private _getAddedImports;
1468
+ getModuleInfo(id: string): ModuleInfo | null;
1469
+ private handleHookPromise;
1470
+ get options(): InputOptions;
1471
+ resolveRolldownOptions(): Promise<InputOptions>;
1472
+ private _getPluginContext;
1473
+ private hookParallel;
1474
+ buildStart(_options?: InputOptions): Promise<void>;
1475
+ resolveId(rawId: string, importer?: string | undefined, options?: {
1476
+ kind?: ImportKind;
1477
+ attributes?: Record<string, string>;
1478
+ custom?: CustomPluginOptions;
1479
+ /** @deprecated use `skipCalls` instead */
1480
+ skip?: Set<Plugin>;
1481
+ skipCalls?: readonly SkipInformation[];
1482
+
1483
+ isEntry?: boolean;
1484
+ }): Promise<PartialResolvedId | null>;
1485
+ load(id: string): Promise<LoadResult | null>;
1486
+ transform(code: string, id: string, options?: {
1487
+ inMap?: SourceDescription["map"];
1488
+ moduleType?: string;
1489
+ }): Promise<{
1490
+ code: string;
1491
+ map: SourceMap | {
1492
+ mappings: "";
1493
+ } | null;
1494
+ moduleType?: ModuleType;
1495
+ }>;
1496
+ watchChange(id: string, change: {
1497
+ event: "create" | "update" | "delete";
1498
+ }): Promise<void>;
1499
+ close(): Promise<void>;
1500
+ }
1501
+ declare class BasicMinimalPluginContext<Meta = PluginContextMeta> {
1502
+ meta: Meta;
1503
+ private _logger;
1504
+ constructor(meta: Meta, _logger: Logger);
1505
+ get pluginName(): string;
1506
+ debug(rawLog: string | RollupLog | (() => string | RollupLog)): void;
1507
+ info(rawLog: string | RollupLog | (() => string | RollupLog)): void;
1508
+ warn(rawLog: string | RollupLog | (() => string | RollupLog)): void;
1509
+ error(e: string | RollupError): never;
1510
+ private _normalizeRawLog;
1511
+ }
1512
+ declare class MinimalPluginContext$1<T extends Environment = Environment> extends BasicMinimalPluginContext implements MinimalPluginContext {
1513
+ environment: T;
1514
+ constructor(meta: PluginContextMeta, environment: T);
1515
+ }
1516
+ declare class PluginContainer {
1517
+ private environments;
1518
+ constructor(environments: Record<string, Environment>);
1519
+ private _getEnvironment;
1520
+ private _getPluginContainer;
1521
+ getModuleInfo(id: string): ModuleInfo | null;
1522
+ get options(): InputOptions;
1523
+ buildStart(_options?: InputOptions): Promise<void>;
1524
+ watchChange(id: string, change: {
1525
+ event: "create" | "update" | "delete";
1526
+ }): Promise<void>;
1527
+ resolveId(rawId: string, importer?: string, options?: {
1528
+ attributes?: Record<string, string>;
1529
+ custom?: CustomPluginOptions;
1530
+ /** @deprecated use `skipCalls` instead */
1531
+ skip?: Set<Plugin>;
1532
+ skipCalls?: readonly SkipInformation[];
1533
+ ssr?: boolean;
1534
+
1535
+ isEntry?: boolean;
1536
+ }): Promise<PartialResolvedId | null>;
1537
+ load(id: string, options?: {
1538
+ ssr?: boolean;
1539
+ }): Promise<LoadResult | null>;
1540
+ transform(code: string, id: string, options?: {
1541
+ ssr?: boolean;
1542
+ environment?: Environment;
1543
+ inMap?: SourceDescription["map"];
1544
+ }): Promise<{
1545
+ code: string;
1546
+ map: SourceMap | {
1547
+ mappings: "";
1548
+ } | null;
1549
+ }>;
1550
+ close(): Promise<void>;
1551
+ }
1552
+ //#endregion
1553
+ //#region src/types/ws.d.ts
1554
+ // WebSocket socket.
1555
+ declare class WebSocket extends EventEmitter {
1556
+ /** The connection is not yet open. */
1557
+ static readonly CONNECTING: 0;
1558
+ /** The connection is open and ready to communicate. */
1559
+ static readonly OPEN: 1;
1560
+ /** The connection is in the process of closing. */
1561
+ static readonly CLOSING: 2;
1562
+ /** The connection is closed. */
1563
+ static readonly CLOSED: 3;
1564
+ binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments';
1565
+ readonly bufferedAmount: number;
1566
+ readonly extensions: string;
1567
+ /** Indicates whether the websocket is paused */
1568
+ readonly isPaused: boolean;
1569
+ readonly protocol: string;
1570
+ /** The current state of the connection */
1571
+ readonly readyState: typeof WebSocket.CONNECTING | typeof WebSocket.OPEN | typeof WebSocket.CLOSING | typeof WebSocket.CLOSED;
1572
+ readonly url: string;
1573
+ /** The connection is not yet open. */
1574
+ readonly CONNECTING: 0;
1575
+ /** The connection is open and ready to communicate. */
1576
+ readonly OPEN: 1;
1577
+ /** The connection is in the process of closing. */
1578
+ readonly CLOSING: 2;
1579
+ /** The connection is closed. */
1580
+ readonly CLOSED: 3;
1581
+ onopen: ((event: WebSocket.Event) => void) | null;
1582
+ onerror: ((event: WebSocket.ErrorEvent) => void) | null;
1583
+ onclose: ((event: WebSocket.CloseEvent) => void) | null;
1584
+ onmessage: ((event: WebSocket.MessageEvent) => void) | null;
1585
+ constructor(address: null);
1586
+ constructor(address: string | url_URL, options?: WebSocket.ClientOptions | ClientRequestArgs);
1587
+ constructor(address: string | url_URL, protocols?: string | string[], options?: WebSocket.ClientOptions | ClientRequestArgs);
1588
+ close(code?: number, data?: string | Buffer): void;
1589
+ ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
1590
+ pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
1591
+ send(data: any, cb?: (err?: Error) => void): void;
1592
+ send(data: any, options: {
1593
+ mask?: boolean | undefined;
1594
+ binary?: boolean | undefined;
1595
+ compress?: boolean | undefined;
1596
+ fin?: boolean | undefined;
1597
+ }, cb?: (err?: Error) => void): void;
1598
+ terminate(): void;
1599
+ /**
1600
+ * Pause the websocket causing it to stop emitting events. Some events can still be
1601
+ * emitted after this is called, until all buffered data is consumed. This method
1602
+ * is a noop if the ready state is `CONNECTING` or `CLOSED`.
1603
+ */
1604
+ pause(): void;
1605
+ /**
1606
+ * Make a paused socket resume emitting events. This method is a noop if the ready
1607
+ * state is `CONNECTING` or `CLOSED`.
1608
+ */
1609
+ resume(): void;
1610
+ // HTML5 WebSocket events
1611
+ addEventListener(method: 'message', cb: (event: WebSocket.MessageEvent) => void, options?: WebSocket.EventListenerOptions): void;
1612
+ addEventListener(method: 'close', cb: (event: WebSocket.CloseEvent) => void, options?: WebSocket.EventListenerOptions): void;
1613
+ addEventListener(method: 'error', cb: (event: WebSocket.ErrorEvent) => void, options?: WebSocket.EventListenerOptions): void;
1614
+ addEventListener(method: 'open', cb: (event: WebSocket.Event) => void, options?: WebSocket.EventListenerOptions): void;
1615
+ removeEventListener(method: 'message', cb: (event: WebSocket.MessageEvent) => void): void;
1616
+ removeEventListener(method: 'close', cb: (event: WebSocket.CloseEvent) => void): void;
1617
+ removeEventListener(method: 'error', cb: (event: WebSocket.ErrorEvent) => void): void;
1618
+ removeEventListener(method: 'open', cb: (event: WebSocket.Event) => void): void;
1619
+ // Events
1620
+ on(event: 'close', listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
1621
+ on(event: 'error', listener: (this: WebSocket, err: Error) => void): this;
1622
+ on(event: 'upgrade', listener: (this: WebSocket, request: http.IncomingMessage) => void): this;
1623
+ on(event: 'message', listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
1624
+ on(event: 'open', listener: (this: WebSocket) => void): this;
1625
+ on(event: 'ping' | 'pong', listener: (this: WebSocket, data: Buffer) => void): this;
1626
+ on(event: 'unexpected-response', listener: (this: WebSocket, request: ClientRequest, response: http.IncomingMessage) => void): this;
1627
+ on(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
1628
+ once(event: 'close', listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
1629
+ once(event: 'error', listener: (this: WebSocket, err: Error) => void): this;
1630
+ once(event: 'upgrade', listener: (this: WebSocket, request: http.IncomingMessage) => void): this;
1631
+ once(event: 'message', listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
1632
+ once(event: 'open', listener: (this: WebSocket) => void): this;
1633
+ once(event: 'ping' | 'pong', listener: (this: WebSocket, data: Buffer) => void): this;
1634
+ once(event: 'unexpected-response', listener: (this: WebSocket, request: ClientRequest, response: http.IncomingMessage) => void): this;
1635
+ once(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
1636
+ off(event: 'close', listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
1637
+ off(event: 'error', listener: (this: WebSocket, err: Error) => void): this;
1638
+ off(event: 'upgrade', listener: (this: WebSocket, request: http.IncomingMessage) => void): this;
1639
+ off(event: 'message', listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
1640
+ off(event: 'open', listener: (this: WebSocket) => void): this;
1641
+ off(event: 'ping' | 'pong', listener: (this: WebSocket, data: Buffer) => void): this;
1642
+ off(event: 'unexpected-response', listener: (this: WebSocket, request: ClientRequest, response: http.IncomingMessage) => void): this;
1643
+ off(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
1644
+ addListener(event: 'close', listener: (code: number, reason: Buffer) => void): this;
1645
+ addListener(event: 'error', listener: (err: Error) => void): this;
1646
+ addListener(event: 'upgrade', listener: (request: http.IncomingMessage) => void): this;
1647
+ addListener(event: 'message', listener: (data: WebSocket.RawData, isBinary: boolean) => void): this;
1406
1648
  addListener(event: 'open', listener: () => void): this;
1407
1649
  addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this;
1408
1650
  addListener(event: 'unexpected-response', listener: (request: ClientRequest, response: http.IncomingMessage) => void): this;
@@ -1620,58 +1862,6 @@ interface WebSocketClient extends NormalizedHotChannelClient {
1620
1862
  socket: WebSocket;
1621
1863
  }
1622
1864
  //#endregion
1623
- //#region src/node/server/bundledDev.d.ts
1624
- type MemoryFile = {
1625
- source: string | Uint8Array;
1626
- etag?: string;
1627
- };
1628
- declare class MemoryFiles {
1629
- private files;
1630
- get size(): number;
1631
- get(file: string): MemoryFile | undefined;
1632
- set(file: string, content: MemoryFile | (() => MemoryFile)): void;
1633
- has(file: string): boolean;
1634
- clear(): void;
1635
- }
1636
- declare class BundledDev {
1637
- private environment;
1638
- private _devEngine;
1639
- private viteRuntime?;
1640
- private initialBuildCompleted;
1641
- private _closed;
1642
- private clients;
1643
- private debouncedFullReload;
1644
- private fullReloadPending;
1645
- private reloadNeededClientIds;
1646
- private debouncedReloadNeededFlush;
1647
- private lastBuildError;
1648
- memoryFiles: MemoryFiles;
1649
- constructor(environment: DevEnvironment);
1650
- private get devEngine();
1651
- private pendingPayloadFilenames;
1652
- get hasBuildOutput(): boolean;
1653
- listen(): Promise<void>;
1654
- private waitForInitialBuildFinish;
1655
- private ensureOutputAndFlushReloadNeeded;
1656
- triggerBundleRegenerationIfStale(): Promise<boolean>;
1657
- triggerLazyBundling(moduleId: string | null, clientId: string | null): Promise<{
1658
- code: string;
1659
- filename: string;
1660
- } | undefined>;
1661
- /**
1662
- * Called by the serving middlewares when the response for a payload completed.
1663
- * Only delivered payloads are recorded on the server's per-client ship map, so
1664
- * later chunks may omit a module only if the payload carrying it was delivered.
1665
- *
1666
- * Note: the payload filename is unique across all clients.
1667
- */
1668
- markPayloadDelivered(filename: string): void;
1669
- close(): Promise<void>;
1670
- private storeOutputFiles;
1671
- private getRolldownOptions;
1672
- private handleHmrOutput;
1673
- }
1674
- //#endregion
1675
1865
  //#region src/node/server/environment.d.ts
1676
1866
  interface DevEnvironmentContext {
1677
1867
  hot: boolean;
@@ -1740,799 +1930,427 @@ export declare class DevEnvironment extends BaseEnvironment {
1740
1930
  waitForRequestsIdle(ignoredId?: string): Promise<void>;
1741
1931
  }
1742
1932
  //#endregion
1743
- //#region src/types/commonjs.d.ts
1744
-
1745
- interface RollupCommonJSOptions {
1746
- /**
1747
- * A minimatch pattern, or array of patterns, which specifies the files in
1748
- * the build the plugin should operate on. By default, all files with
1749
- * extension `".cjs"` or those in `extensions` are included, but you can
1750
- * narrow this list by only including specific files. These files will be
1751
- * analyzed and transpiled if either the analysis does not find ES module
1752
- * specific statements or `transformMixedEsModules` is `true`.
1753
- * @default undefined
1754
- */
1755
- include?: string | RegExp | readonly (string | RegExp)[];
1933
+ //#region src/node/optimizer/scan.d.ts
1934
+ declare class ScanEnvironment extends BaseEnvironment {
1935
+ mode: "scan";
1936
+ get pluginContainer(): EnvironmentPluginContainer;
1937
+ init(): Promise<void>;
1938
+ }
1939
+ //#endregion
1940
+ //#region src/node/environment.d.ts
1941
+ type Environment = DevEnvironment | BuildEnvironment | ScanEnvironment | UnknownEnvironment;
1942
+ /**
1943
+ * Creates a function that hides the complexities of a WeakMap with an initial value
1944
+ * to implement object metadata. Used by plugins to implement cross hooks per
1945
+ * environment metadata
1946
+ *
1947
+ * @experimental
1948
+ */
1949
+ export declare function perEnvironmentState<State>(initial: (environment: Environment) => State): (context: PluginContext) => State;
1950
+ //#endregion
1951
+ //#region src/node/plugins/html.d.ts
1952
+ interface HtmlTagDescriptor {
1953
+ tag: string;
1756
1954
  /**
1757
- * A minimatch pattern, or array of patterns, which specifies the files in
1758
- * the build the plugin should _ignore_. By default, all files with
1759
- * extensions other than those in `extensions` or `".cjs"` are ignored, but you
1760
- * can exclude additional files. See also the `include` option.
1761
- * @default undefined
1955
+ * attribute values will be escaped automatically if needed
1762
1956
  */
1763
- exclude?: string | RegExp | readonly (string | RegExp)[];
1957
+ attrs?: Record<string, string | boolean | undefined>;
1958
+ children?: string | HtmlTagDescriptor[];
1764
1959
  /**
1765
- * For extensionless imports, search for extensions other than .js in the
1766
- * order specified. Note that you need to make sure that non-JavaScript files
1767
- * are transpiled by another plugin first.
1768
- * @default [ '.js' ]
1960
+ * default: 'head-prepend'
1769
1961
  */
1770
- extensions?: ReadonlyArray<string>;
1962
+ injectTo?: "head" | "body" | "head-prepend" | "body-prepend";
1963
+ }
1964
+ type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | {
1965
+ html: string;
1966
+ tags: HtmlTagDescriptor[];
1967
+ };
1968
+ interface IndexHtmlTransformContext {
1771
1969
  /**
1772
- * If true then uses of `global` won't be dealt with by this plugin
1773
- * @default false
1970
+ * public path when served
1774
1971
  */
1775
- ignoreGlobal?: boolean;
1972
+ path: string;
1776
1973
  /**
1777
- * If false, skips source map generation for CommonJS modules. This will
1778
- * improve performance.
1779
- * @default true
1974
+ * filename on disk
1780
1975
  */
1781
- sourceMap?: boolean;
1976
+ filename: string;
1977
+ server?: ViteDevServer;
1978
+ bundle?: OutputBundle;
1979
+ chunk?: OutputChunk;
1980
+ originalUrl?: string;
1981
+ }
1982
+ type IndexHtmlTransformHook = (this: MinimalPluginContextWithoutEnvironment, html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>;
1983
+ type IndexHtmlTransform = IndexHtmlTransformHook | {
1984
+ order?: "pre" | "post" | null;
1985
+ handler: IndexHtmlTransformHook;
1986
+ };
1987
+ //#endregion
1988
+ //#region src/node/plugins/pluginFilter.d.ts
1989
+ type StringFilter<Value = string | RegExp> = Value | Array<Value> | {
1990
+ include?: Value | Array<Value>;
1991
+ exclude?: Value | Array<Value>;
1992
+ };
1993
+ //#endregion
1994
+ //#region src/node/shortcuts.d.ts
1995
+ type BindCLIShortcutsOptions<Server = ViteDevServer | PreviewServer> = {
1782
1996
  /**
1783
- * Some `require` calls cannot be resolved statically to be translated to
1784
- * imports.
1785
- * When this option is set to `false`, the generated code will either
1786
- * directly throw an error when such a call is encountered or, when
1787
- * `dynamicRequireTargets` is used, when such a call cannot be resolved with a
1788
- * configured dynamic require target.
1789
- * Setting this option to `true` will instead leave the `require` call in the
1790
- * code or use it as a fallback for `dynamicRequireTargets`.
1791
- * @default false
1997
+ * Print a one-line shortcuts "help" hint to the terminal
1792
1998
  */
1793
- ignoreDynamicRequires?: boolean;
1999
+ print?: boolean;
1794
2000
  /**
1795
- * Instructs the plugin whether to enable mixed module transformations. This
1796
- * is useful in scenarios with modules that contain a mix of ES `import`
1797
- * statements and CommonJS `require` expressions. Set to `true` if `require`
1798
- * calls should be transformed to imports in mixed modules, or `false` if the
1799
- * `require` expressions should survive the transformation. The latter can be
1800
- * important if the code contains environment detection, or you are coding
1801
- * for an environment with special treatment for `require` calls such as
1802
- * ElectronJS. See also the `ignore` option.
1803
- * @default false
2001
+ * Custom shortcuts to run when a key is pressed. These shortcuts take priority
2002
+ * over the default shortcuts if they have the same keys (except the `h` key).
2003
+ * To disable a default shortcut, define the same key but with `action: undefined`.
1804
2004
  */
1805
- transformMixedEsModules?: boolean;
2005
+ customShortcuts?: CLIShortcut<Server>[];
2006
+ };
2007
+ type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
2008
+ key: string;
2009
+ description: string;
2010
+ action?(server: Server): void | Promise<void>;
2011
+ };
2012
+ //#endregion
2013
+ //#region src/node/typeUtils.d.ts
2014
+ type RequiredExceptFor<T, K extends keyof T> = Pick<T, K> & Required<Omit<T, K>>;
2015
+ //#endregion
2016
+ //#region src/node/preview.d.ts
2017
+ interface PreviewOptions extends CommonServerOptions {}
2018
+ interface ResolvedPreviewOptions extends RequiredExceptFor<PreviewOptions, "host" | "https" | "proxy"> {}
2019
+ interface PreviewServer {
1806
2020
  /**
1807
- * By default, this plugin will try to hoist `require` statements as imports
1808
- * to the top of each file. While this works well for many code bases and
1809
- * allows for very efficient ESM output, it does not perfectly capture
1810
- * CommonJS semantics as the order of side effects like log statements may
1811
- * change. But it is especially problematic when there are circular `require`
1812
- * calls between CommonJS modules as those often rely on the lazy execution of
1813
- * nested `require` calls.
1814
- *
1815
- * Setting this option to `true` will wrap all CommonJS files in functions
1816
- * which are executed when they are required for the first time, preserving
1817
- * NodeJS semantics. Note that this can have an impact on the size and
1818
- * performance of the generated code.
1819
- *
1820
- * The default value of `"auto"` will only wrap CommonJS files when they are
1821
- * part of a CommonJS dependency cycle, e.g. an index file that is required by
1822
- * many of its dependencies. All other CommonJS files are hoisted. This is the
1823
- * recommended setting for most code bases.
1824
- *
1825
- * `false` will entirely prevent wrapping and hoist all files. This may still
1826
- * work depending on the nature of cyclic dependencies but will often cause
1827
- * problems.
1828
- *
1829
- * You can also provide a minimatch pattern, or array of patterns, to only
1830
- * specify a subset of files which should be wrapped in functions for proper
1831
- * `require` semantics.
1832
- *
1833
- * `"debug"` works like `"auto"` but after bundling, it will display a warning
1834
- * containing a list of ids that have been wrapped which can be used as
1835
- * minimatch pattern for fine-tuning.
1836
- * @default "auto"
2021
+ * The resolved vite config object
1837
2022
  */
1838
- strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[];
2023
+ config: ResolvedConfig;
1839
2024
  /**
1840
- * Sometimes you have to leave require statements unconverted. Pass an array
1841
- * containing the IDs or a `id => boolean` function.
1842
- * @default []
2025
+ * Stop the server.
1843
2026
  */
1844
- ignore?: ReadonlyArray<string> | ((id: string) => boolean);
2027
+ close(): Promise<void>;
1845
2028
  /**
1846
- * In most cases, where `require` calls are inside a `try-catch` clause,
1847
- * they should be left unconverted as it requires an optional dependency
1848
- * that may or may not be installed beside the rolled up package.
1849
- * Due to the conversion of `require` to a static `import` - the call is
1850
- * hoisted to the top of the file, outside the `try-catch` clause.
1851
- *
1852
- * - `true`: Default. All `require` calls inside a `try` will be left unconverted.
1853
- * - `false`: All `require` calls inside a `try` will be converted as if the
1854
- * `try-catch` clause is not there.
1855
- * - `remove`: Remove all `require` calls from inside any `try` block.
1856
- * - `string[]`: Pass an array containing the IDs to left unconverted.
1857
- * - `((id: string) => boolean|'remove')`: Pass a function that controls
1858
- * individual IDs.
2029
+ * A connect app instance.
2030
+ * - Can be used to attach custom middlewares to the preview server.
2031
+ * - Can also be used as the handler function of a custom http server
2032
+ * or as a middleware in any connect-style Node.js frameworks
1859
2033
  *
1860
- * @default true
2034
+ * https://github.com/senchalabs/connect#use-middleware
1861
2035
  */
1862
- ignoreTryCatch?: boolean | 'remove' | ReadonlyArray<string> | ((id: string) => boolean | 'remove');
2036
+ middlewares: Connect.Server;
1863
2037
  /**
1864
- * Controls how to render imports from external dependencies. By default,
1865
- * this plugin assumes that all external dependencies are CommonJS. This
1866
- * means they are rendered as default imports to be compatible with e.g.
1867
- * NodeJS where ES modules can only import a default export from a CommonJS
1868
- * dependency.
1869
- *
1870
- * If you set `esmExternals` to `true`, this plugin assumes that all
1871
- * external dependencies are ES modules and respect the
1872
- * `requireReturnsDefault` option. If that option is not set, they will be
1873
- * rendered as namespace imports.
1874
- *
1875
- * You can also supply an array of ids to be treated as ES modules, or a
1876
- * function that will be passed each external id to determine whether it is
1877
- * an ES module.
1878
- * @default false
2038
+ * native Node http server instance
1879
2039
  */
1880
- esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean);
2040
+ httpServer: HttpServer;
1881
2041
  /**
1882
- * Controls what is returned when requiring an ES module from a CommonJS file.
1883
- * When using the `esmExternals` option, this will also apply to external
1884
- * modules. By default, this plugin will render those imports as namespace
1885
- * imports i.e.
1886
- *
1887
- * ```js
1888
- * // input
1889
- * const foo = require('foo');
1890
- *
1891
- * // output
1892
- * import * as foo from 'foo';
1893
- * ```
1894
- *
1895
- * However, there are some situations where this may not be desired.
1896
- * For these situations, you can change Rollup's behaviour either globally or
1897
- * per module. To change it globally, set the `requireReturnsDefault` option
1898
- * to one of the following values:
1899
- *
1900
- * - `false`: This is the default, requiring an ES module returns its
1901
- * namespace. This is the only option that will also add a marker
1902
- * `__esModule: true` to the namespace to support interop patterns in
1903
- * CommonJS modules that are transpiled ES modules.
1904
- * - `"namespace"`: Like `false`, requiring an ES module returns its
1905
- * namespace, but the plugin does not add the `__esModule` marker and thus
1906
- * creates more efficient code. For external dependencies when using
1907
- * `esmExternals: true`, no additional interop code is generated.
1908
- * - `"auto"`: This is complementary to how `output.exports: "auto"` works in
1909
- * Rollup: If a module has a default export and no named exports, requiring
1910
- * that module returns the default export. In all other cases, the namespace
1911
- * is returned. For external dependencies when using `esmExternals: true`, a
1912
- * corresponding interop helper is added.
1913
- * - `"preferred"`: If a module has a default export, requiring that module
1914
- * always returns the default export, no matter whether additional named
1915
- * exports exist. This is similar to how previous versions of this plugin
1916
- * worked. Again for external dependencies when using `esmExternals: true`,
1917
- * an interop helper is added.
1918
- * - `true`: This will always try to return the default export on require
1919
- * without checking if it actually exists. This can throw at build time if
1920
- * there is no default export. This is how external dependencies are handled
1921
- * when `esmExternals` is not used. The advantage over the other options is
1922
- * that, like `false`, this does not add an interop helper for external
1923
- * dependencies, keeping the code lean.
1924
- *
1925
- * To change this for individual modules, you can supply a function for
1926
- * `requireReturnsDefault` instead. This function will then be called once for
1927
- * each required ES module or external dependency with the corresponding id
1928
- * and allows you to return different values for different modules.
1929
- * @default false
2042
+ * The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
2043
+ * if the server is not listening on any port.
1930
2044
  */
1931
- requireReturnsDefault?: boolean | 'auto' | 'preferred' | 'namespace' | ((id: string) => boolean | 'auto' | 'preferred' | 'namespace');
2045
+ resolvedUrls: ResolvedServerUrls | null;
1932
2046
  /**
1933
- * @default "auto"
2047
+ * Print server urls
1934
2048
  */
1935
- defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto');
2049
+ printUrls(): void;
1936
2050
  /**
1937
- * Some modules contain dynamic `require` calls, or require modules that
1938
- * contain circular dependencies, which are not handled well by static
1939
- * imports. Including those modules as `dynamicRequireTargets` will simulate a
1940
- * CommonJS (NodeJS-like) environment for them with support for dynamic
1941
- * dependencies. It also enables `strictRequires` for those modules.
1942
- *
1943
- * Note: In extreme cases, this feature may result in some paths being
1944
- * rendered as absolute in the final bundle. The plugin tries to avoid
1945
- * exposing paths from the local machine, but if you are `dynamicRequirePaths`
1946
- * with paths that are far away from your project's folder, that may require
1947
- * replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
1948
- */
1949
- dynamicRequireTargets?: string | ReadonlyArray<string>;
1950
- /**
1951
- * To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
1952
- * that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
1953
- * may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
1954
- * home directory name. By default, it uses the current working directory.
2051
+ * Bind CLI shortcuts
1955
2052
  */
1956
- dynamicRequireRoot?: string;
2053
+ bindCLIShortcuts(options?: BindCLIShortcutsOptions<PreviewServer>): void;
1957
2054
  }
2055
+ type PreviewServerHook = (this: MinimalPluginContextWithoutEnvironment, server: PreviewServer) => (() => void) | void | Promise<(() => void) | void>;
2056
+ type ClosePreviewServerHook = (this: MinimalPluginContextWithoutEnvironment) => void | Promise<void>;
2057
+ /**
2058
+ * Starts the Vite server in preview mode, to simulate a production deployment
2059
+ */
2060
+ export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewServer>;
1958
2061
  //#endregion
1959
- //#region src/types/dynamicImportVars.d.ts
1960
- interface RollupDynamicImportVarsOptions {
1961
- /**
1962
- * Files to include in this plugin (default all).
1963
- * @default []
1964
- */
1965
- include?: string | RegExp | (string | RegExp)[];
1966
- /**
1967
- * Files to exclude in this plugin (default none).
1968
- * @default []
1969
- */
1970
- exclude?: string | RegExp | (string | RegExp)[];
2062
+ //#region src/node/plugin.d.ts
2063
+ /**
2064
+ * Vite plugins extends the Rollup plugin interface with a few extra
2065
+ * vite-specific options. A valid vite plugin is also a valid Rollup plugin.
2066
+ * On the contrary, a Rollup plugin may or may NOT be a valid vite universal
2067
+ * plugin, since some Rollup features do not make sense in an unbundled
2068
+ * dev server context. That said, as long as a rollup plugin doesn't have strong
2069
+ * coupling between its bundle phase and output phase hooks then it should
2070
+ * just work (that means, most of them).
2071
+ *
2072
+ * By default, the plugins are run during both serve and build. When a plugin
2073
+ * is applied during serve, it will only run **non output plugin hooks** (see
2074
+ * rollup type definition of {@link rollup#PluginHooks}). You can think of the
2075
+ * dev server as only running `const bundle = rollup.rollup()` but never calling
2076
+ * `bundle.generate()`.
2077
+ *
2078
+ * A plugin that expects to have different behavior depending on serve/build can
2079
+ * export a factory function that receives the command being run via options.
2080
+ *
2081
+ * If a plugin should be applied only for server or build, a function format
2082
+ * config file can be used to conditional determine the plugins to use.
2083
+ *
2084
+ * The current environment can be accessed from the context for the all non-global
2085
+ * hooks (it is not available in config, configResolved, configureServer, etc).
2086
+ * It can be a dev, build, or scan environment.
2087
+ * Plugins can use this.environment.mode === 'dev' to guard for dev specific APIs.
2088
+ */
2089
+ interface PluginContextExtension {
1971
2090
  /**
1972
- * @deprecated This option is no-op and will be removed in future versions.
2091
+ * Vite-specific environment instance
1973
2092
  */
1974
- warnOnError?: boolean;
2093
+ environment: Environment;
1975
2094
  }
1976
- //#endregion
1977
- //#region src/node/plugins/terser.d.ts
1978
- interface TerserOptions extends TerserMinifyOptions {
2095
+ interface PluginContextMetaExtension {
2096
+ viteVersion: string;
2097
+ }
2098
+ interface ConfigPluginContext extends Omit<MinimalPluginContext, "meta" | "environment"> {
2099
+ meta: Omit<PluginContextMeta, "watchMode">;
2100
+ }
2101
+ interface MinimalPluginContextWithoutEnvironment extends Omit<MinimalPluginContext, "environment"> {}
2102
+ declare module "rolldown" {
2103
+ interface MinimalPluginContext extends PluginContextExtension {}
2104
+ interface PluginContextMeta extends PluginContextMetaExtension {}
2105
+ }
2106
+ /**
2107
+ * There are two types of plugins in Vite. App plugins and environment plugins.
2108
+ * Environment Plugins are defined by a constructor function that will be called
2109
+ * once per each environment allowing users to have completely different plugins
2110
+ * for each of them. The constructor gets the resolved environment after the server
2111
+ * and builder has already been created simplifying config access and cache
2112
+ * management for environment specific plugins.
2113
+ * Environment Plugins are closer to regular rollup plugins. They can't define
2114
+ * app level hooks (like config, configResolved, configureServer, etc).
2115
+ */
2116
+ interface Plugin<A = any> extends Rolldown.Plugin<A> {
1979
2117
  /**
1980
- * Vite-specific option to specify the max number of workers to spawn
1981
- * when minifying files with terser.
2118
+ * Perform custom handling of HMR updates.
2119
+ * The handler receives an options containing changed filename, timestamp, a
2120
+ * list of modules affected by the file change, and the dev server instance.
1982
2121
  *
1983
- * @default number of CPUs minus 1
2122
+ * - The hook can return a filtered list of modules to narrow down the update.
2123
+ * e.g. for a Vue SFC, we can narrow down the part to update by comparing
2124
+ * the descriptors.
2125
+ *
2126
+ * - The hook can also return an empty array and then perform custom updates
2127
+ * by sending a custom hmr payload via environment.hot.send().
2128
+ *
2129
+ * - If the hook doesn't return a value, the hmr update will be performed as
2130
+ * normal.
1984
2131
  */
1985
- maxWorkers?: number;
1986
- }
1987
- //#endregion
1988
- //#region src/node/plugins/resolve.d.ts
1989
- interface EnvironmentResolveOptions {
2132
+ hotUpdate?: ObjectHook<(this: MinimalPluginContext & {
2133
+ environment: DevEnvironment;
2134
+ }, options: HotUpdateOptions) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
1990
2135
  /**
1991
- * @default ['browser', 'module', 'jsnext:main', 'jsnext']
2136
+ * extend hooks with ssr flag
1992
2137
  */
1993
- mainFields?: string[];
1994
- conditions?: string[];
1995
- externalConditions?: string[];
2138
+ resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
2139
+ kind?: ImportKind;
2140
+ custom?: CustomPluginOptions;
2141
+ ssr?: boolean | undefined;
2142
+
2143
+ isEntry: boolean;
2144
+ }) => Promise<ResolveIdResult> | ResolveIdResult, {
2145
+ filter?: {
2146
+ id?: StringFilter<RegExp>;
2147
+ };
2148
+ }>;
2149
+ load?: ObjectHook<(this: PluginContext, id: string, options?: {
2150
+ ssr?: boolean | undefined;
2151
+ }) => Promise<LoadResult> | LoadResult, {
2152
+ filter?: {
2153
+ id?: StringFilter;
2154
+ };
2155
+ }>;
2156
+ transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
2157
+ moduleType: ModuleType;
2158
+ ssr?: boolean | undefined;
2159
+ }) => Promise<Rolldown.TransformResult> | Rolldown.TransformResult, {
2160
+ filter?: {
2161
+ id?: StringFilter;
2162
+ code?: StringFilter;
2163
+ moduleType?: ModuleTypeFilter;
2164
+ };
2165
+ }>;
1996
2166
  /**
1997
- * @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
2167
+ * Opt-in this plugin into the shared plugins pipeline.
2168
+ * For backward-compatibility, plugins are re-recreated for each environment
2169
+ * during `vite build --app`
2170
+ * We have an opt-in per plugin, and a general `builder.sharedPlugins`
2171
+ * In a future major, we'll flip the default to be shared by default
2172
+ * @experimental
1998
2173
  */
1999
- extensions?: string[];
2000
- dedupe?: string[];
2174
+ sharedDuringBuild?: boolean;
2001
2175
  /**
2002
- * Prevent listed dependencies from being externalized and will get bundled in build.
2003
- * Only works in server environments for now. Previously this was `ssr.noExternal`.
2176
+ * Opt-in this plugin into per-environment buildStart and buildEnd during dev.
2177
+ * For backward-compatibility, the buildStart hook is called only once during
2178
+ * dev, for the client environment. Plugins can opt-in to be called
2179
+ * per-environment, aligning with the build hook behavior.
2004
2180
  * @experimental
2005
2181
  */
2006
- noExternal?: string | RegExp | (string | RegExp)[] | true;
2182
+ perEnvironmentStartEndDuringDev?: boolean;
2007
2183
  /**
2008
- * Externalize the given dependencies and their transitive dependencies.
2009
- * Only works in server environments for now. Previously this was `ssr.external`.
2184
+ * Opt-in this plugin into per-environment watchChange during dev.
2185
+ * For backward-compatibility, the watchChange hook is called only once during
2186
+ * dev, for the client environment. Plugins can opt-in to be called
2187
+ * per-environment, aligning with the watchChange hook behavior.
2010
2188
  * @experimental
2011
2189
  */
2012
- external?: string[] | true;
2190
+ perEnvironmentWatchChangeDuringDev?: boolean;
2013
2191
  /**
2014
- * Array of strings or regular expressions that indicate what modules are builtin for the environment.
2192
+ * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
2193
+ * is still subject to the `order` property in the hook object.
2194
+ *
2195
+ * Plugin invocation order:
2196
+ * - alias resolution
2197
+ * - `enforce: 'pre'` plugins
2198
+ * - vite core plugins
2199
+ * - normal plugins
2200
+ * - vite build plugins
2201
+ * - `enforce: 'post'` plugins
2202
+ * - vite build post plugins
2015
2203
  */
2016
- builtins?: (string | RegExp)[];
2017
- }
2018
- interface ResolveOptions extends EnvironmentResolveOptions {
2204
+ enforce?: "pre" | "post";
2019
2205
  /**
2020
- * @default false
2206
+ * Apply the plugin only for serve or build, or on certain conditions.
2021
2207
  */
2022
- preserveSymlinks?: boolean;
2208
+ apply?: "serve" | "build" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean);
2023
2209
  /**
2024
- * Enable tsconfig paths resolution
2210
+ * Define environments where this plugin should be active
2211
+ * By default, the plugin is active in all environments
2212
+ * @experimental
2213
+ */
2214
+ applyToEnvironment?: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption;
2215
+ /**
2216
+ * Modify vite config before it's resolved. The hook can either mutate the
2217
+ * passed-in config directly, or return a partial config object that will be
2218
+ * deeply merged into existing config.
2025
2219
  *
2026
- * @default false
2220
+ * Note: User plugins are resolved before running this hook so injecting other
2221
+ * plugins inside the `config` hook will have no effect.
2027
2222
  */
2028
- tsconfigPaths?: boolean;
2029
- }
2030
- interface ResolvePluginOptions {
2031
- root: string;
2032
- isBuild: boolean;
2033
- isProduction: boolean;
2034
- packageCache?: PackageCache;
2223
+ config?: ObjectHook<(this: ConfigPluginContext, config: UserConfig, env: ConfigEnv) => Omit<UserConfig, "plugins"> | null | void | Promise<Omit<UserConfig, "plugins"> | null | void>>;
2035
2224
  /**
2036
- * src code mode also attempts the following:
2037
- * - resolving /xxx as URLs
2038
- * - resolving bare imports from optimized deps
2225
+ * Modify environment configs before it's resolved. The hook can either mutate the
2226
+ * passed-in environment config directly, or return a partial config object that will be
2227
+ * deeply merged into existing config.
2228
+ * This hook is called for each environment with a partially resolved environment config
2229
+ * that already accounts for the default environment config values set at the root level.
2230
+ * If plugins need to modify the config of a given environment, they should do it in this
2231
+ * hook instead of the config hook. Leaving the config hook only for modifying the root
2232
+ * default environment config.
2039
2233
  */
2040
- asSrc?: boolean;
2041
- tryIndex?: boolean;
2042
- tryPrefix?: string;
2043
- preferRelative?: boolean;
2044
- isRequire?: boolean;
2045
- scan?: boolean;
2234
+ configEnvironment?: ObjectHook<(this: ConfigPluginContext, name: string, config: EnvironmentOptions, env: ConfigEnv & {
2235
+ /**
2236
+ * Whether this environment is SSR environment and `ssr.target` is set to `'webworker'`.
2237
+ * Only intended to be used for backward compatibility.
2238
+ */
2239
+ isSsrTargetWebworker?: boolean;
2240
+ }) => EnvironmentOptions | null | void | Promise<EnvironmentOptions | null | void>>;
2046
2241
  /**
2047
- * Enable when `legacy.inconsistentCjsInterop` is true. See that option for more details.
2242
+ * Use this hook to read and store the final resolved vite config.
2048
2243
  */
2049
- legacyInconsistentCjsInterop?: boolean;
2050
- }
2051
- interface InternalResolveOptions extends Required<ResolveOptions>, ResolvePluginOptions {}
2052
- //#endregion
2053
- //#region src/node/packages.d.ts
2054
- /** Cache for package.json resolution and package.json contents */
2055
- type PackageCache = Map<string, PackageData>;
2056
- interface PackageData {
2057
- dir: string;
2058
- hasSideEffects: (id: string) => boolean | "no-treeshake" | null;
2059
- setResolvedCache: (key: string, entry: string, options: InternalResolveOptions) => void;
2060
- getResolvedCache: (key: string, options: InternalResolveOptions) => string | undefined;
2061
- data: {
2062
- [field: string]: any;
2063
- name: string;
2064
- type: string;
2065
- version: string;
2066
- main: string;
2067
- module: string;
2068
- browser: string | Record<string, string | false>;
2069
- exports: string | Record<string, any> | string[];
2070
- imports: Record<string, any>;
2071
- dependencies: Record<string, string>;
2072
- };
2073
- }
2074
- //#endregion
2075
- //#region src/node/plugins/license.d.ts
2076
- interface LicenseOptions {
2244
+ configResolved?: ObjectHook<(this: MinimalPluginContextWithoutEnvironment, config: ResolvedConfig) => void | Promise<void>>;
2077
2245
  /**
2078
- * The output file name of the license file relative to the output directory.
2079
- * Specify a path that ends with `.json` to output the raw JSON metadata.
2246
+ * Configure the vite server. The hook receives the {@link ViteDevServer}
2247
+ * instance. This can also be used to store a reference to the server
2248
+ * for use in other hooks.
2080
2249
  *
2081
- * @default '.vite/license.md'
2250
+ * The hooks will be called before internal middlewares are applied. A hook
2251
+ * can return a post hook that will be called after internal middlewares
2252
+ * are applied. Hook can be async functions and will be called in series.
2082
2253
  */
2083
- fileName: string;
2084
- }
2085
- //#endregion
2086
- //#region src/node/build.d.ts
2087
- interface BuildEnvironmentOptions {
2254
+ configureServer?: ObjectHook<ServerHook>;
2088
2255
  /**
2089
- * Compatibility transform target. The transform is performed with esbuild
2090
- * and the lowest supported target is es2015. Note this only handles
2091
- * syntax transformation and does not cover polyfills
2092
- *
2093
- * Default: 'baseline-widely-available' - transpile targeting browsers that
2094
- * are included in the Baseline Widely Available on 2026-01-01.
2095
- * (Chrome 111+, Edge 111+, Firefox 114+, Safari 16.4+).
2096
- *
2097
- * Another special value is 'esnext' - which only performs minimal transpiling
2098
- * (for minification compat).
2256
+ * Configure the preview server. The hook receives the {@link PreviewServer}
2257
+ * instance. This can also be used to store a reference to the server
2258
+ * for use in other hooks.
2099
2259
  *
2100
- * For custom targets, see https://esbuild.github.io/api/#target and
2101
- * https://esbuild.github.io/content-types/#javascript for more details.
2102
- * @default 'baseline-widely-available'
2103
- */
2104
- target?: "baseline-widely-available" | EsbuildTarget | false;
2105
- /**
2106
- * whether to inject module preload polyfill.
2107
- * Note: does not apply to library mode.
2108
- * @default true
2109
- * @deprecated use `modulePreload.polyfill` instead
2110
- */
2111
- polyfillModulePreload?: boolean;
2112
- /**
2113
- * Configure module preload
2114
- * Note: does not apply to library mode.
2115
- * @default true
2116
- */
2117
- modulePreload?: boolean | ModulePreloadOptions;
2118
- /**
2119
- * Directory relative from `root` where build output will be placed. If the
2120
- * directory exists, it will be removed before the build.
2121
- * @default 'dist'
2122
- */
2123
- outDir?: string;
2124
- /**
2125
- * Directory relative from `outDir` where the built js/css/image assets will
2126
- * be placed.
2127
- * @default 'assets'
2260
+ * The hooks are called before other middlewares are applied. A hook can
2261
+ * return a post hook that will be called after other middlewares are
2262
+ * applied. Hooks can be async functions and will be called in series.
2128
2263
  */
2129
- assetsDir?: string;
2264
+ configurePreviewServer?: ObjectHook<PreviewServerHook>;
2130
2265
  /**
2131
- * Static asset files smaller than this number (in bytes) will be inlined as
2132
- * base64 strings. If a callback is passed, a boolean can be returned to opt-in
2133
- * or opt-out of inlining. If nothing is returned the default logic applies.
2266
+ * Run logic when the server is restarted or closed. The hook receives a
2267
+ * `reason` that is `'restart'` when the server is restarting and `'close'`
2268
+ * when it is closing.
2134
2269
  *
2135
- * Default limit is `4096` (4 KiB). Set to `0` to disable.
2136
- * @default 4096
2270
+ * The hooks are called after the server is torn down. Hooks can be async
2271
+ * functions and will be called in parallel.
2137
2272
  */
2138
- assetsInlineLimit?: number | ((filePath: string, content: Buffer) => boolean | undefined);
2273
+ closeServer?: ObjectHook<CloseServerHook>;
2139
2274
  /**
2140
- * Whether to code-split CSS. When enabled, CSS in async chunks will be
2141
- * inlined as strings in the chunk and inserted via dynamically created
2142
- * style tags when the chunk is loaded.
2143
- * @default true
2275
+ * Same as `closeServer` but for the preview server. The preview server never
2276
+ * restarts, so no `reason` is provided.
2144
2277
  */
2145
- cssCodeSplit?: boolean;
2278
+ closePreviewServer?: ObjectHook<ClosePreviewServerHook>;
2146
2279
  /**
2147
- * An optional separate target for CSS minification.
2148
- * As esbuild only supports configuring targets to mainstream
2149
- * browsers, users may need this option when they are targeting
2150
- * a niche browser that comes with most modern JavaScript features
2151
- * but has poor CSS support, e.g. Android WeChat WebView, which
2152
- * doesn't support the #RGBA syntax.
2153
- * When `build.cssMinify` is `lightningcss` (the default), this
2154
- * option takes precedence over `css.lightningcss.targets` for the
2155
- * minification step.
2156
- * @default target
2157
- */
2158
- cssTarget?: EsbuildTarget | false;
2159
- /**
2160
- * Override CSS minification specifically instead of defaulting to `build.minify`,
2161
- * so you can configure minification for JS and CSS separately.
2162
- * @default 'lightningcss', but false if build.minify is disabled for client build
2163
- */
2164
- cssMinify?: boolean | "lightningcss" | "esbuild";
2165
- /**
2166
- * If `true`, a separate sourcemap file will be created. If 'inline', the
2167
- * sourcemap will be appended to the resulting output file as data URI.
2168
- * 'hidden' works like `true` except that the corresponding sourcemap
2169
- * comments in the bundled files are suppressed.
2170
- * @default false
2171
- */
2172
- sourcemap?: boolean | "inline" | "hidden";
2173
- /**
2174
- * Set to `false` to disable minification, or specify the minifier to use.
2175
- * Available options are 'oxc' or 'terser' or 'esbuild'.
2176
- * @default 'oxc' for client build, false for SSR build
2177
- */
2178
- minify?: boolean | "oxc" | "terser" | "esbuild";
2179
- /**
2180
- * Options for terser
2181
- * https://terser.org/docs/api-reference#minify-options
2280
+ * Transform index.html.
2281
+ * The hook receives the following arguments:
2182
2282
  *
2183
- * In addition, you can also pass a `maxWorkers: number` option to specify the
2184
- * max number of workers to spawn. Defaults to the number of CPUs minus 1.
2185
- */
2186
- terserOptions?: TerserOptions;
2187
- /**
2188
- * Whether to use import maps feature to optimize chunk caching efficiency.
2189
- * @default false
2190
- * @experimental
2191
- */
2192
- chunkImportMap?: boolean;
2193
- /**
2194
- * Alias to `rolldownOptions`
2195
- * @deprecated Use `rolldownOptions` instead.
2196
- */
2197
- rollupOptions?: RolldownOptions;
2198
- /**
2199
- * Will be merged with internal rolldown options.
2200
- * https://rolldown.rs/reference/Interface.RolldownOptions
2201
- */
2202
- rolldownOptions?: RolldownOptions;
2203
- /**
2204
- * Options to pass on to `@rollup/plugin-commonjs`
2205
- * @deprecated This option is no-op and will be removed in future versions.
2206
- */
2207
- commonjsOptions?: RollupCommonJSOptions;
2208
- /**
2209
- * Options to pass on to `@rollup/plugin-dynamic-import-vars`
2210
- */
2211
- dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
2212
- /**
2213
- * Whether to write bundle to disk
2214
- * @default true
2215
- */
2216
- write?: boolean;
2217
- /**
2218
- * Empty outDir on write.
2219
- * @default true when outDir is a sub directory of project root
2220
- */
2221
- emptyOutDir?: boolean | null;
2222
- /**
2223
- * Copy the public directory to outDir on write.
2224
- * @default true
2225
- */
2226
- copyPublicDir?: boolean;
2227
- /**
2228
- * Whether to emit a `.vite/license.md` file that includes all bundled dependencies'
2229
- * licenses. Pass an object to customize the output file name.
2230
- * @default false
2231
- */
2232
- license?: boolean | LicenseOptions;
2233
- /**
2234
- * Whether to emit a .vite/manifest.json in the output dir to map hash-less filenames
2235
- * to their hashed versions. Useful when you want to generate your own HTML
2236
- * instead of using the one generated by Vite.
2283
+ * - html: string
2284
+ * - ctx: IndexHtmlTransformContext, which contains:
2285
+ * - path: public path when served
2286
+ * - filename: filename on disk
2287
+ * - server?: ViteDevServer (only present during serve)
2288
+ * - bundle?: rollup.OutputBundle (only present during build)
2289
+ * - chunk?: rollup.OutputChunk
2290
+ * - originalUrl?: string
2237
2291
  *
2238
- * Example:
2292
+ * It can either return a transformed string, or a list of html tag
2293
+ * descriptors that will be injected into the `<head>` or `<body>`.
2239
2294
  *
2240
- * ```json
2241
- * {
2242
- * "main.js": {
2243
- * "file": "main.68fe3fad.js",
2244
- * "css": "main.e6b63442.css",
2245
- * "imports": [...],
2246
- * "dynamicImports": [...]
2247
- * }
2248
- * }
2249
- * ```
2250
- * @default false
2251
- */
2252
- manifest?: boolean | string;
2253
- /**
2254
- * Build in library mode. The value should be the global name of the lib in
2255
- * UMD mode. This will produce esm + cjs + umd bundle formats with default
2256
- * configurations that are suitable for distributing libraries.
2257
- * @default false
2258
- */
2259
- lib?: LibraryOptions | false;
2260
- /**
2261
- * Produce SSR oriented build. Note this requires specifying SSR entry via
2262
- * `rolldownOptions.input`.
2263
- * @default false
2264
- */
2265
- ssr?: boolean | string;
2266
- /**
2267
- * Generate SSR manifest for determining style links and asset preload
2268
- * directives in production.
2269
- * @default false
2270
- */
2271
- ssrManifest?: boolean | string;
2272
- /**
2273
- * Emit assets during SSR.
2274
- * @default false
2275
- */
2276
- ssrEmitAssets?: boolean;
2277
- /**
2278
- * Emit assets during build. Frameworks can set environments.ssr.build.emitAssets
2279
- * By default, it is true for the client and false for other environments.
2280
- */
2281
- emitAssets?: boolean;
2282
- /**
2283
- * Set to false to disable reporting compressed chunk sizes.
2284
- * Can slightly improve build speed.
2285
- * @default true
2286
- */
2287
- reportCompressedSize?: boolean;
2288
- /**
2289
- * Adjust chunk size warning limit (in kB).
2290
- * @default 500
2291
- */
2292
- chunkSizeWarningLimit?: number;
2293
- /**
2294
- * Rollup watch options
2295
- * https://rollupjs.org/configuration-options/#watch
2296
- * @default null
2297
- */
2298
- watch?: WatcherOptions | null;
2299
- /**
2300
- * create the Build Environment instance
2301
- */
2302
- createEnvironment?: (name: string, config: ResolvedConfig) => Promise<BuildEnvironment> | BuildEnvironment;
2303
- }
2304
- type BuildOptions = BuildEnvironmentOptions;
2305
- interface LibraryOptions {
2306
- /**
2307
- * Path of library entry.
2308
- * Defaults to the top-level `input` option when omitted.
2309
- */
2310
- entry?: InputOption;
2311
- /**
2312
- * The name of the exposed global variable. Required when the `formats` option includes
2313
- * `umd` or `iife`
2314
- */
2315
- name?: string;
2316
- /**
2317
- * Output bundle formats. Defaults to `['es', 'umd']` for a single entry, or
2318
- * `['es', 'cjs']` for multiple entries (`umd` and `iife` do not support
2319
- * multiple entries).
2320
- * @default ['es', 'umd']
2321
- */
2322
- formats?: LibraryFormats[];
2323
- /**
2324
- * The name of the package file output. The default file name is the name option
2325
- * of the project package.json. It can also be defined as a function taking the
2326
- * format as an argument.
2327
- */
2328
- fileName?: string | ((format: ModuleFormat, entryName: string) => string);
2329
- /**
2330
- * The name of the CSS file output if the library imports CSS. Defaults to the
2331
- * same value as `build.lib.fileName` if it's set a string, otherwise it falls
2332
- * back to the name option of the project package.json.
2333
- */
2334
- cssFileName?: string;
2335
- }
2336
- type LibraryFormats = "es" | "cjs" | "umd" | "iife";
2337
- interface ModulePreloadOptions {
2338
- /**
2339
- * Whether to inject a module preload polyfill.
2340
- * Note: does not apply to library mode.
2341
- * @default true
2295
+ * By default the transform is applied **after** vite's internal html
2296
+ * transform. If you need to apply the transform before vite, use an object:
2297
+ * `{ order: 'pre', handler: hook }`
2342
2298
  */
2343
- polyfill?: boolean;
2299
+ transformIndexHtml?: IndexHtmlTransform;
2344
2300
  /**
2345
- * Resolve the list of dependencies to preload for a given dynamic import
2301
+ * Build Environments
2302
+ *
2346
2303
  * @experimental
2347
2304
  */
2348
- resolveDependencies?: ResolveModulePreloadDependenciesFn;
2349
- }
2350
- interface ResolvedModulePreloadOptions {
2351
- polyfill: boolean;
2352
- resolveDependencies?: ResolveModulePreloadDependenciesFn;
2353
- }
2354
- type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: {
2355
- hostId: string;
2356
- hostType: "html" | "js";
2357
- }) => string[];
2358
- interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, "polyfillModulePreload">> {
2359
- modulePreload: false | ResolvedModulePreloadOptions;
2360
- }
2361
- interface ResolvedBuildOptions extends Required<Omit<BuildOptions, "polyfillModulePreload">> {
2362
- modulePreload: false | ResolvedModulePreloadOptions;
2363
- }
2364
- /**
2365
- * Bundles a single environment for production.
2366
- * Returns a Promise containing the build result.
2367
- */
2368
- export declare function build(inlineConfig?: InlineConfig): Promise<RolldownOutput | RolldownOutput[] | RolldownWatcher>;
2369
- type RenderBuiltAssetUrl = (filename: string, type: {
2370
- type: "asset" | "public";
2371
- hostId: string;
2372
- hostType: "js" | "css" | "html";
2373
- ssr: boolean;
2374
- }) => string | {
2375
- relative?: boolean;
2376
- runtime?: string;
2377
- } | undefined;
2378
- export declare class BuildEnvironment extends BaseEnvironment {
2379
- mode: "build";
2380
- isBuilt: boolean;
2381
- constructor(name: string, config: ResolvedConfig, setup?: {
2382
- options?: EnvironmentOptions;
2383
- });
2384
- init(): Promise<void>;
2385
- }
2386
- interface ViteBuilder {
2387
- environments: Record<string, BuildEnvironment>;
2388
- config: ResolvedConfig;
2389
- buildApp(): Promise<void>;
2390
- build(environment: BuildEnvironment): Promise<RolldownOutput | RolldownOutput[] | RolldownWatcher>;
2391
- runDevTools(): Promise<void>;
2392
- }
2393
- interface BuilderOptions {
2305
+ buildApp?: ObjectHook<BuildAppHook>;
2394
2306
  /**
2395
- * Whether to share the config instance among environments to align with the behavior of dev server.
2307
+ * Perform custom handling of HMR updates.
2308
+ * The handler receives a context containing changed filename, timestamp, a
2309
+ * list of modules affected by the file change, and the dev server instance.
2396
2310
  *
2397
- * @default false
2398
- * @experimental
2311
+ * - The hook can return a filtered list of modules to narrow down the update.
2312
+ * e.g. for a Vue SFC, we can narrow down the part to update by comparing
2313
+ * the descriptors.
2314
+ *
2315
+ * - The hook can also return an empty array and then perform custom updates
2316
+ * by sending a custom hmr payload via server.ws.send().
2317
+ *
2318
+ * - If the hook doesn't return a value, the hmr update will be performed as
2319
+ * normal.
2399
2320
  */
2400
- sharedConfigBuild?: boolean;
2321
+ handleHotUpdate?: ObjectHook<(this: MinimalPluginContextWithoutEnvironment, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
2401
2322
  /**
2402
- * Whether to share the plugin instances among environments to align with the behavior of dev server.
2323
+ * This hook is not supported by Rolldown yet. But the type is declared for compatibility.
2403
2324
  *
2404
- * @default false
2405
- * @experimental
2325
+ * @deprecated This hook is **not** deprecated. It is marked as deprecated just to make it clear that this hook is currently a no-op.
2406
2326
  */
2407
- sharedPlugins?: boolean;
2408
- buildApp?: (builder: ViteBuilder) => Promise<void>;
2409
- }
2410
- type ResolvedBuilderOptions = Required<BuilderOptions>;
2411
- /**
2412
- * Creates a ViteBuilder to orchestrate building multiple environments.
2413
- * @experimental
2414
- */
2415
- export declare function createBuilder(inlineConfig?: InlineConfig, useLegacyBuilder?: null | boolean): Promise<ViteBuilder>;
2416
- type BuildAppHook = (this: MinimalPluginContextWithoutEnvironment, builder: ViteBuilder) => Promise<void>;
2417
- //#endregion
2418
- //#region src/node/environment.d.ts
2419
- type Environment = DevEnvironment | BuildEnvironment | ScanEnvironment | UnknownEnvironment;
2420
- /**
2421
- * Creates a function that hides the complexities of a WeakMap with an initial value
2422
- * to implement object metadata. Used by plugins to implement cross hooks per
2423
- * environment metadata
2424
- *
2425
- * @experimental
2426
- */
2427
- export declare function perEnvironmentState<State>(initial: (environment: Environment) => State): (context: PluginContext) => State;
2428
- //#endregion
2429
- //#region src/node/server/pluginContainer.d.ts
2430
- type SkipInformation = {
2431
- id: string;
2432
- importer: string | undefined;
2433
- plugin: Plugin;
2434
- called?: boolean;
2435
- };
2436
- declare class EnvironmentPluginContainer<Env extends Environment = Environment> {
2437
- private _pluginContextMap;
2438
- private _resolvedRolldownOptions?;
2439
- private _processesing;
2440
- private _seenResolves;
2441
- private _moduleNodeToLoadAddedImports;
2442
- getSortedPluginHooks: PluginHookUtils["getSortedPluginHooks"];
2443
- getSortedPlugins: PluginHookUtils["getSortedPlugins"];
2444
- moduleGraph: EnvironmentModuleGraph | undefined;
2445
- watchFiles: Set<string>;
2446
- minimalContext: MinimalPluginContext$1<Env>;
2447
- private _started;
2448
- private _buildStartPromise;
2449
- private _closed;
2450
- private _updateModuleLoadAddedImports;
2451
- private _getAddedImports;
2452
- getModuleInfo(id: string): ModuleInfo | null;
2453
- private handleHookPromise;
2454
- get options(): InputOptions;
2455
- resolveRolldownOptions(): Promise<InputOptions>;
2456
- private _getPluginContext;
2457
- private hookParallel;
2458
- buildStart(_options?: InputOptions): Promise<void>;
2459
- resolveId(rawId: string, importer?: string | undefined, options?: {
2460
- kind?: ImportKind;
2461
- attributes?: Record<string, string>;
2462
- custom?: CustomPluginOptions;
2463
- /** @deprecated use `skipCalls` instead */
2464
- skip?: Set<Plugin>;
2465
- skipCalls?: readonly SkipInformation[];
2466
-
2467
- isEntry?: boolean;
2468
- }): Promise<PartialResolvedId | null>;
2469
- load(id: string): Promise<LoadResult | null>;
2470
- transform(code: string, id: string, options?: {
2471
- inMap?: SourceDescription["map"];
2472
- moduleType?: string;
2473
- }): Promise<{
2474
- code: string;
2475
- map: SourceMap | {
2476
- mappings: "";
2477
- } | null;
2478
- moduleType?: ModuleType;
2479
- }>;
2480
- watchChange(id: string, change: {
2481
- event: "create" | "update" | "delete";
2482
- }): Promise<void>;
2483
- close(): Promise<void>;
2484
- }
2485
- declare class BasicMinimalPluginContext<Meta = PluginContextMeta> {
2486
- meta: Meta;
2487
- private _logger;
2488
- constructor(meta: Meta, _logger: Logger);
2489
- get pluginName(): string;
2490
- debug(rawLog: string | RollupLog | (() => string | RollupLog)): void;
2491
- info(rawLog: string | RollupLog | (() => string | RollupLog)): void;
2492
- warn(rawLog: string | RollupLog | (() => string | RollupLog)): void;
2493
- error(e: string | RollupError): never;
2494
- private _normalizeRawLog;
2495
- }
2496
- declare class MinimalPluginContext$1<T extends Environment = Environment> extends BasicMinimalPluginContext implements MinimalPluginContext {
2497
- environment: T;
2498
- constructor(meta: PluginContextMeta, environment: T);
2499
- }
2500
- declare class PluginContainer {
2501
- private environments;
2502
- constructor(environments: Record<string, Environment>);
2503
- private _getEnvironment;
2504
- private _getPluginContainer;
2505
- getModuleInfo(id: string): ModuleInfo | null;
2506
- get options(): InputOptions;
2507
- buildStart(_options?: InputOptions): Promise<void>;
2508
- watchChange(id: string, change: {
2509
- event: "create" | "update" | "delete";
2510
- }): Promise<void>;
2511
- resolveId(rawId: string, importer?: string, options?: {
2512
- attributes?: Record<string, string>;
2513
- custom?: CustomPluginOptions;
2514
- /** @deprecated use `skipCalls` instead */
2515
- skip?: Set<Plugin>;
2516
- skipCalls?: readonly SkipInformation[];
2517
- ssr?: boolean;
2518
-
2519
- isEntry?: boolean;
2520
- }): Promise<PartialResolvedId | null>;
2521
- load(id: string, options?: {
2522
- ssr?: boolean;
2523
- }): Promise<LoadResult | null>;
2524
- transform(code: string, id: string, options?: {
2525
- ssr?: boolean;
2526
- environment?: Environment;
2527
- inMap?: SourceDescription["map"];
2528
- }): Promise<{
2327
+ shouldTransformCachedModule?: ObjectHook<(this: PluginContext, options: {
2529
2328
  code: string;
2530
- map: SourceMap | {
2531
- mappings: "";
2532
- } | null;
2533
- }>;
2534
- close(): Promise<void>;
2329
+ id: string;
2330
+ meta: CustomPluginOptions;
2331
+ moduleSideEffects: boolean | "no-treeshake";
2332
+ }) => boolean | null | void>;
2535
2333
  }
2334
+ type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
2335
+ type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & { [P in K]: NonNullable<Plugin[P]>; };
2336
+ type Thenable<T> = T | Promise<T>;
2337
+ type FalsyPlugin = false | null | undefined;
2338
+ type PluginOption = Thenable<Plugin | {
2339
+ name: string;
2340
+ } | FalsyPlugin | PluginOption[]>;
2341
+ /**
2342
+ * @experimental
2343
+ */
2344
+ export declare function perEnvironmentPlugin(name: string, applyToEnvironment: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption): Plugin;
2345
+ //#endregion
2346
+ //#region src/node/watch.d.ts
2347
+ /**
2348
+ * Watch options for the dev server. Accepts both chokidar options and Rolldown
2349
+ * watch options. The chokidar options are used by the chokidar watcher, while
2350
+ * the Rolldown options are used by the Rolldown file watcher when bundled dev
2351
+ * mode is enabled.
2352
+ */
2353
+ type ServerWatchOptions = WatchOptions & Omit<DevWatchOptions, "enabled" | "skipWrite">;
2536
2354
  //#endregion
2537
2355
  //#region src/node/server/index.d.ts
2538
2356
  interface ServerOptions$1 extends CommonServerOptions {
@@ -2560,10 +2378,14 @@ interface ServerOptions$1 extends CommonServerOptions {
2560
2378
  ssrFiles?: string[];
2561
2379
  };
2562
2380
  /**
2563
- * chokidar watch options or null to disable FS watching
2564
- * https://github.com/paulmillr/chokidar/tree/3.6.0#api
2381
+ * File system watcher options, or null to disable FS watching.
2382
+ *
2383
+ * Accepts chokidar options
2384
+ * (https://github.com/paulmillr/chokidar/tree/3.6.0#api), which are used by
2385
+ * the chokidar watcher, and Rolldown watch options, which are used by the
2386
+ * Rolldown file watcher when bundled dev mode is enabled.
2565
2387
  */
2566
- watch?: WatchOptions | null;
2388
+ watch?: ServerWatchOptions | null;
2567
2389
  /**
2568
2390
  * Create Vite dev server to be used as a middleware in an existing server
2569
2391
  * @default false
@@ -2608,504 +2430,697 @@ interface ServerOptions$1 extends CommonServerOptions {
2608
2430
  */
2609
2431
  perEnvironmentStartEndDuringDev?: boolean;
2610
2432
  /**
2611
- * Backward compatibility. The watchChange hook was called only once for the client environment.
2612
- * This option enables per-environment watchChange hooks.
2613
- * @default false
2614
- * @experimental
2433
+ * Backward compatibility. The watchChange hook was called only once for the client environment.
2434
+ * This option enables per-environment watchChange hooks.
2435
+ * @default false
2436
+ * @experimental
2437
+ */
2438
+ perEnvironmentWatchChangeDuringDev?: boolean;
2439
+ /**
2440
+ * Run HMR tasks, by default the HMR propagation is done in parallel for all environments
2441
+ * @experimental
2442
+ */
2443
+ hotUpdateEnvironments?: (server: ViteDevServer, hmr: (environment: DevEnvironment) => Promise<void>) => Promise<void>;
2444
+ forwardConsole?: boolean | ForwardConsoleOptions;
2445
+ }
2446
+ interface ResolvedServerOptions extends Omit<RequiredExceptFor<ServerOptions$1, "host" | "https" | "proxy" | "hmr" | "ws" | "watch" | "origin" | "hotUpdateEnvironments">, "fs" | "middlewareMode" | "sourcemapIgnoreList" | "forwardConsole"> {
2447
+ fs: Required<FileSystemServeOptions>;
2448
+ middlewareMode: NonNullable<ServerOptions$1["middlewareMode"]>;
2449
+ sourcemapIgnoreList: Exclude<ServerOptions$1["sourcemapIgnoreList"], false | undefined>;
2450
+ forwardConsole: ResolvedForwardConsoleOptions;
2451
+ }
2452
+ interface FileSystemServeOptions {
2453
+ /**
2454
+ * Strictly restrict file accessing outside of allowing paths.
2455
+ *
2456
+ * Set to `false` to disable the warning
2457
+ *
2458
+ * @default true
2459
+ */
2460
+ strict?: boolean;
2461
+ /**
2462
+ * Restrict accessing files outside the allowed directories.
2463
+ *
2464
+ * Accepts absolute path or a path relative to project root.
2465
+ * Will try to search up for workspace root by default.
2466
+ */
2467
+ allow?: string[];
2468
+ /**
2469
+ * Restrict accessing files that matches the patterns.
2470
+ *
2471
+ * This will have higher priority than `allow`.
2472
+ * picomatch patterns are supported.
2473
+ *
2474
+ * @default ['.env', '.env.*', '*.{crt,pem,key,p12,pfx,cer,der}', '.npmrc', '.yarnrc.yml', '**\/.git/**']
2475
+ */
2476
+ deny?: string[];
2477
+ }
2478
+ type ServerHook = (this: MinimalPluginContextWithoutEnvironment, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
2479
+ interface CloseServerHookContext {
2480
+ /**
2481
+ * Whether the server is being restarted (e.g. a config change or
2482
+ * `server.restart()`) or closed (e.g. the `q` shortcut, SIGTERM, stdin
2483
+ * ending, or `server.close()`).
2484
+ */
2485
+ reason: "restart" | "close";
2486
+ }
2487
+ type CloseServerHook = (this: MinimalPluginContextWithoutEnvironment, context: CloseServerHookContext) => void | Promise<void>;
2488
+ type HttpServer = http.Server | Http2SecureServer;
2489
+ interface ViteDevServer {
2490
+ /**
2491
+ * The resolved vite config object
2492
+ */
2493
+ config: ResolvedConfig;
2494
+ /**
2495
+ * A connect app instance.
2496
+ * - Can be used to attach custom middlewares to the dev server.
2497
+ * - Can also be used as the handler function of a custom http server
2498
+ * or as a middleware in any connect-style Node.js frameworks
2499
+ *
2500
+ * https://github.com/senchalabs/connect#use-middleware
2501
+ */
2502
+ middlewares: Connect.Server;
2503
+ /**
2504
+ * native Node http server instance
2505
+ * will be null in middleware mode
2506
+ */
2507
+ httpServer: HttpServer | null;
2508
+ /**
2509
+ * Chokidar watcher instance. If `config.server.watch` is set to `null`,
2510
+ * it will not watch any files and calling `add` or `unwatch` will have no effect.
2511
+ * https://github.com/paulmillr/chokidar/tree/3.6.0#api
2512
+ */
2513
+ watcher: FSWatcher;
2514
+ /**
2515
+ * WebSocket server with `send(payload)` method
2516
+ */
2517
+ ws: WebSocketServer;
2518
+ /**
2519
+ * An alias to `server.environments.client.hot`.
2520
+ * If you want to interact with all environments, loop over `server.environments`.
2521
+ */
2522
+ hot: NormalizedHotChannel;
2523
+ /**
2524
+ * Rollup plugin container that can run plugin hooks on a given file
2525
+ */
2526
+ pluginContainer: PluginContainer;
2527
+ /**
2528
+ * Module execution environments attached to the Vite server.
2529
+ */
2530
+ environments: Record<"client" | "ssr" | (string & {}), DevEnvironment>;
2531
+ /**
2532
+ * Module graph that tracks the import relationships, url to file mapping
2533
+ * and hmr state.
2534
+ */
2535
+ moduleGraph: ModuleGraph;
2536
+ /**
2537
+ * The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
2538
+ * in middleware mode or if the server is not listening on any port.
2539
+ */
2540
+ resolvedUrls: ResolvedServerUrls | null;
2541
+ /**
2542
+ * Programmatically resolve, load and transform a URL and get the result
2543
+ * without going through the http request pipeline.
2544
+ */
2545
+ transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
2546
+ /**
2547
+ * Same as `transformRequest` but only warm up the URLs so the next request
2548
+ * will already be cached. The function will never throw as it handles and
2549
+ * reports errors internally.
2550
+ */
2551
+ warmupRequest(url: string, options?: TransformOptions): Promise<void>;
2552
+ /**
2553
+ * Apply vite built-in HTML transforms and any plugin HTML transforms.
2554
+ */
2555
+ transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
2556
+ /**
2557
+ * Transform module code into SSR format.
2558
+ */
2559
+ ssrTransform(code: string, inMap: SourceMap | {
2560
+ mappings: "";
2561
+ } | null, url: string, originalCode?: string): Promise<TransformResult | null>;
2562
+ /**
2563
+ * Load a given URL as an instantiated module for SSR.
2564
+ */
2565
+ ssrLoadModule(url: string, opts?: {
2566
+ fixStacktrace?: boolean;
2567
+ }): Promise<Record<string, any>>;
2568
+ /**
2569
+ * Returns a fixed version of the given stack
2570
+ */
2571
+ ssrRewriteStacktrace(stack: string): string;
2572
+ /**
2573
+ * Mutates the given SSR error by rewriting the stacktrace
2574
+ */
2575
+ ssrFixStacktrace(e: Error): void;
2576
+ /**
2577
+ * Triggers HMR for a module in the module graph. You can use the `server.moduleGraph`
2578
+ * API to retrieve the module to be reloaded. If `hmr` is false, this is a no-op.
2579
+ */
2580
+ reloadModule(module: ModuleNode): Promise<void>;
2581
+ /**
2582
+ * Start the server.
2583
+ */
2584
+ listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
2585
+ /**
2586
+ * Stop the server.
2587
+ */
2588
+ close(): Promise<void>;
2589
+ /**
2590
+ * Print server urls
2591
+ */
2592
+ printUrls(): void;
2593
+ /**
2594
+ * Bind CLI shortcuts
2595
+ */
2596
+ bindCLIShortcuts(options?: BindCLIShortcutsOptions<ViteDevServer>): void;
2597
+ /**
2598
+ * Restart the server.
2599
+ *
2600
+ * @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
2601
+ */
2602
+ restart(forceOptimize?: boolean): Promise<void>;
2603
+ /**
2604
+ * Open browser
2605
+ */
2606
+ openBrowser(): void;
2607
+ /**
2608
+ * Calling `await server.waitForRequestsIdle(id)` will wait until all static imports
2609
+ * are processed. If called from a load or transform plugin hook, the id needs to be
2610
+ * passed as a parameter to avoid deadlocks. Calling this function after the first
2611
+ * static imports section of the module graph has been processed will resolve immediately.
2612
+ */
2613
+ waitForRequestsIdle: (ignoredId?: string) => Promise<void>;
2614
+ }
2615
+ interface ResolvedServerUrls {
2616
+ local: string[];
2617
+ network: string[];
2618
+ /**
2619
+ * Names of the network interface that each {@link ResolvedServerUrls.network}
2620
+ * URL is bound to, in the same order as `network`. An entry is `undefined`
2621
+ * when the interface name is not known, for example when an explicit `host`
2622
+ * is set.
2623
+ */
2624
+ networkInterfaceNames?: (string | undefined)[];
2625
+ }
2626
+ export declare function createServer(inlineConfig?: InlineConfig | ResolvedConfig): Promise<ViteDevServer>;
2627
+ //#endregion
2628
+ //#region src/node/logger.d.ts
2629
+ type LogType = "error" | "warn" | "info";
2630
+ type LogLevel = LogType | "silent";
2631
+ interface Logger {
2632
+ info(msg: string, options?: LogOptions): void;
2633
+ warn(msg: string, options?: LogOptions): void;
2634
+ warnOnce(msg: string, options?: LogOptions): void;
2635
+ error(msg: string, options?: LogErrorOptions): void;
2636
+ clearScreen(type: LogType): void;
2637
+ hasErrorLogged(error: Error | RollupError): boolean;
2638
+ hasWarned: boolean;
2639
+ }
2640
+ interface LogOptions {
2641
+ clear?: boolean;
2642
+ timestamp?: boolean;
2643
+ environment?: string;
2644
+ }
2645
+ interface LogErrorOptions extends LogOptions {
2646
+ error?: Error | RollupError | null;
2647
+ }
2648
+ interface LoggerOptions {
2649
+ prefix?: string;
2650
+ allowClearScreen?: boolean;
2651
+ customLogger?: Logger;
2652
+ console?: Console;
2653
+ }
2654
+ export declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
2655
+ //#endregion
2656
+ //#region src/node/baseEnvironment.d.ts
2657
+ declare class PartialEnvironment {
2658
+ name: string;
2659
+ getTopLevelConfig(): ResolvedConfig;
2660
+ config: ResolvedConfig & ResolvedEnvironmentOptions;
2661
+ logger: Logger;
2662
+ constructor(name: string, topLevelConfig: ResolvedConfig, options?: ResolvedEnvironmentOptions);
2663
+ }
2664
+ declare class BaseEnvironment extends PartialEnvironment {
2665
+ get plugins(): readonly Plugin[];
2666
+ constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
2667
+ }
2668
+ /**
2669
+ * This class discourages users from inversely checking the `mode`
2670
+ * to determine the type of environment, e.g.
2671
+ *
2672
+ * ```js
2673
+ * const isDev = environment.mode !== 'build' // bad
2674
+ * const isDev = environment.mode === 'dev' // good
2675
+ * ```
2676
+ *
2677
+ * You should also not check against `"unknown"` specifically. It's
2678
+ * a placeholder for more possible environment types.
2679
+ */
2680
+ declare class UnknownEnvironment extends BaseEnvironment {
2681
+ mode: "unknown";
2682
+ }
2683
+ //#endregion
2684
+ //#region src/node/plugins/resolve.d.ts
2685
+ interface EnvironmentResolveOptions {
2686
+ /**
2687
+ * @default ['browser', 'module', 'jsnext:main', 'jsnext']
2615
2688
  */
2616
- perEnvironmentWatchChangeDuringDev?: boolean;
2689
+ mainFields?: string[];
2690
+ conditions?: string[];
2691
+ externalConditions?: string[];
2617
2692
  /**
2618
- * Run HMR tasks, by default the HMR propagation is done in parallel for all environments
2619
- * @experimental
2693
+ * @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
2620
2694
  */
2621
- hotUpdateEnvironments?: (server: ViteDevServer, hmr: (environment: DevEnvironment) => Promise<void>) => Promise<void>;
2622
- forwardConsole?: boolean | ForwardConsoleOptions;
2623
- }
2624
- interface ResolvedServerOptions extends Omit<RequiredExceptFor<ServerOptions$1, "host" | "https" | "proxy" | "hmr" | "ws" | "watch" | "origin" | "hotUpdateEnvironments">, "fs" | "middlewareMode" | "sourcemapIgnoreList" | "forwardConsole"> {
2625
- fs: Required<FileSystemServeOptions>;
2626
- middlewareMode: NonNullable<ServerOptions$1["middlewareMode"]>;
2627
- sourcemapIgnoreList: Exclude<ServerOptions$1["sourcemapIgnoreList"], false | undefined>;
2628
- forwardConsole: ResolvedForwardConsoleOptions;
2629
- }
2630
- interface FileSystemServeOptions {
2695
+ extensions?: string[];
2696
+ dedupe?: string[];
2631
2697
  /**
2632
- * Strictly restrict file accessing outside of allowing paths.
2633
- *
2634
- * Set to `false` to disable the warning
2635
- *
2636
- * @default true
2698
+ * Prevent listed dependencies from being externalized and will get bundled in build.
2699
+ * Only works in server environments for now. Previously this was `ssr.noExternal`.
2700
+ * @experimental
2637
2701
  */
2638
- strict?: boolean;
2702
+ noExternal?: string | RegExp | (string | RegExp)[] | true;
2639
2703
  /**
2640
- * Restrict accessing files outside the allowed directories.
2641
- *
2642
- * Accepts absolute path or a path relative to project root.
2643
- * Will try to search up for workspace root by default.
2704
+ * Externalize the given dependencies and their transitive dependencies.
2705
+ * Only works in server environments for now. Previously this was `ssr.external`.
2706
+ * @experimental
2644
2707
  */
2645
- allow?: string[];
2708
+ external?: string[] | true;
2646
2709
  /**
2647
- * Restrict accessing files that matches the patterns.
2648
- *
2649
- * This will have higher priority than `allow`.
2650
- * picomatch patterns are supported.
2651
- *
2652
- * @default ['.env', '.env.*', '*.{crt,pem,key,p12,pfx,cer,der}', '.npmrc', '.yarnrc.yml', '**\/.git/**']
2710
+ * Array of strings or regular expressions that indicate what modules are builtin for the environment.
2653
2711
  */
2654
- deny?: string[];
2712
+ builtins?: (string | RegExp)[];
2655
2713
  }
2656
- type ServerHook = (this: MinimalPluginContextWithoutEnvironment, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
2657
- type HttpServer = http.Server | Http2SecureServer;
2658
- interface ViteDevServer {
2714
+ interface ResolveOptions extends EnvironmentResolveOptions {
2659
2715
  /**
2660
- * The resolved vite config object
2716
+ * @default false
2661
2717
  */
2662
- config: ResolvedConfig;
2718
+ preserveSymlinks?: boolean;
2663
2719
  /**
2664
- * A connect app instance.
2665
- * - Can be used to attach custom middlewares to the dev server.
2666
- * - Can also be used as the handler function of a custom http server
2667
- * or as a middleware in any connect-style Node.js frameworks
2720
+ * Enable tsconfig paths resolution
2668
2721
  *
2669
- * https://github.com/senchalabs/connect#use-middleware
2670
- */
2671
- middlewares: Connect.Server;
2672
- /**
2673
- * native Node http server instance
2674
- * will be null in middleware mode
2675
- */
2676
- httpServer: HttpServer | null;
2677
- /**
2678
- * Chokidar watcher instance. If `config.server.watch` is set to `null`,
2679
- * it will not watch any files and calling `add` or `unwatch` will have no effect.
2680
- * https://github.com/paulmillr/chokidar/tree/3.6.0#api
2681
- */
2682
- watcher: FSWatcher;
2683
- /**
2684
- * WebSocket server with `send(payload)` method
2685
- */
2686
- ws: WebSocketServer;
2687
- /**
2688
- * An alias to `server.environments.client.hot`.
2689
- * If you want to interact with all environments, loop over `server.environments`.
2722
+ * @default false
2690
2723
  */
2691
- hot: NormalizedHotChannel;
2724
+ tsconfigPaths?: boolean;
2725
+ }
2726
+ interface ResolvePluginOptions {
2727
+ root: string;
2728
+ isBuild: boolean;
2729
+ isProduction: boolean;
2730
+ packageCache?: PackageCache;
2692
2731
  /**
2693
- * Rollup plugin container that can run plugin hooks on a given file
2732
+ * src code mode also attempts the following:
2733
+ * - resolving /xxx as URLs
2734
+ * - resolving bare imports from optimized deps
2694
2735
  */
2695
- pluginContainer: PluginContainer;
2736
+ asSrc?: boolean;
2737
+ tryIndex?: boolean;
2738
+ tryPrefix?: string;
2739
+ preferRelative?: boolean;
2740
+ isRequire?: boolean;
2741
+ scan?: boolean;
2696
2742
  /**
2697
- * Module execution environments attached to the Vite server.
2743
+ * Enable when `legacy.inconsistentCjsInterop` is true. See that option for more details.
2698
2744
  */
2699
- environments: Record<"client" | "ssr" | (string & {}), DevEnvironment>;
2745
+ legacyInconsistentCjsInterop?: boolean;
2746
+ }
2747
+ interface InternalResolveOptions extends Required<ResolveOptions>, ResolvePluginOptions {}
2748
+ //#endregion
2749
+ //#region src/node/packages.d.ts
2750
+ /** Cache for package.json resolution and package.json contents */
2751
+ type PackageCache = Map<string, PackageData>;
2752
+ interface PackageData {
2753
+ dir: string;
2754
+ hasSideEffects: (id: string) => boolean | "no-treeshake" | null;
2755
+ setResolvedCache: (key: string, entry: string, options: InternalResolveOptions) => void;
2756
+ getResolvedCache: (key: string, options: InternalResolveOptions) => string | undefined;
2757
+ data: {
2758
+ [field: string]: any;
2759
+ name: string;
2760
+ type: string;
2761
+ version: string;
2762
+ main: string;
2763
+ module: string;
2764
+ browser: string | Record<string, string | false>;
2765
+ exports: string | Record<string, any> | string[];
2766
+ imports: Record<string, any>;
2767
+ dependencies: Record<string, string>;
2768
+ };
2769
+ }
2770
+ //#endregion
2771
+ //#region src/node/plugins/license.d.ts
2772
+ interface LicenseOptions {
2700
2773
  /**
2701
- * Module graph that tracks the import relationships, url to file mapping
2702
- * and hmr state.
2774
+ * The output file name of the license file relative to the output directory.
2775
+ * Specify a path that ends with `.json` to output the raw JSON metadata.
2776
+ *
2777
+ * @default '.vite/license.md'
2703
2778
  */
2704
- moduleGraph: ModuleGraph;
2779
+ fileName: string;
2780
+ }
2781
+ //#endregion
2782
+ //#region src/node/plugins/terser.d.ts
2783
+ interface TerserOptions extends TerserMinifyOptions {
2705
2784
  /**
2706
- * The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
2707
- * in middleware mode or if the server is not listening on any port.
2785
+ * Vite-specific option to specify the max number of workers to spawn
2786
+ * when minifying files with terser.
2787
+ *
2788
+ * @default number of CPUs minus 1
2708
2789
  */
2709
- resolvedUrls: ResolvedServerUrls | null;
2790
+ maxWorkers?: number;
2791
+ }
2792
+ //#endregion
2793
+ //#region src/node/build.d.ts
2794
+ interface BuildEnvironmentOptions {
2710
2795
  /**
2711
- * Programmatically resolve, load and transform a URL and get the result
2712
- * without going through the http request pipeline.
2796
+ * Compatibility transform target. The transform is performed with esbuild
2797
+ * and the lowest supported target is es2015. Note this only handles
2798
+ * syntax transformation and does not cover polyfills
2799
+ *
2800
+ * Default: 'baseline-widely-available' - transpile targeting browsers that
2801
+ * are included in the Baseline Widely Available on 2026-01-01.
2802
+ * (Chrome 111+, Edge 111+, Firefox 114+, Safari 16.4+).
2803
+ *
2804
+ * Another special value is 'esnext' - which only performs minimal transpiling
2805
+ * (for minification compat).
2806
+ *
2807
+ * For custom targets, see https://esbuild.github.io/api/#target and
2808
+ * https://esbuild.github.io/content-types/#javascript for more details.
2809
+ * @default 'baseline-widely-available'
2713
2810
  */
2714
- transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
2811
+ target?: "baseline-widely-available" | EsbuildTarget | false;
2715
2812
  /**
2716
- * Same as `transformRequest` but only warm up the URLs so the next request
2717
- * will already be cached. The function will never throw as it handles and
2718
- * reports errors internally.
2813
+ * whether to inject module preload polyfill.
2814
+ * Note: does not apply to library mode.
2815
+ * @default true
2816
+ * @deprecated use `modulePreload.polyfill` instead
2719
2817
  */
2720
- warmupRequest(url: string, options?: TransformOptions): Promise<void>;
2818
+ polyfillModulePreload?: boolean;
2721
2819
  /**
2722
- * Apply vite built-in HTML transforms and any plugin HTML transforms.
2820
+ * Configure module preload
2821
+ * Note: does not apply to library mode.
2822
+ * @default true
2723
2823
  */
2724
- transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
2824
+ modulePreload?: boolean | ModulePreloadOptions;
2725
2825
  /**
2726
- * Transform module code into SSR format.
2826
+ * Directory relative from `root` where build output will be placed. If the
2827
+ * directory exists, it will be removed before the build.
2828
+ * @default 'dist'
2727
2829
  */
2728
- ssrTransform(code: string, inMap: SourceMap | {
2729
- mappings: "";
2730
- } | null, url: string, originalCode?: string): Promise<TransformResult | null>;
2830
+ outDir?: string;
2731
2831
  /**
2732
- * Load a given URL as an instantiated module for SSR.
2832
+ * Directory relative from `outDir` where the built js/css/image assets will
2833
+ * be placed.
2834
+ * @default 'assets'
2733
2835
  */
2734
- ssrLoadModule(url: string, opts?: {
2735
- fixStacktrace?: boolean;
2736
- }): Promise<Record<string, any>>;
2836
+ assetsDir?: string;
2737
2837
  /**
2738
- * Returns a fixed version of the given stack
2838
+ * Static asset files smaller than this number (in bytes) will be inlined as
2839
+ * base64 strings. If a callback is passed, a boolean can be returned to opt-in
2840
+ * or opt-out of inlining. If nothing is returned the default logic applies.
2841
+ *
2842
+ * Default limit is `4096` (4 KiB). Set to `0` to disable.
2843
+ * @default 4096
2739
2844
  */
2740
- ssrRewriteStacktrace(stack: string): string;
2845
+ assetsInlineLimit?: number | ((filePath: string, content: Buffer) => boolean | undefined);
2741
2846
  /**
2742
- * Mutates the given SSR error by rewriting the stacktrace
2847
+ * Whether to code-split CSS. When enabled, CSS in async chunks will be
2848
+ * inlined as strings in the chunk and inserted via dynamically created
2849
+ * style tags when the chunk is loaded.
2850
+ * @default true
2743
2851
  */
2744
- ssrFixStacktrace(e: Error): void;
2852
+ cssCodeSplit?: boolean;
2745
2853
  /**
2746
- * Triggers HMR for a module in the module graph. You can use the `server.moduleGraph`
2747
- * API to retrieve the module to be reloaded. If `hmr` is false, this is a no-op.
2854
+ * An optional separate target for CSS minification.
2855
+ * As esbuild only supports configuring targets to mainstream
2856
+ * browsers, users may need this option when they are targeting
2857
+ * a niche browser that comes with most modern JavaScript features
2858
+ * but has poor CSS support, e.g. Android WeChat WebView, which
2859
+ * doesn't support the #RGBA syntax.
2860
+ * When `build.cssMinify` is `lightningcss` (the default), this
2861
+ * option takes precedence over `css.lightningcss.targets` for the
2862
+ * minification step.
2863
+ * @default target
2748
2864
  */
2749
- reloadModule(module: ModuleNode): Promise<void>;
2865
+ cssTarget?: EsbuildTarget | false;
2750
2866
  /**
2751
- * Start the server.
2867
+ * Override CSS minification specifically instead of defaulting to `build.minify`,
2868
+ * so you can configure minification for JS and CSS separately.
2869
+ * @default 'lightningcss', but false if build.minify is disabled for client build
2752
2870
  */
2753
- listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
2871
+ cssMinify?: boolean | "lightningcss" | "esbuild";
2754
2872
  /**
2755
- * Stop the server.
2873
+ * If `true`, a separate sourcemap file will be created. If 'inline', the
2874
+ * sourcemap will be appended to the resulting output file as data URI.
2875
+ * 'hidden' works like `true` except that the corresponding sourcemap
2876
+ * comments in the bundled files are suppressed.
2877
+ * @default false
2756
2878
  */
2757
- close(): Promise<void>;
2879
+ sourcemap?: boolean | "inline" | "hidden";
2758
2880
  /**
2759
- * Print server urls
2881
+ * Set to `false` to disable minification, or specify the minifier to use.
2882
+ * Available options are 'oxc' or 'terser' or 'esbuild'.
2883
+ * @default 'oxc' for client build, false for SSR build
2760
2884
  */
2761
- printUrls(): void;
2885
+ minify?: boolean | "oxc" | "terser" | "esbuild";
2762
2886
  /**
2763
- * Bind CLI shortcuts
2887
+ * Options for terser
2888
+ * https://terser.org/docs/api-reference#minify-options
2889
+ *
2890
+ * In addition, you can also pass a `maxWorkers: number` option to specify the
2891
+ * max number of workers to spawn. Defaults to the number of CPUs minus 1.
2764
2892
  */
2765
- bindCLIShortcuts(options?: BindCLIShortcutsOptions<ViteDevServer>): void;
2893
+ terserOptions?: TerserOptions;
2766
2894
  /**
2767
- * Restart the server.
2768
- *
2769
- * @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
2895
+ * Whether to use import maps feature to optimize chunk caching efficiency.
2896
+ * @default false
2897
+ * @experimental
2770
2898
  */
2771
- restart(forceOptimize?: boolean): Promise<void>;
2899
+ chunkImportMap?: boolean;
2772
2900
  /**
2773
- * Open browser
2901
+ * Alias to `rolldownOptions`
2902
+ * @deprecated Use `rolldownOptions` instead.
2774
2903
  */
2775
- openBrowser(): void;
2904
+ rollupOptions?: RolldownOptions;
2776
2905
  /**
2777
- * Calling `await server.waitForRequestsIdle(id)` will wait until all static imports
2778
- * are processed. If called from a load or transform plugin hook, the id needs to be
2779
- * passed as a parameter to avoid deadlocks. Calling this function after the first
2780
- * static imports section of the module graph has been processed will resolve immediately.
2906
+ * Will be merged with internal rolldown options.
2907
+ * https://rolldown.rs/reference/Interface.RolldownOptions
2781
2908
  */
2782
- waitForRequestsIdle: (ignoredId?: string) => Promise<void>;
2783
- }
2784
- interface ResolvedServerUrls {
2785
- local: string[];
2786
- network: string[];
2909
+ rolldownOptions?: RolldownOptions;
2787
2910
  /**
2788
- * Names of the network interface that each {@link ResolvedServerUrls.network}
2789
- * URL is bound to, in the same order as `network`. An entry is `undefined`
2790
- * when the interface name is not known, for example when an explicit `host`
2791
- * is set.
2911
+ * Options to pass on to `@rollup/plugin-commonjs`
2912
+ * @deprecated This option is no-op and will be removed in future versions.
2792
2913
  */
2793
- networkInterfaceNames?: (string | undefined)[];
2794
- }
2795
- export declare function createServer(inlineConfig?: InlineConfig | ResolvedConfig): Promise<ViteDevServer>;
2796
- //#endregion
2797
- //#region src/node/plugins/html.d.ts
2798
- interface HtmlTagDescriptor {
2799
- tag: string;
2914
+ commonjsOptions?: RollupCommonJSOptions;
2800
2915
  /**
2801
- * attribute values will be escaped automatically if needed
2916
+ * Options to pass on to `@rollup/plugin-dynamic-import-vars`
2802
2917
  */
2803
- attrs?: Record<string, string | boolean | undefined>;
2804
- children?: string | HtmlTagDescriptor[];
2918
+ dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
2805
2919
  /**
2806
- * default: 'head-prepend'
2920
+ * Whether to write bundle to disk
2921
+ * @default true
2807
2922
  */
2808
- injectTo?: "head" | "body" | "head-prepend" | "body-prepend";
2809
- }
2810
- type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | {
2811
- html: string;
2812
- tags: HtmlTagDescriptor[];
2813
- };
2814
- interface IndexHtmlTransformContext {
2923
+ write?: boolean;
2815
2924
  /**
2816
- * public path when served
2925
+ * Empty outDir on write.
2926
+ * @default true when outDir is a sub directory of project root
2817
2927
  */
2818
- path: string;
2928
+ emptyOutDir?: boolean | null;
2819
2929
  /**
2820
- * filename on disk
2930
+ * Copy the public directory to outDir on write.
2931
+ * @default true
2821
2932
  */
2822
- filename: string;
2823
- server?: ViteDevServer;
2824
- bundle?: OutputBundle;
2825
- chunk?: OutputChunk;
2826
- originalUrl?: string;
2827
- }
2828
- type IndexHtmlTransformHook = (this: MinimalPluginContextWithoutEnvironment, html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>;
2829
- type IndexHtmlTransform = IndexHtmlTransformHook | {
2830
- order?: "pre" | "post" | null;
2831
- handler: IndexHtmlTransformHook;
2832
- };
2833
- //#endregion
2834
- //#region src/node/plugins/pluginFilter.d.ts
2835
- type StringFilter<Value = string | RegExp> = Value | Array<Value> | {
2836
- include?: Value | Array<Value>;
2837
- exclude?: Value | Array<Value>;
2838
- };
2839
- //#endregion
2840
- //#region src/node/plugin.d.ts
2841
- /**
2842
- * Vite plugins extends the Rollup plugin interface with a few extra
2843
- * vite-specific options. A valid vite plugin is also a valid Rollup plugin.
2844
- * On the contrary, a Rollup plugin may or may NOT be a valid vite universal
2845
- * plugin, since some Rollup features do not make sense in an unbundled
2846
- * dev server context. That said, as long as a rollup plugin doesn't have strong
2847
- * coupling between its bundle phase and output phase hooks then it should
2848
- * just work (that means, most of them).
2849
- *
2850
- * By default, the plugins are run during both serve and build. When a plugin
2851
- * is applied during serve, it will only run **non output plugin hooks** (see
2852
- * rollup type definition of {@link rollup#PluginHooks}). You can think of the
2853
- * dev server as only running `const bundle = rollup.rollup()` but never calling
2854
- * `bundle.generate()`.
2855
- *
2856
- * A plugin that expects to have different behavior depending on serve/build can
2857
- * export a factory function that receives the command being run via options.
2858
- *
2859
- * If a plugin should be applied only for server or build, a function format
2860
- * config file can be used to conditional determine the plugins to use.
2861
- *
2862
- * The current environment can be accessed from the context for the all non-global
2863
- * hooks (it is not available in config, configResolved, configureServer, etc).
2864
- * It can be a dev, build, or scan environment.
2865
- * Plugins can use this.environment.mode === 'dev' to guard for dev specific APIs.
2866
- */
2867
- interface PluginContextExtension {
2933
+ copyPublicDir?: boolean;
2868
2934
  /**
2869
- * Vite-specific environment instance
2935
+ * Whether to emit a `.vite/license.md` file that includes all bundled dependencies'
2936
+ * licenses. Pass an object to customize the output file name.
2937
+ * @default false
2870
2938
  */
2871
- environment: Environment;
2872
- }
2873
- interface PluginContextMetaExtension {
2874
- viteVersion: string;
2875
- }
2876
- interface ConfigPluginContext extends Omit<MinimalPluginContext, "meta" | "environment"> {
2877
- meta: Omit<PluginContextMeta, "watchMode">;
2878
- }
2879
- interface MinimalPluginContextWithoutEnvironment extends Omit<MinimalPluginContext, "environment"> {}
2880
- declare module "rolldown" {
2881
- interface MinimalPluginContext extends PluginContextExtension {}
2882
- interface PluginContextMeta extends PluginContextMetaExtension {}
2883
- }
2884
- /**
2885
- * There are two types of plugins in Vite. App plugins and environment plugins.
2886
- * Environment Plugins are defined by a constructor function that will be called
2887
- * once per each environment allowing users to have completely different plugins
2888
- * for each of them. The constructor gets the resolved environment after the server
2889
- * and builder has already been created simplifying config access and cache
2890
- * management for environment specific plugins.
2891
- * Environment Plugins are closer to regular rollup plugins. They can't define
2892
- * app level hooks (like config, configResolved, configureServer, etc).
2893
- */
2894
- interface Plugin<A = any> extends Rolldown.Plugin<A> {
2939
+ license?: boolean | LicenseOptions;
2895
2940
  /**
2896
- * Perform custom handling of HMR updates.
2897
- * The handler receives an options containing changed filename, timestamp, a
2898
- * list of modules affected by the file change, and the dev server instance.
2899
- *
2900
- * - The hook can return a filtered list of modules to narrow down the update.
2901
- * e.g. for a Vue SFC, we can narrow down the part to update by comparing
2902
- * the descriptors.
2941
+ * Whether to emit a .vite/manifest.json in the output dir to map hash-less filenames
2942
+ * to their hashed versions. Useful when you want to generate your own HTML
2943
+ * instead of using the one generated by Vite.
2903
2944
  *
2904
- * - The hook can also return an empty array and then perform custom updates
2905
- * by sending a custom hmr payload via environment.hot.send().
2945
+ * Example:
2906
2946
  *
2907
- * - If the hook doesn't return a value, the hmr update will be performed as
2908
- * normal.
2947
+ * ```json
2948
+ * {
2949
+ * "main.js": {
2950
+ * "file": "main.68fe3fad.js",
2951
+ * "css": "main.e6b63442.css",
2952
+ * "imports": [...],
2953
+ * "dynamicImports": [...]
2954
+ * }
2955
+ * }
2956
+ * ```
2957
+ * @default false
2909
2958
  */
2910
- hotUpdate?: ObjectHook<(this: MinimalPluginContext & {
2911
- environment: DevEnvironment;
2912
- }, options: HotUpdateOptions) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
2959
+ manifest?: boolean | string;
2913
2960
  /**
2914
- * extend hooks with ssr flag
2961
+ * Build in library mode. The value should be the global name of the lib in
2962
+ * UMD mode. This will produce esm + cjs + umd bundle formats with default
2963
+ * configurations that are suitable for distributing libraries.
2964
+ * @default false
2915
2965
  */
2916
- resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
2917
- kind?: ImportKind;
2918
- custom?: CustomPluginOptions;
2919
- ssr?: boolean | undefined;
2920
-
2921
- isEntry: boolean;
2922
- }) => Promise<ResolveIdResult> | ResolveIdResult, {
2923
- filter?: {
2924
- id?: StringFilter<RegExp>;
2925
- };
2926
- }>;
2927
- load?: ObjectHook<(this: PluginContext, id: string, options?: {
2928
- ssr?: boolean | undefined;
2929
- }) => Promise<LoadResult> | LoadResult, {
2930
- filter?: {
2931
- id?: StringFilter;
2932
- };
2933
- }>;
2934
- transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
2935
- moduleType: ModuleType;
2936
- ssr?: boolean | undefined;
2937
- }) => Promise<Rolldown.TransformResult> | Rolldown.TransformResult, {
2938
- filter?: {
2939
- id?: StringFilter;
2940
- code?: StringFilter;
2941
- moduleType?: ModuleTypeFilter;
2942
- };
2943
- }>;
2966
+ lib?: LibraryOptions | false;
2944
2967
  /**
2945
- * Opt-in this plugin into the shared plugins pipeline.
2946
- * For backward-compatibility, plugins are re-recreated for each environment
2947
- * during `vite build --app`
2948
- * We have an opt-in per plugin, and a general `builder.sharedPlugins`
2949
- * In a future major, we'll flip the default to be shared by default
2950
- * @experimental
2968
+ * Produce SSR oriented build. Note this requires specifying SSR entry via
2969
+ * `rolldownOptions.input`.
2970
+ * @default false
2951
2971
  */
2952
- sharedDuringBuild?: boolean;
2972
+ ssr?: boolean | string;
2953
2973
  /**
2954
- * Opt-in this plugin into per-environment buildStart and buildEnd during dev.
2955
- * For backward-compatibility, the buildStart hook is called only once during
2956
- * dev, for the client environment. Plugins can opt-in to be called
2957
- * per-environment, aligning with the build hook behavior.
2958
- * @experimental
2974
+ * Generate SSR manifest for determining style links and asset preload
2975
+ * directives in production.
2976
+ * @default false
2959
2977
  */
2960
- perEnvironmentStartEndDuringDev?: boolean;
2978
+ ssrManifest?: boolean | string;
2961
2979
  /**
2962
- * Opt-in this plugin into per-environment watchChange during dev.
2963
- * For backward-compatibility, the watchChange hook is called only once during
2964
- * dev, for the client environment. Plugins can opt-in to be called
2965
- * per-environment, aligning with the watchChange hook behavior.
2966
- * @experimental
2980
+ * Emit assets during SSR.
2981
+ * @default false
2982
+ */
2983
+ ssrEmitAssets?: boolean;
2984
+ /**
2985
+ * Emit assets during build. Frameworks can set environments.ssr.build.emitAssets
2986
+ * By default, it is true for the client and false for other environments.
2987
+ */
2988
+ emitAssets?: boolean;
2989
+ /**
2990
+ * Set to false to disable reporting compressed chunk sizes.
2991
+ * Can slightly improve build speed.
2992
+ * @default true
2967
2993
  */
2968
- perEnvironmentWatchChangeDuringDev?: boolean;
2994
+ reportCompressedSize?: boolean;
2969
2995
  /**
2970
- * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
2971
- * is still subject to the `order` property in the hook object.
2972
- *
2973
- * Plugin invocation order:
2974
- * - alias resolution
2975
- * - `enforce: 'pre'` plugins
2976
- * - vite core plugins
2977
- * - normal plugins
2978
- * - vite build plugins
2979
- * - `enforce: 'post'` plugins
2980
- * - vite build post plugins
2996
+ * Adjust chunk size warning limit (in kB).
2997
+ * @default 500
2981
2998
  */
2982
- enforce?: "pre" | "post";
2999
+ chunkSizeWarningLimit?: number;
2983
3000
  /**
2984
- * Apply the plugin only for serve or build, or on certain conditions.
3001
+ * Rollup watch options
3002
+ * https://rollupjs.org/configuration-options/#watch
3003
+ * @default null
2985
3004
  */
2986
- apply?: "serve" | "build" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean);
3005
+ watch?: WatcherOptions | null;
2987
3006
  /**
2988
- * Define environments where this plugin should be active
2989
- * By default, the plugin is active in all environments
2990
- * @experimental
3007
+ * create the Build Environment instance
2991
3008
  */
2992
- applyToEnvironment?: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption;
3009
+ createEnvironment?: (name: string, config: ResolvedConfig) => Promise<BuildEnvironment> | BuildEnvironment;
3010
+ }
3011
+ type BuildOptions = BuildEnvironmentOptions;
3012
+ interface LibraryOptions {
2993
3013
  /**
2994
- * Modify vite config before it's resolved. The hook can either mutate the
2995
- * passed-in config directly, or return a partial config object that will be
2996
- * deeply merged into existing config.
2997
- *
2998
- * Note: User plugins are resolved before running this hook so injecting other
2999
- * plugins inside the `config` hook will have no effect.
3014
+ * Path of library entry.
3015
+ * Defaults to the top-level `input` option when omitted.
3000
3016
  */
3001
- config?: ObjectHook<(this: ConfigPluginContext, config: UserConfig, env: ConfigEnv) => Omit<UserConfig, "plugins"> | null | void | Promise<Omit<UserConfig, "plugins"> | null | void>>;
3017
+ entry?: InputOption;
3002
3018
  /**
3003
- * Modify environment configs before it's resolved. The hook can either mutate the
3004
- * passed-in environment config directly, or return a partial config object that will be
3005
- * deeply merged into existing config.
3006
- * This hook is called for each environment with a partially resolved environment config
3007
- * that already accounts for the default environment config values set at the root level.
3008
- * If plugins need to modify the config of a given environment, they should do it in this
3009
- * hook instead of the config hook. Leaving the config hook only for modifying the root
3010
- * default environment config.
3019
+ * The name of the exposed global variable. Required when the `formats` option includes
3020
+ * `umd` or `iife`
3011
3021
  */
3012
- configEnvironment?: ObjectHook<(this: ConfigPluginContext, name: string, config: EnvironmentOptions, env: ConfigEnv & {
3013
- /**
3014
- * Whether this environment is SSR environment and `ssr.target` is set to `'webworker'`.
3015
- * Only intended to be used for backward compatibility.
3016
- */
3017
- isSsrTargetWebworker?: boolean;
3018
- }) => EnvironmentOptions | null | void | Promise<EnvironmentOptions | null | void>>;
3022
+ name?: string;
3019
3023
  /**
3020
- * Use this hook to read and store the final resolved vite config.
3024
+ * Output bundle formats. Defaults to `['es', 'umd']` for a single entry, or
3025
+ * `['es', 'cjs']` for multiple entries (`umd` and `iife` do not support
3026
+ * multiple entries).
3027
+ * @default ['es', 'umd']
3021
3028
  */
3022
- configResolved?: ObjectHook<(this: MinimalPluginContextWithoutEnvironment, config: ResolvedConfig) => void | Promise<void>>;
3029
+ formats?: LibraryFormats[];
3023
3030
  /**
3024
- * Configure the vite server. The hook receives the {@link ViteDevServer}
3025
- * instance. This can also be used to store a reference to the server
3026
- * for use in other hooks.
3027
- *
3028
- * The hooks will be called before internal middlewares are applied. A hook
3029
- * can return a post hook that will be called after internal middlewares
3030
- * are applied. Hook can be async functions and will be called in series.
3031
+ * The name of the package file output. The default file name is the name option
3032
+ * of the project package.json. It can also be defined as a function taking the
3033
+ * format as an argument.
3031
3034
  */
3032
- configureServer?: ObjectHook<ServerHook>;
3035
+ fileName?: string | ((format: ModuleFormat, entryName: string) => string);
3033
3036
  /**
3034
- * Configure the preview server. The hook receives the {@link PreviewServer}
3035
- * instance. This can also be used to store a reference to the server
3036
- * for use in other hooks.
3037
- *
3038
- * The hooks are called before other middlewares are applied. A hook can
3039
- * return a post hook that will be called after other middlewares are
3040
- * applied. Hooks can be async functions and will be called in series.
3037
+ * The name of the CSS file output if the library imports CSS. Defaults to the
3038
+ * same value as `build.lib.fileName` if it's set a string, otherwise it falls
3039
+ * back to the name option of the project package.json.
3041
3040
  */
3042
- configurePreviewServer?: ObjectHook<PreviewServerHook>;
3041
+ cssFileName?: string;
3042
+ }
3043
+ type LibraryFormats = "es" | "cjs" | "umd" | "iife";
3044
+ interface ModulePreloadOptions {
3043
3045
  /**
3044
- * Transform index.html.
3045
- * The hook receives the following arguments:
3046
- *
3047
- * - html: string
3048
- * - ctx: IndexHtmlTransformContext, which contains:
3049
- * - path: public path when served
3050
- * - filename: filename on disk
3051
- * - server?: ViteDevServer (only present during serve)
3052
- * - bundle?: rollup.OutputBundle (only present during build)
3053
- * - chunk?: rollup.OutputChunk
3054
- * - originalUrl?: string
3055
- *
3056
- * It can either return a transformed string, or a list of html tag
3057
- * descriptors that will be injected into the `<head>` or `<body>`.
3058
- *
3059
- * By default the transform is applied **after** vite's internal html
3060
- * transform. If you need to apply the transform before vite, use an object:
3061
- * `{ order: 'pre', handler: hook }`
3046
+ * Whether to inject a module preload polyfill.
3047
+ * Note: does not apply to library mode.
3048
+ * @default true
3062
3049
  */
3063
- transformIndexHtml?: IndexHtmlTransform;
3050
+ polyfill?: boolean;
3064
3051
  /**
3065
- * Build Environments
3066
- *
3052
+ * Resolve the list of dependencies to preload for a given dynamic import
3067
3053
  * @experimental
3068
3054
  */
3069
- buildApp?: ObjectHook<BuildAppHook>;
3055
+ resolveDependencies?: ResolveModulePreloadDependenciesFn;
3056
+ }
3057
+ interface ResolvedModulePreloadOptions {
3058
+ polyfill: boolean;
3059
+ resolveDependencies?: ResolveModulePreloadDependenciesFn;
3060
+ }
3061
+ type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: {
3062
+ hostId: string;
3063
+ hostType: "html" | "js";
3064
+ }) => string[];
3065
+ interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, "polyfillModulePreload">> {
3066
+ modulePreload: false | ResolvedModulePreloadOptions;
3067
+ }
3068
+ interface ResolvedBuildOptions extends Required<Omit<BuildOptions, "polyfillModulePreload">> {
3069
+ modulePreload: false | ResolvedModulePreloadOptions;
3070
+ }
3071
+ /**
3072
+ * Bundles a single environment for production.
3073
+ * Returns a Promise containing the build result.
3074
+ */
3075
+ export declare function build(inlineConfig?: InlineConfig): Promise<RolldownOutput | RolldownOutput[] | RolldownWatcher>;
3076
+ type RenderBuiltAssetUrl = (filename: string, type: {
3077
+ type: "asset" | "public";
3078
+ hostId: string;
3079
+ hostType: "js" | "css" | "html";
3080
+ ssr: boolean;
3081
+ }) => string | {
3082
+ relative?: boolean;
3083
+ runtime?: string;
3084
+ } | undefined;
3085
+ export declare class BuildEnvironment extends BaseEnvironment {
3086
+ mode: "build";
3087
+ isBuilt: boolean;
3088
+ constructor(name: string, config: ResolvedConfig, setup?: {
3089
+ options?: EnvironmentOptions;
3090
+ });
3091
+ init(): Promise<void>;
3092
+ }
3093
+ interface ViteBuilder {
3094
+ environments: Record<string, BuildEnvironment>;
3095
+ config: ResolvedConfig;
3096
+ buildApp(): Promise<void>;
3097
+ build(environment: BuildEnvironment): Promise<RolldownOutput | RolldownOutput[] | RolldownWatcher>;
3098
+ runDevTools(): Promise<void>;
3099
+ }
3100
+ interface BuilderOptions {
3070
3101
  /**
3071
- * Perform custom handling of HMR updates.
3072
- * The handler receives a context containing changed filename, timestamp, a
3073
- * list of modules affected by the file change, and the dev server instance.
3074
- *
3075
- * - The hook can return a filtered list of modules to narrow down the update.
3076
- * e.g. for a Vue SFC, we can narrow down the part to update by comparing
3077
- * the descriptors.
3078
- *
3079
- * - The hook can also return an empty array and then perform custom updates
3080
- * by sending a custom hmr payload via server.ws.send().
3102
+ * Whether to share the config instance among environments to align with the behavior of dev server.
3081
3103
  *
3082
- * - If the hook doesn't return a value, the hmr update will be performed as
3083
- * normal.
3104
+ * @default false
3105
+ * @experimental
3084
3106
  */
3085
- handleHotUpdate?: ObjectHook<(this: MinimalPluginContextWithoutEnvironment, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
3107
+ sharedConfigBuild?: boolean;
3086
3108
  /**
3087
- * This hook is not supported by Rolldown yet. But the type is declared for compatibility.
3109
+ * Whether to share the plugin instances among environments to align with the behavior of dev server.
3088
3110
  *
3089
- * @deprecated This hook is **not** deprecated. It is marked as deprecated just to make it clear that this hook is currently a no-op.
3111
+ * @default false
3112
+ * @experimental
3090
3113
  */
3091
- shouldTransformCachedModule?: ObjectHook<(this: PluginContext, options: {
3092
- code: string;
3093
- id: string;
3094
- meta: CustomPluginOptions;
3095
- moduleSideEffects: boolean | "no-treeshake";
3096
- }) => boolean | null | void>;
3114
+ sharedPlugins?: boolean;
3115
+ buildApp?: (builder: ViteBuilder) => Promise<void>;
3097
3116
  }
3098
- type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
3099
- type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & { [P in K]: NonNullable<Plugin[P]>; };
3100
- type Thenable<T> = T | Promise<T>;
3101
- type FalsyPlugin = false | null | undefined;
3102
- type PluginOption = Thenable<Plugin | {
3103
- name: string;
3104
- } | FalsyPlugin | PluginOption[]>;
3117
+ type ResolvedBuilderOptions = Required<BuilderOptions>;
3105
3118
  /**
3119
+ * Creates a ViteBuilder to orchestrate building multiple environments.
3106
3120
  * @experimental
3107
3121
  */
3108
- export declare function perEnvironmentPlugin(name: string, applyToEnvironment: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption): Plugin;
3122
+ export declare function createBuilder(inlineConfig?: InlineConfig, useLegacyBuilder?: null | boolean): Promise<ViteBuilder>;
3123
+ type BuildAppHook = (this: MinimalPluginContextWithoutEnvironment, builder: ViteBuilder) => Promise<void>;
3109
3124
  //#endregion
3110
3125
  //#region src/node/idResolver.d.ts
3111
3126
  type ResolveIdFn = (environment: PartialEnvironment, id: string, importer?: string, aliasOnly?: boolean) => Promise<string | undefined>;
@@ -3115,7 +3130,7 @@ type ResolveIdFn = (environment: PartialEnvironment, id: string, importer?: stri
3115
3130
  */
3116
3131
  export declare function createIdResolver(config: ResolvedConfig, options?: Partial<InternalResolveOptions>): ResolveIdFn;
3117
3132
  //#endregion
3118
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.26_tsx@4.23.12_yaml@2.9.0/node_modules/postcss-load-config/src/index.d.ts
3133
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.15_yaml@2.9.0/node_modules/postcss-load-config/src/index.d.ts
3119
3134
  type ConfigPlugin = Transformer | PostCSS.Plugin | Processor;
3120
3135
  interface Config {
3121
3136
  parser?: string | ProcessOptions['parser'] | false;
@@ -3248,32 +3263,15 @@ interface JsonOptions {
3248
3263
  stringify?: boolean | "auto";
3249
3264
  }
3250
3265
  //#endregion
3251
- //#region src/node/assetSource.d.ts
3252
- /**
3253
- * Defines which attributes of an HTML element should be treated as asset sources.
3254
- * Used in `html.additionalAssetSources` configuration.
3255
- */
3256
- interface HtmlAssetSource {
3257
- /**
3258
- * Attributes that contain a single asset URL.
3259
- * @example ['src', 'data-src-dark']
3260
- */
3261
- srcAttributes?: string[];
3262
- /**
3263
- * Attributes that contain srcset-format URLs.
3264
- * @example ['srcset', 'imagesrcset']
3265
- */
3266
- srcsetAttributes?: string[];
3267
- /**
3268
- * Called before handling an attribute to determine if it should be processed.
3269
- */
3270
- filter?: (data: HtmlAssetSourceFilterData) => boolean;
3271
- }
3272
- interface HtmlAssetSourceFilterData {
3273
- key: string;
3274
- value: string;
3275
- attributes: Record<string, string>;
3266
+ //#region src/node/plugins/oxc.d.ts
3267
+ interface OxcOptions extends Omit<rolldown_utils_TransformOptions, "cwd" | "sourceType" | "lang" | "sourcemap" | "helpers" | "inject" | "tsconfig" | "inputMap"> {
3268
+ include?: string | RegExp | ReadonlyArray<string | RegExp>;
3269
+ exclude?: string | RegExp | ReadonlyArray<string | RegExp>;
3270
+ jsxInject?: string;
3271
+ jsxRefreshInclude?: string | RegExp | ReadonlyArray<string | RegExp>;
3272
+ jsxRefreshExclude?: string | RegExp | ReadonlyArray<string | RegExp>;
3276
3273
  }
3274
+ export declare function transformWithOxc(code: string, filename: string, options?: rolldown_utils_TransformOptions, inMap?: object, config?: ResolvedConfig, watcher?: FSWatcher): Promise<Omit<rolldown_utils_TransformResult, "errors">>;
3277
3275
  //#endregion
3278
3276
  //#region src/node/ssr/index.d.ts
3279
3277
  type SSRTarget = "node" | "webworker";
@@ -3320,16 +3318,6 @@ interface ResolvedSSROptions extends SSROptions {
3320
3318
  optimizeDeps: SsrDepOptimizationConfig;
3321
3319
  }
3322
3320
  //#endregion
3323
- //#region src/node/plugins/oxc.d.ts
3324
- interface OxcOptions extends Omit<rolldown_utils_TransformOptions, "cwd" | "sourceType" | "lang" | "sourcemap" | "helpers" | "inject" | "tsconfig" | "inputMap"> {
3325
- include?: string | RegExp | ReadonlyArray<string | RegExp>;
3326
- exclude?: string | RegExp | ReadonlyArray<string | RegExp>;
3327
- jsxInject?: string;
3328
- jsxRefreshInclude?: string | RegExp | ReadonlyArray<string | RegExp>;
3329
- jsxRefreshExclude?: string | RegExp | ReadonlyArray<string | RegExp>;
3330
- }
3331
- export declare function transformWithOxc(code: string, filename: string, options?: rolldown_utils_TransformOptions, inMap?: object, config?: ResolvedConfig, watcher?: FSWatcher): Promise<Omit<rolldown_utils_TransformResult, "errors">>;
3332
- //#endregion
3333
3321
  //#region src/node/config.d.ts
3334
3322
  interface ConfigEnv {
3335
3323
  /**
@@ -3494,6 +3482,11 @@ interface UserConfig extends DefaultEnvironmentOptions {
3494
3482
  * @default process.cwd()
3495
3483
  */
3496
3484
  root?: string;
3485
+ /**
3486
+ * Path to the TypeScript configuration file. Relative paths are resolved
3487
+ * from the project root.
3488
+ */
3489
+ tsconfig?: string;
3497
3490
  /**
3498
3491
  * Base public path when served in development or production.
3499
3492
  * @default '/'
@@ -3659,7 +3652,6 @@ interface UserConfig extends DefaultEnvironmentOptions {
3659
3652
  appType?: AppType;
3660
3653
  /**
3661
3654
  * Enable devtools integration. Ensure that `@vitejs/devtools` is installed as a dependency.
3662
- * This feature is currently supported only in build mode.
3663
3655
  * @experimental
3664
3656
  * @default false
3665
3657
  */
@@ -3814,7 +3806,7 @@ interface ResolvedConfig extends Readonly<Omit<UserConfig, "plugins" | "css" | "
3814
3806
  /** @experimental */
3815
3807
  builder: ResolvedBuilderOptions | undefined;
3816
3808
  build: ResolvedBuildOptions;
3817
- devtools: ResolvedDevToolsConfig;
3809
+ devtools: ResolvedDevToolsConfig | false;
3818
3810
  preview: ResolvedPreviewOptions;
3819
3811
  ssr: ResolvedSSROptions;
3820
3812
  assetsInclude: (file: string) => boolean;
@@ -4066,4 +4058,4 @@ export declare const parseAst: typeof parseAst$1;
4066
4058
  export declare const parseAstAsync: typeof parseAstAsync$1;
4067
4059
  export declare const esbuildVersion = "0.25.0";
4068
4060
  //#endregion
4069
- export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type BindCLIShortcutsOptions, type BuildAppHook, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type ChunkMetadata, type CommonServerOptions, type ConfigEnv, type ConfigPluginContext, type Connect, type ConnectedPayload, type CorsOptions, type CorsOrigin, type CustomEventMap, type CustomPayload, type CustomPluginOptionsVite, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESTree, type Environment, type EnvironmentModuleGraph, type EnvironmentModuleNode, type EnvironmentOptions, type ErrorPayload, type EsbuildTransformOptions, type ExperimentalOptions, type ExportsData, type FSWatcher, type FetchFunction, type FetchModuleOptions, type FetchResult, type FetchableDevEnvironment, type FetchableDevEnvironmentContext, type FileSystemServeOptions, type FilterPattern, type FullReloadPayload, type GeneralImportGlobOptions, type HMRPayload, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotChannelListener, type HotPayload, type HotUpdateOptions, type HtmlAssetSource, type HtmlTagDescriptor, type index_d_exports as HttpProxy, type HttpServer, type ImportGlobFunction, type ImportGlobOptions, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InferCustomEventPayload, type InlineConfig, type InternalResolveOptions, type InvalidatePayload, type JsonOptions, type KnownAsTypeMap, type KnownQueryTypeMap, type LegacyOptions, type LessPreprocessorOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, type MinifyOptions, type MinifyResult, type MinimalPluginContextWithoutEnvironment, type ModuleGraph, type ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type NormalizedHotChannel, type NormalizedHotChannelClient, type NormalizedServerHotChannel, type OptimizedDepInfo, type OxcOptions, type ParseResult, type ParserOptions, type Plugin, type PluginContainer, type PluginHookUtils, type PluginOption, type Config as PostcssUserConfig, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type PrunePayload, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type Rolldown, type Rollup, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type RunnableDevEnvironment, type RunnableDevEnvironmentContext, type SSROptions, type SSRTarget, type SassPreprocessorOptions, type SendOptions, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions$1 as ServerOptions, type SkipInformation, type SsrDepOptimizationConfig, type StylusPreprocessorOptions, type Terser, type TerserOptions, type TransformOptions, type TransformResult, type Update, type UpdatePayload, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, Visitor, type VisitorObject, type ViteBuilder, type ViteDevServer, type WatchOptions, type WebSocket, type WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, type WebSocketServer, type WsOptions, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_EXTERNAL_CONDITIONS as defaultExternalConditions, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, esmExternalRequirePlugin, minify, minifySync, ssrTransform as moduleRunnerTransform, parse, parseSync, rolldownVersion, VERSION as version, withFilter };
4061
+ export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type BindCLIShortcutsOptions, type BuildAppHook, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type ChunkMetadata, type CommonServerOptions, type ConfigEnv, type ConfigPluginContext, type Connect, type ConnectedPayload, type CorsOptions, type CorsOrigin, type CustomEventMap, type CustomPayload, type CustomPluginOptionsVite, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESTree, type Environment, type EnvironmentModuleGraph, type EnvironmentModuleNode, type EnvironmentOptions, type ErrorPayload, type EsbuildTransformOptions, type ExperimentalOptions, type ExportsData, type FSWatcher, type FetchFunction, type FetchModuleOptions, type FetchResult, type FetchableDevEnvironment, type FetchableDevEnvironmentContext, type FileSystemServeOptions, type FilterPattern, type FullReloadPayload, type GeneralImportGlobOptions, type HMRPayload, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotChannelListener, type HotPayload, type HotUpdateOptions, type HtmlAssetSource, type HtmlTagDescriptor, type index_d_exports as HttpProxy, type HttpServer, type ImportGlobFunction, type ImportGlobOptions, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InferCustomEventPayload, type InlineConfig, type InternalResolveOptions, type InvalidatePayload, type JsonOptions, type KnownAsTypeMap, type KnownQueryTypeMap, type LegacyOptions, type LessPreprocessorOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, type MinifyOptions, type MinifyResult, type MinimalPluginContextWithoutEnvironment, type ModuleGraph, type ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type NormalizedHotChannel, type NormalizedHotChannelClient, type NormalizedServerHotChannel, type OptimizedDepInfo, type OxcOptions, type ParseResult, type ParserOptions, type Plugin, type PluginContainer, type PluginHookUtils, type PluginOption, type Config as PostcssUserConfig, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type PrunePayload, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedDevToolsConfig, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type Rolldown, type Rollup, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type RunnableDevEnvironment, type RunnableDevEnvironmentContext, type SSROptions, type SSRTarget, type SassPreprocessorOptions, type SendOptions, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions$1 as ServerOptions, type ServerWatchOptions, type SkipInformation, type SsrDepOptimizationConfig, type StylusPreprocessorOptions, type Terser, type TerserOptions, type TransformOptions, type TransformResult, type Update, type UpdatePayload, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, Visitor, type VisitorObject, type ViteBuilder, type ViteDevServer, type WatchOptions, type WebSocket, type WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, type WebSocketServer, type WsOptions, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_EXTERNAL_CONDITIONS as defaultExternalConditions, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, esmExternalRequirePlugin, minify, minifySync, ssrTransform as moduleRunnerTransform, parse, parseSync, rolldownVersion, VERSION as version, withFilter };