vite 6.0.0-beta.9 → 6.0.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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -1,7 +1,3 @@
1
- import { createRequire as __cjs_createRequire } from 'node:module';
2
-
3
- const require = __cjs_createRequire(import.meta.url);
4
- const __require = require;
5
1
  const UNDEFINED_CODE_POINTS = new Set([
6
2
  65534, 65535, 131070, 131071, 196606, 196607, 262142, 262143, 327678, 327679, 393214,
7
3
  393215, 458750, 458751, 524286, 524287, 589822, 589823, 655358, 655359, 720894,
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs__default from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { K as colors, E as createLogger, r as resolveConfig } from './chunks/dep-CG5ueZZV.js';
5
+ import { M as colors, G as createLogger, r as resolveConfig } from './chunks/dep-C6qYk3zB.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -19,7 +19,6 @@ import 'util';
19
19
  import 'net';
20
20
  import 'url';
21
21
  import 'http';
22
- import 'fs/promises';
23
22
  import 'stream';
24
23
  import 'os';
25
24
  import 'child_process';
@@ -32,17 +31,17 @@ import 'module';
32
31
  import 'node:readline';
33
32
  import 'node:process';
34
33
  import 'node:buffer';
34
+ import 'node:events';
35
35
  import 'crypto';
36
36
  import 'node:assert';
37
37
  import 'node:v8';
38
38
  import 'node:worker_threads';
39
- import 'node:events';
40
39
  import 'zlib';
41
40
  import 'buffer';
42
41
  import 'https';
43
42
  import 'tls';
44
43
  import 'assert';
45
- import 'querystring';
44
+ import 'node:querystring';
46
45
  import 'node:zlib';
47
46
 
48
47
  function toArr(any) {
@@ -741,7 +740,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
741
740
  `[boolean] force the optimizer to ignore the cache and re-bundle`
742
741
  ).action(async (root, options) => {
743
742
  filterDuplicateOptions(options);
744
- const { createServer } = await import('./chunks/dep-CG5ueZZV.js').then(function (n) { return n.O; });
743
+ const { createServer } = await import('./chunks/dep-C6qYk3zB.js').then(function (n) { return n.Q; });
745
744
  try {
746
745
  const server = await createServer({
747
746
  root,
@@ -834,7 +833,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
834
833
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
835
834
  async (root, options) => {
836
835
  filterDuplicateOptions(options);
837
- const { createBuilder } = await import('./chunks/dep-CG5ueZZV.js').then(function (n) { return n.P; });
836
+ const { createBuilder } = await import('./chunks/dep-C6qYk3zB.js').then(function (n) { return n.R; });
838
837
  const buildOptions = cleanGlobalCLIOptions(
839
838
  cleanBuilderCLIOptions(options)
840
839
  );
@@ -869,7 +868,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
869
868
  ).action(
870
869
  async (root, options) => {
871
870
  filterDuplicateOptions(options);
872
- const { optimizeDeps } = await import('./chunks/dep-CG5ueZZV.js').then(function (n) { return n.N; });
871
+ const { optimizeDeps } = await import('./chunks/dep-C6qYk3zB.js').then(function (n) { return n.P; });
873
872
  try {
874
873
  const config = await resolveConfig(
875
874
  {
@@ -895,7 +894,7 @@ ${e.stack}`),
895
894
  cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
896
895
  async (root, options) => {
897
896
  filterDuplicateOptions(options);
898
- const { preview } = await import('./chunks/dep-CG5ueZZV.js').then(function (n) { return n.Q; });
897
+ const { preview } = await import('./chunks/dep-C6qYk3zB.js').then(function (n) { return n.S; });
899
898
  try {
900
899
  const server = await preview({
901
900
  root,
@@ -42,14 +42,18 @@ const DEFAULT_MAIN_FIELDS = [
42
42
  // moment still uses this...
43
43
  "jsnext"
44
44
  ];
45
+ const DEFAULT_CLIENT_MAIN_FIELDS = Object.freeze(DEFAULT_MAIN_FIELDS);
46
+ const DEFAULT_SERVER_MAIN_FIELDS = Object.freeze(
47
+ DEFAULT_MAIN_FIELDS.filter((f) => f !== "browser")
48
+ );
45
49
  const DEV_PROD_CONDITION = `development|production`;
46
- const DEFAULT_CONDITIONS = [
47
- "module",
48
- "browser",
49
- "node",
50
- DEV_PROD_CONDITION
51
- ];
52
- const DEFAULT_EXTERNAL_CONDITIONS = ["node"];
50
+ const DEFAULT_CONDITIONS = ["module", "browser", "node", DEV_PROD_CONDITION];
51
+ const DEFAULT_CLIENT_CONDITIONS = Object.freeze(
52
+ DEFAULT_CONDITIONS.filter((c) => c !== "node")
53
+ );
54
+ const DEFAULT_SERVER_CONDITIONS = Object.freeze(
55
+ DEFAULT_CONDITIONS.filter((c) => c !== "browser")
56
+ );
53
57
  const ESBUILD_MODULES_TARGET = [
54
58
  "es2020",
55
59
  // support import.meta.url
@@ -58,15 +62,6 @@ const ESBUILD_MODULES_TARGET = [
58
62
  "chrome87",
59
63
  "safari14"
60
64
  ];
61
- const DEFAULT_EXTENSIONS = [
62
- ".mjs",
63
- ".js",
64
- ".mts",
65
- ".ts",
66
- ".jsx",
67
- ".tsx",
68
- ".json"
69
- ];
70
65
  const DEFAULT_CONFIG_FILES = [
71
66
  "vite.config.js",
72
67
  "vite.config.mjs",
@@ -104,6 +99,7 @@ const KNOWN_ASSET_TYPES = [
104
99
  "ico",
105
100
  "webp",
106
101
  "avif",
102
+ "cur",
107
103
  // media
108
104
  "mp4",
109
105
  "webm",
@@ -146,7 +142,6 @@ const DEFAULT_PREVIEW_PORT = 4173;
146
142
  const DEFAULT_ASSETS_INLINE_LIMIT = 4096;
147
143
  const METADATA_FILENAME = "_metadata.json";
148
144
  const ERR_OPTIMIZE_DEPS_PROCESSING_ERROR = "ERR_OPTIMIZE_DEPS_PROCESSING_ERROR";
149
- const ERR_OUTDATED_OPTIMIZED_DEP = "ERR_OUTDATED_OPTIMIZED_DEP";
150
145
  const ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR = "ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR";
151
146
 
152
- export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CONDITIONS, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_EXTERNAL_CONDITIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, DEV_PROD_CONDITION, ENV_ENTRY, ENV_PUBLIC_PATH, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_OUTDATED_OPTIMIZED_DEP, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, ROLLUP_HOOKS, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
147
+ export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CLIENT_CONDITIONS, DEFAULT_CLIENT_MAIN_FIELDS, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_PREVIEW_PORT, DEFAULT_SERVER_CONDITIONS, DEFAULT_SERVER_MAIN_FIELDS, DEP_VERSION_RE, DEV_PROD_CONDITION, ENV_ENTRY, ENV_PUBLIC_PATH, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, ROLLUP_HOOKS, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
@@ -6,7 +6,7 @@ export { parseAst, parseAstAsync } from 'rollup/parseAst';
6
6
  import * as http from 'node:http';
7
7
  import { OutgoingHttpHeaders, ClientRequestArgs, IncomingMessage, ClientRequest, Agent, Server, ServerResponse } from 'node:http';
8
8
  import { Http2SecureServer } from 'node:http2';
9
- import { Stats } from 'node:fs';
9
+ import * as fs from 'node:fs';
10
10
  import * as events from 'node:events';
11
11
  import { EventEmitter } from 'node:events';
12
12
  import { ServerOptions as HttpsServerOptions, Server as HttpsServer } from 'node:https';
@@ -63,107 +63,211 @@ interface ResolverObject {
63
63
  */
64
64
  type AliasOptions = readonly Alias[] | { [find: string]: string }
65
65
 
66
- // Inlined with the following changes:
67
- // 1. Rename `ChokidarOptions` to `WatchOptions` (compat with chokidar v3)
68
- // 2. Remove internal properties exposed from `FSWatcher`
69
- // 3. Remove unneeded types from the tweaks above
70
- // 4. Add spacing and formatted for readability
66
+ type AnymatchFn = (testString: string) => boolean
67
+ type AnymatchPattern = string | RegExp | AnymatchFn
68
+ type AnymatchMatcher = AnymatchPattern | AnymatchPattern[]
71
69
 
72
- // #region handler.d.ts
70
+ // Inlined to avoid extra dependency (chokidar is bundled in the published build)
73
71
 
74
- declare const EVENTS: {
75
- readonly ALL: 'all'
76
- readonly READY: 'ready'
77
- readonly ADD: 'add'
78
- readonly CHANGE: 'change'
79
- readonly ADD_DIR: 'addDir'
80
- readonly UNLINK: 'unlink'
81
- readonly UNLINK_DIR: 'unlinkDir'
82
- readonly RAW: 'raw'
83
- readonly ERROR: 'error'
84
- }
85
- type EventName = (typeof EVENTS)[keyof typeof EVENTS]
72
+ declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
73
+ options: WatchOptions
86
74
 
87
- type Path = string
75
+ /**
76
+ * Constructs a new FSWatcher instance with optional WatchOptions parameter.
77
+ */
78
+ constructor(options?: WatchOptions)
88
79
 
89
- // #endregion
80
+ /**
81
+ * When called, requests that the Node.js event loop not exit so long as the fs.FSWatcher is active.
82
+ * Calling watcher.ref() multiple times will have no effect.
83
+ */
84
+ ref(): this
90
85
 
91
- // #region index.d.ts
86
+ /**
87
+ * When called, the active fs.FSWatcher object will not require the Node.js event loop to remain active.
88
+ * If there is no other activity keeping the event loop running, the process may exit before the fs.FSWatcher object's callback is invoked.
89
+ * Calling watcher.unref() multiple times will have no effect.
90
+ */
91
+ unref(): this
92
92
 
93
- type AWF = {
94
- stabilityThreshold: number
95
- pollInterval: number
96
- }
97
- type BasicOpts = {
98
- persistent: boolean
99
- ignoreInitial: boolean
100
- followSymlinks: boolean
101
- cwd?: string
102
- usePolling: boolean
103
- interval: number
104
- binaryInterval: number
105
- alwaysStat?: boolean
106
- depth?: number
107
- ignorePermissionErrors: boolean
108
- atomic: boolean | number
109
- }
93
+ /**
94
+ * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
95
+ * string.
96
+ */
97
+ add(paths: string | ReadonlyArray<string>): this
110
98
 
111
- type WatchOptions = Partial<
112
- BasicOpts & {
113
- ignored: Matcher | Matcher[]
114
- awaitWriteFinish: boolean | Partial<AWF>
99
+ /**
100
+ * Stop watching files, directories, or glob patterns. Takes an array of strings or just one
101
+ * string.
102
+ */
103
+ unwatch(paths: string | ReadonlyArray<string>): this
104
+
105
+ /**
106
+ * Returns an object representing all the paths on the file system being watched by this
107
+ * `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
108
+ * the `cwd` option was used), and the values are arrays of the names of the items contained in
109
+ * each directory.
110
+ */
111
+ getWatched(): {
112
+ [directory: string]: string[]
115
113
  }
116
- >
117
114
 
118
- type FSWInstanceOptions = BasicOpts & {
119
- ignored: Matcher[]
120
- awaitWriteFinish: false | AWF
121
- }
115
+ /**
116
+ * Removes all listeners from watched files.
117
+ */
118
+ close(): Promise<void>
122
119
 
123
- type EmitArgs = [EventName, Path | Error, any?, any?, any?]
120
+ on(
121
+ event: 'add' | 'addDir' | 'change',
122
+ listener: (path: string, stats?: fs.Stats) => void,
123
+ ): this
124
+
125
+ on(
126
+ event: 'all',
127
+ listener: (
128
+ eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir',
129
+ path: string,
130
+ stats?: fs.Stats,
131
+ ) => void,
132
+ ): this
124
133
 
125
- type MatchFunction = (val: string, stats?: Stats) => boolean
134
+ /**
135
+ * Error occurred
136
+ */
137
+ on(event: 'error', listener: (error: Error) => void): this
126
138
 
127
- interface MatcherObject {
128
- path: string
129
- recursive?: boolean
139
+ /**
140
+ * Exposes the native Node `fs.FSWatcher events`
141
+ */
142
+ on(
143
+ event: 'raw',
144
+ listener: (eventName: string, path: string, details: any) => void,
145
+ ): this
146
+
147
+ /**
148
+ * Fires when the initial scan is complete
149
+ */
150
+ on(event: 'ready', listener: () => void): this
151
+
152
+ on(event: 'unlink' | 'unlinkDir', listener: (path: string) => void): this
153
+
154
+ on(event: string, listener: (...args: any[]) => void): this
130
155
  }
131
156
 
132
- type Matcher = string | RegExp | MatchFunction | MatcherObject
157
+ interface WatchOptions {
158
+ /**
159
+ * Indicates whether the process should continue to run as long as files are being watched. If
160
+ * set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`,
161
+ * even if the process continues to run.
162
+ */
163
+ persistent?: boolean
133
164
 
134
- /**
135
- * Watches files & directories for changes. Emitted events:
136
- * `add`, `addDir`, `change`, `unlink`, `unlinkDir`, `all`, `error`
137
- *
138
- * new FSWatcher()
139
- * .add(directories)
140
- * .on('add', path => log('File', path, 'was added'))
141
- */
142
- declare class FSWatcher extends EventEmitter {
143
- closed: boolean
144
- options: FSWInstanceOptions
165
+ /**
166
+ * ([anymatch](https://github.com/micromatch/anymatch)-compatible definition) Defines files/paths to
167
+ * be ignored. The whole relative or absolute path is tested, not just filename. If a function
168
+ * with two arguments is provided, it gets called twice per path - once with a single argument
169
+ * (the path), second time with two arguments (the path and the
170
+ * [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
171
+ */
172
+ ignored?: AnymatchMatcher
173
+
174
+ /**
175
+ * If set to `false` then `add`/`addDir` events are also emitted for matching paths while
176
+ * instantiating the watching as chokidar discovers these file paths (before the `ready` event).
177
+ */
178
+ ignoreInitial?: boolean
145
179
 
146
- constructor(_opts?: WatchOptions)
180
+ /**
181
+ * When `false`, only the symlinks themselves will be watched for changes instead of following
182
+ * the link references and bubbling events through the link's path.
183
+ */
184
+ followSymlinks?: boolean
147
185
 
148
186
  /**
149
- * Adds paths to be watched on an existing FSWatcher instance.
150
- * @param paths_ file or file list. Other arguments are unused
187
+ * The base directory from which watch `paths` are to be derived. Paths emitted with events will
188
+ * be relative to this.
151
189
  */
152
- add(paths_: Path | Path[], _origAdd?: string, _internal?: boolean): FSWatcher
190
+ cwd?: string
191
+
153
192
  /**
154
- * Close watchers or start ignoring events from specified paths.
193
+ * If set to true then the strings passed to .watch() and .add() are treated as literal path
194
+ * names, even if they look like globs.
195
+ *
196
+ * @default false
155
197
  */
156
- unwatch(paths_: Path | Path[]): FSWatcher
198
+ disableGlobbing?: boolean
199
+
157
200
  /**
158
- * Close watchers and remove all listeners from watched paths.
201
+ * Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU
202
+ * utilization, consider setting this to `false`. It is typically necessary to **set this to
203
+ * `true` to successfully watch files over a network**, and it may be necessary to successfully
204
+ * watch files in other non-standard situations. Setting to `true` explicitly on OS X overrides
205
+ * the `useFsEvents` default.
159
206
  */
160
- close(): Promise<void>
207
+ usePolling?: boolean
208
+
209
+ /**
210
+ * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
211
+ * and `fsevents` is available this supersedes the `usePolling` setting. When set to `false` on
212
+ * OS X, `usePolling: true` becomes the default.
213
+ */
214
+ useFsEvents?: boolean
215
+
216
+ /**
217
+ * If relying upon the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that
218
+ * may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is
219
+ * provided even in cases where it wasn't already available from the underlying watch events.
220
+ */
221
+ alwaysStat?: boolean
222
+
223
+ /**
224
+ * If set, limits how many levels of subdirectories will be traversed.
225
+ */
226
+ depth?: number
227
+
228
+ /**
229
+ * Interval of file system polling.
230
+ */
231
+ interval?: number
232
+
233
+ /**
234
+ * Interval of file system polling for binary files. ([see list of binary extensions](https://gi
235
+ * thub.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
236
+ */
237
+ binaryInterval?: number
238
+
239
+ /**
240
+ * Indicates whether to watch files that don't have read permissions if possible. If watching
241
+ * fails due to `EPERM` or `EACCES` with this set to `true`, the errors will be suppressed
242
+ * silently.
243
+ */
244
+ ignorePermissionErrors?: boolean
245
+
161
246
  /**
162
- * Expose list of watched paths
163
- * @returns for chaining
247
+ * `true` if `useFsEvents` and `usePolling` are `false`. Automatically filters out artifacts
248
+ * that occur when using editors that use "atomic writes" instead of writing directly to the
249
+ * source file. If a file is re-added within 100 ms of being deleted, Chokidar emits a `change`
250
+ * event rather than `unlink` then `add`. If the default of 100 ms does not work well for you,
251
+ * you can override it by setting `atomic` to a custom value, in milliseconds.
164
252
  */
165
- getWatched(): Record<string, string[]>
166
- emitWithAll(event: EventName, args: EmitArgs): void
253
+ atomic?: boolean | number
254
+
255
+ /**
256
+ * can be set to an object in order to adjust timing params:
257
+ */
258
+ awaitWriteFinish?: AwaitWriteFinishOptions | boolean
259
+ }
260
+
261
+ interface AwaitWriteFinishOptions {
262
+ /**
263
+ * Amount of time in milliseconds for a file size to remain constant before emitting its event.
264
+ */
265
+ stabilityThreshold?: number
266
+
267
+ /**
268
+ * File size polling interval.
269
+ */
270
+ pollInterval?: number
167
271
  }
168
272
 
169
273
  // Inlined to avoid extra dependency
@@ -2665,6 +2769,14 @@ type ResolvedBuilderOptions = Required<BuilderOptions>;
2665
2769
  declare function createBuilder(inlineConfig?: InlineConfig, useLegacyBuilder?: null | boolean): Promise<ViteBuilder>;
2666
2770
 
2667
2771
  type Environment = DevEnvironment | BuildEnvironment | UnknownEnvironment;
2772
+ /**
2773
+ * Creates a function that hides the complexities of a WeakMap with an initial value
2774
+ * to implement object metadata. Used by plugins to implement cross hooks per
2775
+ * environment metadata
2776
+ *
2777
+ * @experimental
2778
+ */
2779
+ declare function perEnvironmentState<State>(initial: (environment: Environment) => State): (context: PluginContext) => State;
2668
2780
 
2669
2781
  declare class EnvironmentPluginContainer {
2670
2782
  environment: Environment;
@@ -2772,7 +2884,7 @@ interface ServerOptions extends CommonServerOptions {
2772
2884
  };
2773
2885
  /**
2774
2886
  * chokidar watch options or null to disable FS watching
2775
- * https://github.com/paulmillr/chokidar#getting-started
2887
+ * https://github.com/paulmillr/chokidar/tree/3.6.0#api
2776
2888
  */
2777
2889
  watch?: WatchOptions | null;
2778
2890
  /**
@@ -2878,8 +2990,8 @@ interface ViteDevServer {
2878
2990
  httpServer: HttpServer | null;
2879
2991
  /**
2880
2992
  * Chokidar watcher instance. If `config.server.watch` is set to `null`,
2881
- * it will not watch any files and calling `add` will have no effect.
2882
- * https://github.com/paulmillr/chokidar#getting-started
2993
+ * it will not watch any files and calling `add` or `unwatch` will have no effect.
2994
+ * https://github.com/paulmillr/chokidar/tree/3.6.0#api
2883
2995
  */
2884
2996
  watcher: FSWatcher;
2885
2997
  /**
@@ -2991,10 +3103,6 @@ interface ResolvedServerUrls {
2991
3103
  }
2992
3104
  declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
2993
3105
 
2994
- type AnymatchFn = (testString: string) => boolean
2995
- type AnymatchPattern = string | RegExp | AnymatchFn
2996
- type AnymatchMatcher = AnymatchPattern | AnymatchPattern[]
2997
-
2998
3106
  interface ESBuildOptions extends esbuild_TransformOptions {
2999
3107
  include?: string | RegExp | string[] | RegExp[];
3000
3108
  exclude?: string | RegExp | string[] | RegExp[];
@@ -3009,6 +3117,21 @@ type ESBuildTransformResult = Omit<esbuild_TransformResult, 'map'> & {
3009
3117
  };
3010
3118
  declare function transformWithEsbuild(code: string, filename: string, options?: esbuild_TransformOptions, inMap?: object, config?: ResolvedConfig, watcher?: FSWatcher): Promise<ESBuildTransformResult>;
3011
3119
 
3120
+ interface JsonOptions {
3121
+ /**
3122
+ * Generate a named export for every property of the JSON object
3123
+ * @default true
3124
+ */
3125
+ namedExports?: boolean;
3126
+ /**
3127
+ * Generate performant output as JSON.parse("stringified").
3128
+ *
3129
+ * When set to 'auto', the data will be stringified only if the data is bigger than 10kB.
3130
+ * @default 'auto'
3131
+ */
3132
+ stringify?: boolean | 'auto';
3133
+ }
3134
+
3012
3135
  interface CSSOptions {
3013
3136
  /**
3014
3137
  * Using lightningcss is an experimental option to handle CSS modules,
@@ -3070,7 +3193,7 @@ interface CSSModulesOptions {
3070
3193
  */
3071
3194
  localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | ((originalClassName: string, generatedClassName: string, inputFile: string) => string);
3072
3195
  }
3073
- type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & {
3196
+ type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & Required<Pick<CSSOptions, 'transformer'>> & {
3074
3197
  lightningcss?: LightningCSSOptions;
3075
3198
  };
3076
3199
  interface PreprocessCSSResult {
@@ -3275,8 +3398,9 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
3275
3398
  /**
3276
3399
  * Define environments where this plugin should be active
3277
3400
  * By default, the plugin is active in all environments
3401
+ * @experimental
3278
3402
  */
3279
- applyToEnvironment?: (environment: Environment) => boolean;
3403
+ applyToEnvironment?: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption;
3280
3404
  /**
3281
3405
  * Modify vite config before it's resolved. The hook can either mutate the
3282
3406
  * passed-in config directly, or return a partial config object that will be
@@ -3296,7 +3420,13 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
3296
3420
  * hook instead of the config hook. Leaving the config hook only for modifying the root
3297
3421
  * default environment config.
3298
3422
  */
3299
- configEnvironment?: ObjectHook<(this: void, name: string, config: EnvironmentOptions, env: ConfigEnv) => EnvironmentOptions | null | void | Promise<EnvironmentOptions | null | void>>;
3423
+ configEnvironment?: ObjectHook<(this: void, name: string, config: EnvironmentOptions, env: ConfigEnv & {
3424
+ /**
3425
+ * Whether this environment is SSR environment and `ssr.target` is set to `'webworker'`.
3426
+ * Only intended to be used for backward compatibility.
3427
+ */
3428
+ isSsrTargetWebworker?: boolean;
3429
+ }) => EnvironmentOptions | null | void | Promise<EnvironmentOptions | null | void>>;
3300
3430
  /**
3301
3431
  * Use this hook to read and store the final resolved vite config.
3302
3432
  */
@@ -3361,21 +3491,10 @@ type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
3361
3491
  type Thenable<T> = T | Promise<T>;
3362
3492
  type FalsyPlugin = false | null | undefined;
3363
3493
  type PluginOption = Thenable<Plugin | FalsyPlugin | PluginOption[]>;
3364
-
3365
- interface JsonOptions {
3366
- /**
3367
- * Generate a named export for every property of the JSON object
3368
- * @default true
3369
- */
3370
- namedExports?: boolean;
3371
- /**
3372
- * Generate performant output as JSON.parse("stringified").
3373
- *
3374
- * When set to 'auto', the data will be stringified only if the data is bigger than 10kB.
3375
- * @default 'auto'
3376
- */
3377
- stringify?: boolean | 'auto';
3378
- }
3494
+ /**
3495
+ * @experimental
3496
+ */
3497
+ declare function perEnvironmentPlugin(name: string, applyToEnvironment: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption): Plugin;
3379
3498
 
3380
3499
  type SSRTarget = 'node' | 'webworker';
3381
3500
  type SsrDepOptimizationConfig = DepOptimizationConfig;
@@ -3413,6 +3532,7 @@ interface SSROptions {
3413
3532
  * @default []
3414
3533
  */
3415
3534
  externalConditions?: string[];
3535
+ mainFields?: string[];
3416
3536
  };
3417
3537
  }
3418
3538
  interface ResolvedSSROptions extends SSROptions {
@@ -3502,7 +3622,9 @@ interface DevEnvironmentOptions {
3502
3622
  */
3503
3623
  moduleRunnerTransform?: boolean;
3504
3624
  }
3505
- type ResolvedDevEnvironmentOptions = Required<DevEnvironmentOptions>;
3625
+ type ResolvedDevEnvironmentOptions = Omit<Required<DevEnvironmentOptions>, 'sourcemapIgnoreList'> & {
3626
+ sourcemapIgnoreList: Exclude<DevEnvironmentOptions['sourcemapIgnoreList'], false | undefined>;
3627
+ };
3506
3628
  type AllResolveOptions = ResolveOptions & {
3507
3629
  alias?: AliasOptions;
3508
3630
  };
@@ -3784,7 +3906,7 @@ interface InlineConfig extends UserConfig {
3784
3906
  configFile?: string | false;
3785
3907
  envFile?: false;
3786
3908
  }
3787
- type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build' | 'dev' | 'environments'> & {
3909
+ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'json' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build' | 'dev' | 'environments' | 'server' | 'preview'> & {
3788
3910
  configFile: string | undefined;
3789
3911
  configFileDependencies: string[];
3790
3912
  inlineConfig: InlineConfig;
@@ -3803,6 +3925,7 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
3803
3925
  };
3804
3926
  plugins: readonly Plugin[];
3805
3927
  css: ResolvedCSSOptions;
3928
+ json: Required<JsonOptions>;
3806
3929
  esbuild: ESBuildOptions | false;
3807
3930
  server: ResolvedServerOptions;
3808
3931
  dev: ResolvedDevEnvironmentOptions;
@@ -3865,7 +3988,7 @@ interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, 'root' | '
3865
3988
  */
3866
3989
  declare function createServerModuleRunner(environment: DevEnvironment, options?: ServerModuleRunnerOptions): ModuleRunner;
3867
3990
 
3868
- declare function createRunnableDevEnvironment(name: string, config: ResolvedConfig, context?: RunnableDevEnvironmentContext): DevEnvironment;
3991
+ declare function createRunnableDevEnvironment(name: string, config: ResolvedConfig, context?: RunnableDevEnvironmentContext): RunnableDevEnvironment;
3869
3992
  interface RunnableDevEnvironmentContext extends Omit<DevEnvironmentContext, 'hot'> {
3870
3993
  runner?: (environment: RunnableDevEnvironment, options?: ServerModuleRunnerOptions) => ModuleRunner;
3871
3994
  runnerOptions?: ServerModuleRunnerOptions;
@@ -3902,6 +4025,10 @@ declare function ssrTransform(code: string, inMap: SourceMap | {
3902
4025
  } | null, url: string, originalCode: string, options?: ModuleRunnerTransformOptions): Promise<TransformResult | null>;
3903
4026
 
3904
4027
  declare const VERSION: string;
4028
+ declare const DEFAULT_CLIENT_MAIN_FIELDS: readonly string[];
4029
+ declare const DEFAULT_SERVER_MAIN_FIELDS: readonly string[];
4030
+ declare const DEFAULT_CLIENT_CONDITIONS: readonly string[];
4031
+ declare const DEFAULT_SERVER_CONDITIONS: readonly string[];
3905
4032
 
3906
4033
  declare const isCSSRequest: (request: string) => boolean;
3907
4034
  /**
@@ -3976,4 +4103,4 @@ interface ManifestChunk {
3976
4103
  dynamicImports?: string[];
3977
4104
  }
3978
4105
 
3979
- export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type EnvironmentOptions, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotChannelListener, type HotUpdateOptions, type HtmlTagDescriptor, HttpProxy, type HttpServer, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LessPreprocessorOptions, type LibraryFormats, type LibraryOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, 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 RollupCommonJSOptions, type RollupDynamicImportVarsOptions, RunnableDevEnvironment, type RunnableDevEnvironmentContext, type SSROptions, type SSRTarget, type SassPreprocessorOptions, type SendOptions, type ServerHMRChannel, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationConfig, type StylusPreprocessorOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteBuilder, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createBuilder, createFilter, createIdResolver, createLogger, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
4106
+ export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type EnvironmentOptions, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotChannelListener, type HotUpdateOptions, type HtmlTagDescriptor, HttpProxy, type HttpServer, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LessPreprocessorOptions, type LibraryFormats, type LibraryOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, 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 RollupCommonJSOptions, type RollupDynamicImportVarsOptions, RunnableDevEnvironment, type RunnableDevEnvironmentContext, type SSROptions, type SSRTarget, type SassPreprocessorOptions, type SendOptions, type ServerHMRChannel, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationConfig, type StylusPreprocessorOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteBuilder, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createBuilder, createFilter, createIdResolver, createLogger, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, perEnvironmentPlugin, perEnvironmentState, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };