vite 5.0.0-beta.8 → 5.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.
@@ -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,
@@ -1460,16 +1485,37 @@ interface ServerOptions extends CommonServerOptions {
1460
1485
  * Configure HMR-specific options (port, host, path & protocol)
1461
1486
  */
1462
1487
  hmr?: HmrOptions | boolean;
1488
+ /**
1489
+ * Warm-up files to transform and cache the results in advance. This improves the
1490
+ * initial page load during server starts and prevents transform waterfalls.
1491
+ */
1492
+ warmup?: {
1493
+ /**
1494
+ * The files to be transformed and used on the client-side. Supports glob patterns.
1495
+ */
1496
+ clientFiles?: string[];
1497
+ /**
1498
+ * The files to be transformed and used in SSR. Supports glob patterns.
1499
+ */
1500
+ ssrFiles?: string[];
1501
+ };
1463
1502
  /**
1464
1503
  * chokidar watch options or null to disable FS watching
1465
- * https:
1504
+ * https://github.com/paulmillr/chokidar#api
1466
1505
  */
1467
1506
  watch?: WatchOptions | null;
1468
1507
  /**
1469
1508
  * Create Vite dev server to be used as a middleware in an existing server
1470
1509
  * @default false
1471
1510
  */
1472
- 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
+ };
1473
1519
  /**
1474
1520
  * Options for files served via '/\@fs/'.
1475
1521
  */
