vite 5.0.0-beta.9 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,10 @@ import { PluginHooks, RollupError, SourceMap, ModuleInfo, PartialResolvedId, Inp
3
3
  import * as rollup from 'rollup';
4
4
  export { rollup as Rollup };
5
5
  export { VERSION as rollupVersion } from 'rollup';
6
+ export { parseAst, parseAstAsync } from 'rollup/parseAst';
6
7
  import * as http from 'node:http';
7
8
  import { OutgoingHttpHeaders, ClientRequestArgs, IncomingMessage, ClientRequest, Agent, Server, ServerResponse } from 'node:http';
9
+ import { Http2SecureServer } from 'node:http2';
8
10
  import * as fs from 'node:fs';
9
11
  import * as events from 'node:events';
10
12
  import { EventEmitter } from 'node:events';
@@ -53,7 +55,7 @@ interface ResolverObject {
53
55
  * in that the first defined rules are applied first.
54
56
  *
55
57
  * This is passed to \@rollup/plugin-alias as the "entries" field
56
- * https:
58
+ * https://github.com/rollup/plugins/tree/master/packages/alias#entries
57
59
  */
58
60
  type AliasOptions = readonly Alias[] | { [find: string]: string }
59
61
 
@@ -61,6 +63,8 @@ type AnymatchFn = (testString: string) => boolean
61
63
  type AnymatchPattern = string | RegExp | AnymatchFn
62
64
  type AnymatchMatcher = AnymatchPattern | AnymatchPattern[]
63
65
 
66
+ // Inlined to avoid extra dependency (chokidar is bundled in the published build)
67
+
64
68
  declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
65
69
  options: WatchOptions
66
70
 
@@ -142,11 +146,11 @@ interface WatchOptions {
142
146
  persistent?: boolean
143
147
 
144
148
  /**
145
- * ([anymatch](https:
149
+ * ([anymatch](https://github.com/micromatch/anymatch)-compatible definition) Defines files/paths to
146
150
  * be ignored. The whole relative or absolute path is tested, not just filename. If a function
147
151
  * with two arguments is provided, it gets called twice per path - once with a single argument
148
152
  * (the path), second time with two arguments (the path and the
149
- * [`fs.Stats`](https:
153
+ * [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
150
154
  */
151
155
  ignored?: AnymatchMatcher
152
156
 
@@ -193,7 +197,7 @@ interface WatchOptions {
193
197
  useFsEvents?: boolean
194
198
 
195
199
  /**
196
- * If relying upon the [`fs.Stats`](https:
200
+ * If relying upon the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that
197
201
  * may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is
198
202
  * provided even in cases where it wasn't already available from the underlying watch events.
199
203
  */
@@ -210,7 +214,7 @@ interface WatchOptions {
210
214
  interval?: number
211
215
 
212
216
  /**
213
- * Interval of file system polling for binary files. ([see list of binary extensions](https:
217
+ * Interval of file system polling for binary files. ([see list of binary extensions](https://gi
214
218
  * thub.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
215
219
  */
216
220
  binaryInterval?: number
@@ -249,6 +253,9 @@ interface AwaitWriteFinishOptions {
249
253
  pollInterval?: number
250
254
  }
251
255
 
256
+ // Inlined to avoid extra dependency
257
+ // MIT Licensed https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE
258
+
252
259
  declare namespace Connect {
253
260
  export type ServerHandle = HandleFunction | http.Server
254
261
 
@@ -349,6 +356,9 @@ declare namespace Connect {
349
356
  }
350
357
  }
351
358
 
359
+ // Inlined to avoid extra dependency
360
+ // MIT Licensed https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE
361
+
352
362
  declare namespace HttpProxy {
353
363
  export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed
354
364
 
@@ -639,7 +649,7 @@ interface CommonServerOptions {
639
649
  * Enable TLS + HTTP/2.
640
650
  * Note: this downgrades to TLS only when the proxy option is also used.
641
651
  */
642
- https?: boolean | HttpsServerOptions;
652
+ https?: HttpsServerOptions;
643
653
  /**
644
654
  * Open browser window on startup
645
655
  */
@@ -647,18 +657,18 @@ interface CommonServerOptions {
647
657
  /**
648
658
  * Configure custom proxy rules for the dev server. Expects an object
649
659
  * of `{ key: options }` pairs.
650
- * Uses [`http-proxy`](https:
651
- * Full options [here](https:
660
+ * Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
661
+ * Full options [here](https://github.com/http-party/node-http-proxy#options).
652
662
  *
653
663
  * Example `vite.config.js`:
654
664
  * ``` js
655
665
  * module.exports = {
656
666
  * proxy: {
657
- *
658
- * '/foo': 'http:
659
- *
667
+ * // string shorthand
668
+ * '/foo': 'http://localhost:4567/foo',
669
+ * // with options
660
670
  * '/api': {
661
- * target: 'http:
671
+ * target: 'http://jsonplaceholder.typicode.com',
662
672
  * changeOrigin: true,
663
673
  * rewrite: path => path.replace(/^\/api/, '')
664
674
  * }
@@ -669,7 +679,7 @@ interface CommonServerOptions {
669
679
  proxy?: Record<string, string | ProxyOptions>;
670
680
  /**
671
681
  * Configure CORS for the dev server.
672
- * Uses https:
682
+ * Uses https://github.com/expressjs/cors.
673
683
  * Set to `true` to allow all methods from any origin, or configure separately
674
684
  * using an object.
675
685
  */
@@ -680,7 +690,7 @@ interface CommonServerOptions {
680
690
  headers?: OutgoingHttpHeaders;
681
691
  }
682
692
  /**
683
- * https:
693
+ * https://github.com/expressjs/cors#configuration-options
684
694
  */
685
695
  interface CorsOptions {
686
696
  origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
@@ -709,13 +719,13 @@ interface PreviewServer {
709
719
  * - Can also be used as the handler function of a custom http server
710
720
  * or as a middleware in any connect-style Node.js frameworks
711
721
  *
712
- * https:
722
+ * https://github.com/senchalabs/connect#use-middleware
713
723
  */
714
724
  middlewares: Connect.Server;
715
725
  /**
716
726
  * native Node http server instance
717
727
  */
718
- httpServer: http.Server;
728
+ httpServer: HttpServer;
719
729
  /**
720
730
  * The resolved urls Vite prints on the CLI.
721
731
  * null before server is listening.
@@ -738,10 +748,14 @@ declare function preview(inlineConfig?: InlineConfig): Promise<PreviewServer>;
738
748
 
739
749
  type BindCLIShortcutsOptions<Server = ViteDevServer | PreviewServer> = {
740
750
  /**
741
- * Print a one line hint to the terminal.
751
+ * Print a one-line shortcuts "help" hint to the terminal
742
752
  */
743
753
  print?: boolean;
744
- customShortcuts?: (CLIShortcut<Server> | undefined | null)[];
754
+ /**
755
+ * Custom shortcuts to run when a key is pressed. These shortcuts take priority
756
+ * over the default shortcuts if they have the same keys (except the `h` key).
757
+ */
758
+ customShortcuts?: CLIShortcut<Server>[];
745
759
  };
746
760
  type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
747
761
  key: string;
@@ -811,14 +825,19 @@ declare class ModuleGraph {
811
825
  getModuleById(id: string): ModuleNode | undefined;
812
826
  getModulesByFile(file: string): Set<ModuleNode> | undefined;
813
827
  onFileChange(file: string): void;
814
- invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean, hmrBoundaries?: ModuleNode[]): void;
828
+ invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean,
829
+ ): void;
815
830
  invalidateAll(): void;
816
831
  /**
817
832
  * Update the module graph based on a module's updated imports information
818
833
  * If there are dependencies that no longer have any importers, they are
819
834
  * returned as a Set.
835
+ *
836
+ * @param staticImportedUrls Subset of `importedModules` where they're statically imported in code.
837
+ * This is only used for soft invalidations so `undefined` is fine but may cause more runtime processing.
820
838
  */
821
- updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, importedBindings: Map<string, Set<string>> | null, acceptedModules: Set<string | ModuleNode>, acceptedExports: Set<string> | null, isSelfAccepting: boolean, ssr?: boolean): Promise<Set<ModuleNode> | undefined>;
839
+ updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, importedBindings: Map<string, Set<string>> | null, acceptedModules: Set<string | ModuleNode>, acceptedExports: Set<string> | null, isSelfAccepting: boolean, ssr?: boolean,
840
+ ): Promise<Set<ModuleNode> | undefined>;
822
841
  ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>;
823
842
  createFileOnlyEntry(file: string): ModuleNode;
824
843
  resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
@@ -826,7 +845,7 @@ declare class ModuleGraph {
826
845
 
827
846
  /**
828
847
  * This file is refactored into TypeScript based on
829
- * https:
848
+ * https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/rollup-plugin-container.js
830
849
  */
831
850
 
832
851
  interface PluginContainer {
@@ -834,7 +853,7 @@ interface PluginContainer {
834
853
  getModuleInfo(id: string): ModuleInfo | null;
835
854
  buildStart(options: InputOptions): Promise<void>;
836
855
  resolveId(id: string, importer?: string, options?: {
837
- assertions?: Record<string, string>;
856
+ attributes?: Record<string, string>;
838
857
  custom?: CustomPluginOptions;
839
858
  skip?: Set<Plugin>;
840
859
  ssr?: boolean;
@@ -852,12 +871,18 @@ interface PluginContainer {
852
871
  load(id: string, options?: {
853
872
  ssr?: boolean;
854
873
  }): Promise<LoadResult | null>;
874
+ watchChange(id: string, change: {
875
+ event: 'create' | 'update' | 'delete';
876
+ }): Promise<void>;
855
877
  close(): Promise<void>;
856
878
  }
857
879
 
880
+ // Modified and inlined to avoid extra dependency
881
+ // Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ws/index.d.ts
882
+
858
883
  declare const WebSocketAlias: typeof WebSocket
859
884
  interface WebSocketAlias extends WebSocket {}
860
-
885
+ // WebSocket socket.
861
886
  declare class WebSocket extends EventEmitter {
862
887
  /** The connection is not yet open. */
863
888
  static readonly CONNECTING: 0
@@ -935,7 +960,7 @@ declare class WebSocket extends EventEmitter {
935
960
  */
936
961
  resume(): void
937
962
 
938
-
963
+ // HTML5 WebSocket events
939
964
  addEventListener(
940
965
  method: 'message',
941
966
  cb: (event: WebSocket.MessageEvent) => void,
@@ -974,7 +999,7 @@ declare class WebSocket extends EventEmitter {
974
999
  cb: (event: WebSocket.Event) => void,
975
1000
  ): void
976
1001
 
977
-
1002
+ // Events
978
1003
  on(
979
1004
  event: 'close',
980
1005
  listener: (this: WebSocket, code: number, reason: Buffer) => void,
@@ -1125,7 +1150,7 @@ declare class WebSocket extends EventEmitter {
1125
1150
  listener: (...args: any[]) => void,
1126
1151
  ): this
1127
1152
  }
1128
-
1153
+ // tslint:disable-line no-empty-interface
1129
1154
 
1130
1155
  declare namespace WebSocket {
1131
1156
  /**
@@ -1270,7 +1295,7 @@ declare namespace WebSocket {
1270
1295
  port: number
1271
1296
  }
1272
1297
 
1273
-
1298
+ // WebSocket Server
1274
1299
  class Server<T extends WebSocket = WebSocket> extends EventEmitter {
1275
1300
  options: ServerOptions
1276
1301
  path: string
@@ -1288,7 +1313,7 @@ declare namespace WebSocket {
1288
1313
  ): void
1289
1314
  shouldHandle(request: IncomingMessage): boolean | Promise<boolean>
1290
1315
 
1291
-
1316
+ // Events
1292
1317
  on(
1293
1318
  event: 'connection',
1294
1319
  cb: (this: Server<T>, socket: T, request: IncomingMessage) => void,
@@ -1375,11 +1400,11 @@ declare namespace WebSocket {
1375
1400
  }
1376
1401
 
1377
1402
  const WebSocketServer: typeof Server
1378
- interface WebSocketServer extends Server {}
1403
+ interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface
1379
1404
  const WebSocket: typeof WebSocketAlias
1380
- interface WebSocket extends WebSocketAlias {}
1405
+ interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface
1381
1406
 
1382
-
1407
+ // WebSocket stream
1383
1408
  function createWebSocketStream(
1384
1409
  websocket: WebSocket,
1385
1410
  options?: DuplexOptions,
@@ -1476,14 +1501,21 @@ interface ServerOptions extends CommonServerOptions {
1476
1501
  };
1477
1502
  /**
1478
1503
  * chokidar watch options or null to disable FS watching
1479
- * https:
1504
+ * https://github.com/paulmillr/chokidar#api
1480
1505
  */
1481
1506
  watch?: WatchOptions | null;
1482
1507
  /**
1483
1508
  * Create Vite dev server to be used as a middleware in an existing server
1484
1509
  * @default false
1485
1510
  */
1486
- middlewareMode?: boolean | 'html' | 'ssr';
1511
+ middlewareMode?: boolean | {
1512
+ /**
1513
+ * Parent server instance to attach to
1514
+ *
1515
+ * This is needed to proxy WebSocket connections to the parent server.
1516
+ */
1517
+ server: http.Server;
1518
+ };
1487
1519
  /**
1488
1520
  * Options for files served via '/\@fs/'.
1489
1521
  */
@@ -1491,7 +1523,7 @@ interface ServerOptions extends CommonServerOptions {
1491
1523
  /**
1492
1524
  * Origin for the generated asset URLs.
1493
1525
  *
1494
- * @example `http:
1526
+ * @example `http://127.0.0.1:8080`
1495
1527
  */
1496
1528
  origin?: string;
1497
1529
  /**
@@ -1501,7 +1533,7 @@ interface ServerOptions extends CommonServerOptions {
1501
1533
  preTransformRequests?: boolean;
1502
1534
  /**
1503
1535
  * Whether or not to ignore-list source files in the dev server sourcemap, used to populate
1504
- * the [`x_google_ignoreList` source map extension](https:
1536
+ * the [`x_google_ignoreList` source map extension](https://developer.chrome.com/blog/devtools-better-angular-debugging/#the-x_google_ignorelist-source-map-extension).
1505
1537
  *
1506
1538
  * By default, it excludes all paths containing `node_modules`. You can pass `false` to
1507
1539
  * disable this behavior, or, for full control, a function that takes the source path and
@@ -1541,6 +1573,7 @@ interface FileSystemServeOptions {
1541
1573
  deny?: string[];
1542
1574
  }
1543
1575
  type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
1576
+ type HttpServer = http.Server | Http2SecureServer;
1544
1577
  interface ViteDevServer {
1545
1578
  /**
1546
1579
  * The resolved vite config object
@@ -1552,17 +1585,17 @@ interface ViteDevServer {
1552
1585
  * - Can also be used as the handler function of a custom http server
1553
1586
  * or as a middleware in any connect-style Node.js frameworks
1554
1587
  *
1555
- * https:
1588
+ * https://github.com/senchalabs/connect#use-middleware
1556
1589
  */
1557
1590
  middlewares: Connect.Server;
1558
1591
  /**
1559
1592
  * native Node http server instance
1560
1593
  * will be null in middleware mode
1561
1594
  */
1562
- httpServer: http.Server | null;
1595
+ httpServer: HttpServer | null;
1563
1596
  /**
1564
1597
  * chokidar watcher instance
1565
- * https:
1598
+ * https://github.com/paulmillr/chokidar#api
1566
1599
  */
1567
1600
  watcher: FSWatcher;
1568
1601
  /**
@@ -1588,6 +1621,12 @@ interface ViteDevServer {
1588
1621
  * without going through the http request pipeline.
1589
1622
  */
1590
1623
  transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
1624
+ /**
1625
+ * Same as `transformRequest` but only warm up the URLs so the next request
1626
+ * will already be cached. The function will never throw as it handles and
1627
+ * reports errors internally.
1628
+ */
1629
+ warmupRequest(url: string, options?: TransformOptions): Promise<void>;
1591
1630
  /**
1592
1631
  * Apply vite built-in HTML transforms and any plugin HTML transforms.
1593
1632
  */
@@ -1820,10 +1859,10 @@ interface RollupCommonJSOptions {
1820
1859
  * imports i.e.
1821
1860
  *
1822
1861
  * ```js
1823
- *
1862
+ * // input
1824
1863
  * const foo = require('foo');
1825
1864
  *
1826
- *
1865
+ * // output
1827
1866
  * import * as foo from 'foo';
1828
1867
  * ```
1829
1868
  *
@@ -1915,6 +1954,10 @@ interface RollupDynamicImportVarsOptions {
1915
1954
  warnOnError?: boolean
1916
1955
  }
1917
1956
 
1957
+ // Modified and inlined to avoid extra dependency
1958
+ // Source: https://github.com/terser/terser/blob/master/tools/terser.d.ts
1959
+ // BSD Licensed https://github.com/terser/terser/blob/master/LICENSE
1960
+
1918
1961
  declare namespace Terser {
1919
1962
  export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
1920
1963
 
@@ -2149,13 +2192,13 @@ interface BuildOptions {
2149
2192
  *
2150
2193
  * Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
2151
2194
  * transpile targeting browsers that natively support dynamic es module imports.
2152
- * https:
2195
+ * https://caniuse.com/es6-module-dynamic-import
2153
2196
  *
2154
2197
  * Another special value is 'esnext' - which only performs minimal transpiling
2155
2198
  * (for minification compat) and assumes native dynamic imports support.
2156
2199
  *
2157
- * For custom targets, see https:
2158
- * https:
2200
+ * For custom targets, see https://esbuild.github.io/api/#target and
2201
+ * https://esbuild.github.io/content-types/#javascript for more details.
2159
2202
  * @default 'modules'
2160
2203
  */
2161
2204
  target?: 'modules' | esbuild_TransformOptions['target'] | false;
@@ -2229,7 +2272,7 @@ interface BuildOptions {
2229
2272
  minify?: boolean | 'terser' | 'esbuild';
2230
2273
  /**
2231
2274
  * Options for terser
2232
- * https:
2275
+ * https://terser.org/docs/api-reference#minify-options
2233
2276
  *
2234
2277
  * In addition, you can also pass a `maxWorkers: number` option to specify the
2235
2278
  * max number of workers to spawn. Defaults to the number of CPUs minus 1.
@@ -2237,7 +2280,7 @@ interface BuildOptions {
2237
2280
  terserOptions?: TerserOptions;
2238
2281
  /**
2239
2282
  * Will be merged with internal rollup options.
2240
- * https:
2283
+ * https://rollupjs.org/configuration-options/
2241
2284
  */
2242
2285
  rollupOptions?: RollupOptions;
2243
2286
  /**
@@ -2320,7 +2363,7 @@ interface BuildOptions {
2320
2363
  chunkSizeWarningLimit?: number;
2321
2364
  /**
2322
2365
  * Rollup watch options
2323
- * https:
2366
+ * https://rollupjs.org/configuration-options/#watch
2324
2367
  * @default null
2325
2368
  */
2326
2369
  watch?: WatcherOptions | null;
@@ -2447,7 +2490,7 @@ interface DepOptimizationConfig {
2447
2490
  * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
2448
2491
  * - `plugins` are merged with Vite's dep plugin
2449
2492
  *
2450
- * https:
2493
+ * https://esbuild.github.io/api
2451
2494
  */
2452
2495
  esbuildOptions?: Omit<esbuild_BuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
2453
2496
  /**
@@ -2485,7 +2528,7 @@ type DepOptimizationOptions = DepOptimizationConfig & {
2485
2528
  *
2486
2529
  * If neither of these fit your needs, you can specify custom entries using
2487
2530
  * this option - the value should be a fast-glob pattern or array of patterns
2488
- * (https:
2531
+ * (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
2489
2532
  * vite project root. This will overwrite default entries inference.
2490
2533
  */
2491
2534
  entries?: string | string[];
@@ -2592,14 +2635,9 @@ interface ResolvedSSROptions extends SSROptions {
2592
2635
 
2593
2636
  interface ResolveOptions {
2594
2637
  /**
2595
- * @default ['module', 'jsnext:main', 'jsnext']
2638
+ * @default ['browser', 'module', 'jsnext:main', 'jsnext']
2596
2639
  */
2597
2640
  mainFields?: string[];
2598
- /**
2599
- * @deprecated In future, `mainFields` should be used instead.
2600
- * @default true
2601
- */
2602
- browserField?: boolean;
2603
2641
  conditions?: string[];
2604
2642
  /**
2605
2643
  * @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
@@ -2635,6 +2673,8 @@ interface InternalResolveOptions extends Required<ResolveOptions> {
2635
2673
  shouldExternalize?: (id: string, importer?: string) => boolean | undefined;
2636
2674
  }
2637
2675
 
2676
+ // This file is autogenerated by build-prefixes.js. DO NOT EDIT!
2677
+
2638
2678
  interface Targets {
2639
2679
  android?: number,
2640
2680
  chrome?: number,
@@ -2698,7 +2738,7 @@ interface CSSOptions {
2698
2738
  */
2699
2739
  transformer?: 'postcss' | 'lightningcss';
2700
2740
  /**
2701
- * https:
2741
+ * https://github.com/css-modules/postcss-modules
2702
2742
  */
2703
2743
  modules?: CSSModulesOptions | false;
2704
2744
  preprocessorOptions?: Record<string, any>;
@@ -2720,6 +2760,7 @@ interface CSSModulesOptions {
2720
2760
  getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
2721
2761
  scopeBehaviour?: 'global' | 'local';
2722
2762
  globalModulePaths?: RegExp[];
2763
+ exportGlobals?: boolean;
2723
2764
  generateScopedName?: string | ((name: string, filename: string, css: string) => string);
2724
2765
  hashPrefix?: string;
2725
2766
  /**
@@ -2899,7 +2940,7 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
2899
2940
  * extend hooks with ssr flag
2900
2941
  */
2901
2942
  resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
2902
- assertions: Record<string, string>;
2943
+ attributes: Record<string, string>;
2903
2944
  custom?: CustomPluginOptions;
2904
2945
  ssr?: boolean;
2905
2946
  isEntry: boolean;
@@ -2912,6 +2953,9 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
2912
2953
  }) => Promise<rollup.TransformResult> | rollup.TransformResult>;
2913
2954
  }
2914
2955
  type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
2956
+ type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
2957
+ [P in K]: NonNullable<Plugin[P]>;
2958
+ };
2915
2959
 
2916
2960
  interface JsonOptions {
2917
2961
  /**
@@ -2930,10 +2974,8 @@ interface JsonOptions {
2930
2974
  interface ConfigEnv {
2931
2975
  command: 'build' | 'serve';
2932
2976
  mode: string;
2933
- /**
2934
- * @experimental
2935
- */
2936
- ssrBuild?: boolean;
2977
+ isSsrBuild?: boolean;
2978
+ isPreview?: boolean;
2937
2979
  }
2938
2980
  /**
2939
2981
  * spa: include SPA fallback middleware and configure sirv with `single: true` in preview
@@ -3095,9 +3137,11 @@ interface UserConfig {
3095
3137
  */
3096
3138
  format?: 'es' | 'iife';
3097
3139
  /**
3098
- * Vite plugins that apply to worker bundle
3140
+ * Vite plugins that apply to worker bundle. The plugins returned by this function
3141
+ * should be new instances every time it is called, because they are used for each
3142
+ * rollup worker bundling process.
3099
3143
  */
3100
- plugins?: PluginOption[];
3144
+ plugins?: () => PluginOption[];
3101
3145
  /**
3102
3146
  * Rollup options to build worker bundle
3103
3147
  */
@@ -3142,10 +3186,21 @@ interface ExperimentalOptions {
3142
3186
  skipSsrTransform?: boolean;
3143
3187
  }
3144
3188
  interface LegacyOptions {
3189
+ /**
3190
+ * In Vite 4, SSR-externalized modules (modules not bundled and loaded by Node.js at runtime)
3191
+ * are implicitly proxied in dev to automatically handle `default` and `__esModule` access.
3192
+ * However, this does not correctly reflect how it works in the Node.js runtime, causing
3193
+ * inconsistencies between dev and prod.
3194
+ *
3195
+ * In Vite 5, the proxy is removed so dev and prod are consistent, but if you still require
3196
+ * the old behaviour, you can enable this option. If so, please leave your feedback at
3197
+ * https://github.com/vitejs/vite/discussions/14697.
3198
+ */
3199
+ proxySsrExternalModules?: boolean;
3145
3200
  }
3146
- interface ResolvedWorkerOptions extends PluginHookUtils {
3201
+ interface ResolvedWorkerOptions {
3147
3202
  format: 'es' | 'iife';
3148
- plugins: Plugin[];
3203
+ plugins: () => Promise<Plugin[]>;
3149
3204
  rollupOptions: RollupOptions;
3150
3205
  }
3151
3206
  interface InlineConfig extends UserConfig {
@@ -3170,7 +3225,7 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
3170
3225
  alias: Alias[];
3171
3226
  };
3172
3227
  plugins: readonly Plugin[];
3173
- css: ResolvedCSSOptions | undefined;
3228
+ css: ResolvedCSSOptions;
3174
3229
  esbuild: ESBuildOptions | false;
3175
3230
  server: ResolvedServerOptions;
3176
3231
  build: ResolvedBuildOptions;
@@ -3185,11 +3240,11 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
3185
3240
  experimental: ExperimentalOptions;
3186
3241
  } & PluginHookUtils>;
3187
3242
  interface PluginHookUtils {
3188
- getSortedPlugins: (hookName: keyof Plugin) => Plugin[];
3243
+ getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[];
3189
3244
  getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[];
3190
3245
  }
3191
3246
  type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
3192
- declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string): Promise<ResolvedConfig>;
3247
+ declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean): Promise<ResolvedConfig>;
3193
3248
  declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
3194
3249
  declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
3195
3250
  path: string;
@@ -1,5 +1,6 @@
1
- import { i as isInNodeModules } from './chunks/dep-ffdf177d.js';
2
- export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-ffdf177d.js';
1
+ export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
+ import { i as isInNodeModules } from './chunks/dep-VPh1kAXQ.js';
3
+ export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-VPh1kAXQ.js';
3
4
  export { VERSION as version } from './constants.js';
4
5
  export { version as esbuildVersion } from 'esbuild';
5
6
  export { VERSION as rollupVersion } from 'rollup';
@@ -16,6 +17,7 @@ import 'fs';
16
17
  import 'events';
17
18
  import 'assert';
18
19
  import 'node:http';
20
+ import 'node:https';
19
21
  import 'util';
20
22
  import 'net';
21
23
  import 'url';
@@ -36,7 +38,6 @@ import 'node:v8';
36
38
  import 'querystring';
37
39
  import 'node:readline';
38
40
  import 'node:events';
39
- import 'node:https';
40
41
  import 'zlib';
41
42
  import 'buffer';
42
43
  import 'https';