@@ -1477,7 +1523,7 @@ interface ServerOptions extends CommonServerOptions {
1477
1523
  /**
1478
1524
  * Origin for the generated asset URLs.
1479
1525
  *
1480
- * @example `http:
1526
+ * @example `http://127.0.0.1:8080`
1481
1527
  */
1482
1528
  origin?: string;
1483
1529
  /**
@@ -1487,7 +1533,7 @@ interface ServerOptions extends CommonServerOptions {
1487
1533
  preTransformRequests?: boolean;
1488
1534
  /**
1489
1535
  * Whether or not to ignore-list source files in the dev server sourcemap, used to populate
1490
- * 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).
1491
1537
  *
1492
1538
  * By default, it excludes all paths containing `node_modules`. You can pass `false` to
1493
1539
  * disable this behavior, or, for full control, a function that takes the source path and
@@ -1527,6 +1573,7 @@ interface FileSystemServeOptions {
1527
1573
  deny?: string[];
1528
1574
  }
1529
1575
  type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
1576
+ type HttpServer = http.Server | Http2SecureServer;
1530
1577
  interface ViteDevServer {
1531
1578
  /**
1532
1579
  * The resolved vite config object
@@ -1538,17 +1585,17 @@ interface ViteDevServer {
1538
1585
  * - Can also be used as the handler function of a custom http server
1539
1586
  * or as a middleware in any connect-style Node.js frameworks
1540
1587
  *
1541
- * https:
1588
+ * https://github.com/senchalabs/connect#use-middleware
1542
1589
  */
1543
1590
  middlewares: Connect.Server;
1544
1591
  /**
1545
1592
  * native Node http server instance
1546
1593
  * will be null in middleware mode
1547
1594
  */
1548
- httpServer: http.Server | null;
1595
+ httpServer: HttpServer | null;
1549
1596
  /**
1550
1597
  * chokidar watcher instance
1551
- * https:
1598
+ * https://github.com/paulmillr/chokidar#api
1552
1599
  */
1553
1600
  watcher: FSWatcher;
1554
1601
  /**
@@ -1574,6 +1621,12 @@ interface ViteDevServer {
1574
1621
  * without going through the http request pipeline.
1575
1622
  */
1576
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>;
1577
1630
  /**
1578
1631
  * Apply vite built-in HTML transforms and any plugin HTML transforms.
1579
1632
  */
@@ -1806,10 +1859,10 @@ interface RollupCommonJSOptions {
1806
1859
  * imports i.e.
1807
1860
  *
1808
1861
  * ```js
1809
- *
1862
+ * // input
1810
1863
  * const foo = require('foo');
1811
1864
  *
1812
- *
1865
+ * // output
1813
1866
  * import * as foo from 'foo';
1814
1867
  * ```
1815
1868
  *
@@ -1901,6 +1954,10 @@ interface RollupDynamicImportVarsOptions {
1901
1954
  warnOnError?: boolean
1902
1955
  }
1903
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
+
1904
1961
  declare namespace Terser {
1905
1962
  export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
1906
1963
 
@@ -2135,13 +2192,13 @@ interface BuildOptions {
2135
2192
  *
2136
2193
  * Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
2137
2194
  * transpile targeting browsers that natively support dynamic es module imports.
2138
- * https:
2195
+ * https://caniuse.com/es6-module-dynamic-import
2139
2196
  *
2140
2197
  * Another special value is 'esnext' - which only performs minimal transpiling
2141
2198
  * (for minification compat) and assumes native dynamic imports support.
2142
2199
  *
2143
- * For custom targets, see https:
2144
- * https:
2200
+ * For custom targets, see https://esbuild.github.io/api/#target and
2201
+ * https://esbuild.github.io/content-types/#javascript for more details.
2145
2202
  * @default 'modules'
2146
2203
  */
2147
2204
  target?: 'modules' | esbuild_TransformOptions['target'] | false;
@@ -2215,7 +2272,7 @@ interface BuildOptions {
2215
2272
  minify?: boolean | 'terser' | 'esbuild';
2216
2273
  /**
2217
2274
  * Options for terser
2218
- * https:
2275
+ * https://terser.org/docs/api-reference#minify-options
2219
2276
  *
2220
2277
  * In addition, you can also pass a `maxWorkers: number` option to specify the
2221
2278
  * max number of workers to spawn. Defaults to the number of CPUs minus 1.
@@ -2223,7 +2280,7 @@ interface BuildOptions {
2223
2280
  terserOptions?: TerserOptions;
2224
2281
  /**
2225
2282
  * Will be merged with internal rollup options.
2226
- * https:
2283
+ * https://rollupjs.org/configuration-options/
2227
2284
  */
2228
2285
  rollupOptions?: RollupOptions;
2229
2286
  /**
@@ -2306,7 +2363,7 @@ interface BuildOptions {
2306
2363
  chunkSizeWarningLimit?: number;
2307
2364
  /**
2308
2365
  * Rollup watch options
2309
- * https:
2366
+ * https://rollupjs.org/configuration-options/#watch
2310
2367
  * @default null
2311
2368
  */
2312
2369
  watch?: WatcherOptions | null;
@@ -2433,7 +2490,7 @@ interface DepOptimizationConfig {
2433
2490
  * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
2434
2491
  * - `plugins` are merged with Vite's dep plugin
2435
2492
  *
2436
- * https:
2493
+ * https://esbuild.github.io/api
2437
2494
  */
2438
2495
  esbuildOptions?: Omit<esbuild_BuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
2439
2496
  /**
@@ -2471,7 +2528,7 @@ type DepOptimizationOptions = DepOptimizationConfig & {
2471
2528
  *
2472
2529
  * If neither of these fit your needs, you can specify custom entries using
2473
2530
  * this option - the value should be a fast-glob pattern or array of patterns
2474
- * (https:
2531
+ * (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
2475
2532
  * vite project root. This will overwrite default entries inference.
2476
2533
  */
2477
2534
  entries?: string | string[];
@@ -2578,14 +2635,9 @@ interface ResolvedSSROptions extends SSROptions {
2578
2635
 
2579
2636
  interface ResolveOptions {
2580
2637
  /**
2581
- * @default ['module', 'jsnext:main', 'jsnext']
2638
+ * @default ['browser', 'module', 'jsnext:main', 'jsnext']
2582
2639
  */
2583
2640
  mainFields?: string[];
2584
- /**
2585
- * @deprecated In future, `mainFields` should be used instead.
2586
- * @default true
2587
- */
2588
- browserField?: boolean;
2589
2641
  conditions?: string[];
2590
2642
  /**
2591
2643
  * @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
@@ -2621,6 +2673,8 @@ interface InternalResolveOptions extends Required<ResolveOptions> {
2621
2673
  shouldExternalize?: (id: string, importer?: string) => boolean | undefined;
2622
2674
  }
2623
2675
 
2676
+ // This file is autogenerated by build-prefixes.js. DO NOT EDIT!
2677
+
2624
2678
  interface Targets {
2625
2679
  android?: number,
2626
2680
  chrome?: number,
@@ -2684,7 +2738,7 @@ interface CSSOptions {
2684
2738
  */
2685
2739
  transformer?: 'postcss' | 'lightningcss';
2686
2740
  /**
2687
- * https:
2741
+ * https://github.com/css-modules/postcss-modules
2688
2742
  */
2689
2743
  modules?: CSSModulesOptions | false;
2690
2744
  preprocessorOptions?: Record<string, any>;
@@ -2885,7 +2939,7 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
2885
2939
  * extend hooks with ssr flag
2886
2940
  */
2887
2941
  resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
2888
- assertions: Record<string, string>;
2942
+ attributes: Record<string, string>;
2889
2943
  custom?: CustomPluginOptions;
2890
2944
  ssr?: boolean;
2891
2945
  isEntry: boolean;
@@ -2898,6 +2952,9 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
2898
2952
  }) => Promise<rollup.TransformResult> | rollup.TransformResult>;
2899
2953
  }
2900
2954
  type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
2955
+ type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
2956
+ [P in K]: NonNullable<Plugin[P]>;
2957
+ };
2901
2958
 
2902
2959
  interface JsonOptions {
2903
2960
  /**
@@ -2916,10 +2973,8 @@ interface JsonOptions {
2916
2973
  interface ConfigEnv {
2917
2974
  command: 'build' | 'serve';
2918
2975
  mode: string;
2919
- /**
2920
- * @experimental
2921
- */
2922
- ssrBuild?: boolean;
2976
+ isSsrBuild?: boolean;
2977
+ isPreview?: boolean;
2923
2978
  }
2924
2979
  /**
2925
2980
  * spa: include SPA fallback middleware and configure sirv with `single: true` in preview
@@ -3081,9 +3136,11 @@ interface UserConfig {
3081
3136
  */
3082
3137
  format?: 'es' | 'iife';
3083
3138
  /**
3084
- * Vite plugins that apply to worker bundle
3139
+ * Vite plugins that apply to worker bundle. The plugins returned by this function
3140
+ * should be new instances every time it is called, because they are used for each
3141
+ * rollup worker bundling process.
3085
3142
  */
3086
- plugins?: PluginOption[];
3143
+ plugins?: () => PluginOption[];
3087
3144
  /**
3088
3145
  * Rollup options to build worker bundle
3089
3146
  */
@@ -3128,10 +3185,21 @@ interface ExperimentalOptions {
3128
3185
  skipSsrTransform?: boolean;
3129
3186
  }
3130
3187
  interface LegacyOptions {
3188
+ /**
3189
+ * In Vite 4, SSR-externalized modules (modules not bundled and loaded by Node.js at runtime)
3190
+ * are implicitly proxied in dev to automatically handle `default` and `__esModule` access.
3191
+ * However, this does not correctly reflect how it works in the Node.js runtime, causing
3192
+ * inconsistencies between dev and prod.
3193
+ *
3194
+ * In Vite 5, the proxy is removed so dev and prod are consistent, but if you still require
3195
+ * the old behaviour, you can enable this option. If so, please leave your feedback at
3196
+ * https://github.com/vitejs/vite/discussions/14697.
3197
+ */
3198
+ proxySsrExternalModules?: boolean;
3131
3199
  }
3132
- interface ResolvedWorkerOptions extends PluginHookUtils {
3200
+ interface ResolvedWorkerOptions {
3133
3201
  format: 'es' | 'iife';
3134
- plugins: Plugin[];
3202
+ plugins: () => Promise<Plugin[]>;
3135
3203
  rollupOptions: RollupOptions;
3136
3204
  }
3137
3205
  interface InlineConfig extends UserConfig {
@@ -3156,7 +3224,7 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
3156
3224
  alias: Alias[];
3157
3225
  };
3158
3226
  plugins: readonly Plugin[];
3159
- css: ResolvedCSSOptions | undefined;
3227
+ css: ResolvedCSSOptions;
3160
3228
  esbuild: ESBuildOptions | false;
3161
3229
  server: ResolvedServerOptions;
3162
3230
  build: ResolvedBuildOptions;
@@ -3171,11 +3239,11 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
3171
3239
  experimental: ExperimentalOptions;
3172
3240
  } & PluginHookUtils>;
3173
3241
  interface PluginHookUtils {
3174
- getSortedPlugins: (hookName: keyof Plugin) => Plugin[];
3242
+ getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[];
3175
3243
  getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[];
3176
3244
  }
3177
3245
  type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
3178
- declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string): Promise<ResolvedConfig>;
3246
+ declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean): Promise<ResolvedConfig>;
3179
3247
  declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
3180
3248
  declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
3181
3249
  path: string;
@@ -1,5 +1,6 @@
1
- import { i as isInNodeModules } from './chunks/dep-73034a1b.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-73034a1b.js';
1
+ export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
+ import { i as isInNodeModules } from './chunks/dep-T98iZFpD.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-T98iZFpD.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';
@@ -15,6 +16,8 @@ import 'path';
15
16
  import 'fs';
16
17
  import 'events';
17
18
  import 'assert';
19
+ import 'node:http';
20
+ import 'node:https';
18
21
  import 'util';
19
22
  import 'net';
20
23
  import 'url';
@@ -35,8 +38,6 @@ import 'node:v8';
35
38
  import 'querystring';
36
39
  import 'node:readline';
37
40
  import 'node:events';
38
- import 'node:http';
39
- import 'node:https';
40
41
  import 'zlib';
41
42
  import 'buffer';
42
43
  import 'https';