vite 6.0.0-alpha.17 → 6.0.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  /// <reference types="node" />
2
- import { PluginHooks, RollupError, SourceMap, ModuleInfo, PartialResolvedId, RollupOptions, WatcherOptions, InputOption, ModuleFormat, RollupOutput, RollupWatcher, InputOptions, CustomPluginOptions, SourceDescription, LoadResult, SourceMapInput, ExistingRawSourceMap, OutputBundle, OutputChunk, ObjectHook, ResolveIdResult, GetManualChunk } from 'rollup';
2
+ import { PluginHooks, RollupError, SourceMap, ModuleInfo, PartialResolvedId, RollupOptions, WatcherOptions, InputOption, ModuleFormat, RollupOutput, RollupWatcher, MinimalPluginContext, InputOptions, CustomPluginOptions, LoadResult, SourceDescription, SourceMapInput, ExistingRawSourceMap, OutputBundle, OutputChunk, ObjectHook, ResolveIdResult, GetManualChunk } from 'rollup';
3
3
  import * as rollup from 'rollup';
4
4
  export { rollup as Rollup };
5
5
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
6
6
  import * as http from 'node:http';
7
- import { OutgoingHttpHeaders, Server, ClientRequestArgs, IncomingMessage, ClientRequest, Agent, ServerResponse } from 'node:http';
7
+ import { OutgoingHttpHeaders, ClientRequestArgs, IncomingMessage, ClientRequest, Agent, Server, ServerResponse } from 'node:http';
8
8
  import { Http2SecureServer } from 'node:http2';
9
9
  import * as fs from 'node:fs';
10
10
  import * as events from 'node:events';
@@ -15,12 +15,12 @@ import * as url from 'node:url';
15
15
  import { URL } from 'node:url';
16
16
  import * as stream from 'node:stream';
17
17
  import { Duplex, DuplexOptions } from 'node:stream';
18
- import { FetchResult, ModuleRunnerOptions, ModuleRunnerHMRConnection, ModuleRunnerHmr, ModuleEvaluator, ModuleRunner } from 'vite/module-runner';
18
+ import { FetchResult, FetchFunctionOptions, ModuleRunnerOptions, ModuleRunnerHMRConnection, ModuleRunnerHmr, ModuleEvaluator, ModuleRunner } from 'vite/module-runner';
19
19
  export { FetchFunction, FetchResult } from 'vite/module-runner';
20
20
  import { BuildOptions as esbuild_BuildOptions, TransformOptions as esbuild_TransformOptions, TransformResult as esbuild_TransformResult } from 'esbuild';
21
21
  export { TransformOptions as EsbuildTransformOptions, version as esbuildVersion } from 'esbuild';
22
22
  import { HotPayload, CustomPayload } from '../../types/hotPayload.js';
23
- export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HotPayload, PrunePayload, Update, UpdatePayload } from '../../types/hotPayload.js';
23
+ export { ConnectedPayload, CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, HotPayload, PrunePayload, Update, UpdatePayload } from '../../types/hotPayload.js';
24
24
  import { InferCustomEventPayload } from '../../types/customEvent.js';
25
25
  export { CustomEventMap, InferCustomEventPayload, InvalidatePayload } from '../../types/customEvent.js';
26
26
  import { SecureContextOptions } from 'node:tls';
@@ -412,6 +412,7 @@ declare namespace HttpProxy {
412
412
  * @param req - Client request.
413
413
  * @param res - Client response.
414
414
  * @param options - Additional options.
415
+ * @param callback - Error callback.
415
416
  */
416
417
  web(
417
418
  req: http.IncomingMessage,
@@ -426,6 +427,7 @@ declare namespace HttpProxy {
426
427
  * @param socket - Client socket.
427
428
  * @param head - Client head.
428
429
  * @param options - Additional options.
430
+ * @param callback - Error callback.
429
431
  */
430
432
  ws(
431
433
  req: http.IncomingMessage,
@@ -616,6 +618,12 @@ interface ProxyOptions extends HttpProxy.ServerOptions {
616
618
  * webpack-dev-server style bypass function
617
619
  */
618
620
  bypass?: (req: http.IncomingMessage, res: http.ServerResponse, options: ProxyOptions) => void | null | undefined | false | string;
621
+ /**
622
+ * rewrite the Origin header of a WebSocket request to match the the target
623
+ *
624
+ * **Exercise caution as rewriting the Origin can leave the proxying open to [CSRF attacks](https://owasp.org/www-community/attacks/csrf).**
625
+ */
626
+ rewriteWsOrigin?: boolean | undefined;
619
627
  }
620
628
 
621
629
  type LogType = 'error' | 'warn' | 'info';
@@ -785,10 +793,15 @@ type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
785
793
 
786
794
  declare class PartialEnvironment {
787
795
  name: string;
788
- config: ResolvedConfig;
789
- options: ResolvedEnvironmentOptions;
796
+ getTopLevelConfig(): ResolvedConfig;
797
+ config: ResolvedConfig & ResolvedEnvironmentOptions;
798
+ /**
799
+ * @deprecated use environment.config instead
800
+ **/
801
+ get options(): ResolvedEnvironmentOptions;
802
+ _options: ResolvedEnvironmentOptions;
790
803
  logger: Logger;
791
- constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
804
+ constructor(name: string, topLevelConfig: ResolvedConfig, options?: ResolvedEnvironmentOptions);
792
805
  }
793
806
  declare class BaseEnvironment extends PartialEnvironment {
794
807
  get plugins(): Plugin[];
@@ -803,6 +816,7 @@ declare class FutureCompatEnvironment extends BaseEnvironment {
803
816
  }
804
817
 
805
818
  interface FetchModuleOptions {
819
+ cached?: boolean;
806
820
  inlineSourceMap?: boolean;
807
821
  processSourceMap?<T extends NonNullable<TransformResult['map']>>(map: T): T;
808
822
  }
@@ -997,7 +1011,7 @@ interface TransformResult {
997
1011
  }
998
1012
  interface TransformOptions {
999
1013
  /**
1000
- * @deprecated infered from environment
1014
+ * @deprecated inferred from environment
1001
1015
  */
1002
1016
  ssr?: boolean;
1003
1017
  /**
@@ -1074,7 +1088,7 @@ declare class EnvironmentModuleGraph {
1074
1088
  }
1075
1089
 
1076
1090
  /**
1077
- * Backward compatible ModuleNode and ModuleGraph with mixed nodes from both the client and ssr enviornments
1091
+ * Backward compatible ModuleNode and ModuleGraph with mixed nodes from both the client and ssr environments
1078
1092
  * It would be good to take the types names for the new EnvironmentModuleNode and EnvironmentModuleGraph but we can't
1079
1093
  * do that at this point without breaking to much code in the ecosystem.
1080
1094
  * We are going to deprecate these types and we can try to use them back in the future.
@@ -1122,30 +1136,18 @@ declare class ModuleGraph {
1122
1136
  client: () => EnvironmentModuleGraph;
1123
1137
  ssr: () => EnvironmentModuleGraph;
1124
1138
  });
1125
- /** @deprecated */
1126
1139
  getModuleById(id: string): ModuleNode | undefined;
1127
- /** @deprecated */
1128
1140
  getModuleByUrl(url: string, ssr?: boolean): Promise<ModuleNode | undefined>;
1129
- /** @deprecated */
1130
1141
  getModulesByFile(file: string): Set<ModuleNode> | undefined;
1131
- /** @deprecated */
1132
1142
  onFileChange(file: string): void;
1133
- /** @deprecated */
1134
1143
  onFileDelete(file: string): void;
1135
- /** @deprecated */
1136
1144
  invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean,
1137
1145
  ): void;
1138
- /** @deprecated */
1139
1146
  invalidateAll(): void;
1140
- /** @deprecated */
1141
1147
  ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>;
1142
- /** @deprecated */
1143
1148
  createFileOnlyEntry(file: string): ModuleNode;
1144
- /** @deprecated */
1145
1149
  resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
1146
- /** @deprecated */
1147
1150
  updateModuleTransformResult(mod: ModuleNode, result: TransformResult | null, ssr?: boolean): void;
1148
- /** @deprecated */
1149
1151
  getModuleByEtag(etag: string): ModuleNode | undefined;
1150
1152
  getBackwardCompatibleBrowserModuleNode(clientModule: EnvironmentModuleNode): ModuleNode;
1151
1153
  getBackwardCompatibleServerModuleNode(ssrModule: EnvironmentModuleNode): ModuleNode;
@@ -1162,21 +1164,20 @@ interface HmrOptions {
1162
1164
  path?: string;
1163
1165
  timeout?: number;
1164
1166
  overlay?: boolean;
1165
- server?: Server;
1167
+ server?: HttpServer;
1166
1168
  }
1167
- interface HotUpdateContext {
1169
+ interface HotUpdateOptions {
1168
1170
  type: 'create' | 'update' | 'delete';
1169
1171
  file: string;
1170
1172
  timestamp: number;
1171
1173
  modules: Array<EnvironmentModuleNode>;
1172
1174
  read: () => string | Promise<string>;
1173
1175
  server: ViteDevServer;
1176
+ /**
1177
+ * @deprecated use this.environment in the hotUpdate hook instead
1178
+ **/
1174
1179
  environment: DevEnvironment;
1175
1180
  }
1176
- /**
1177
- * @deprecated
1178
- * Used by handleHotUpdate for backward compatibility with mixed client and ssr moduleGraph
1179
- **/
1180
1181
  interface HmrContext {
1181
1182
  file: string;
1182
1183
  timestamp: number;
@@ -1194,6 +1195,8 @@ interface HotChannelClient {
1194
1195
  */
1195
1196
  send(event: string, payload?: CustomPayload['data']): void;
1196
1197
  }
1198
+ /** @deprecated use `HotChannelClient` instead */
1199
+ type HMRBroadcasterClient = HotChannelClient;
1197
1200
  interface HotChannel {
1198
1201
  /**
1199
1202
  * Broadcast events to all clients
@@ -1221,12 +1224,28 @@ interface HotChannel {
1221
1224
  */
1222
1225
  close(): void;
1223
1226
  }
1227
+ /** @deprecated use `HotChannel` instead */
1228
+ type HMRChannel = HotChannel;
1224
1229
  interface ServerHotChannel extends HotChannel {
1225
1230
  api: {
1226
1231
  innerEmitter: EventEmitter;
1227
1232
  outsideEmitter: EventEmitter;
1228
1233
  };
1229
1234
  }
1235
+ /** @deprecated use `ServerHotChannel` instead */
1236
+ type ServerHMRChannel = ServerHotChannel;
1237
+ /** @deprecated use `environment.hot` instead */
1238
+ interface HotBroadcaster extends HotChannel {
1239
+ readonly channels: HotChannel[];
1240
+ /**
1241
+ * A noop.
1242
+ * @deprecated
1243
+ */
1244
+ addChannel(channel: HotChannel): HotBroadcaster;
1245
+ close(): Promise<unknown[]>;
1246
+ }
1247
+ /** @deprecated use `environment.hot` instead */
1248
+ type HMRBroadcaster = HotBroadcaster;
1230
1249
 
1231
1250
  declare class RemoteEnvironmentTransport {
1232
1251
  private readonly options;
@@ -1262,7 +1281,7 @@ declare class DevEnvironment extends BaseEnvironment {
1262
1281
  hot: HotChannel;
1263
1282
  constructor(name: string, config: ResolvedConfig, setup: DevEnvironmentSetup);
1264
1283
  init(): Promise<void>;
1265
- fetchModule(id: string, importer?: string): Promise<FetchResult>;
1284
+ fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<FetchResult>;
1266
1285
  transformRequest(url: string): Promise<TransformResult | null>;
1267
1286
  warmupRequest(url: string): Promise<void>;
1268
1287
  close(): Promise<void>;
@@ -1526,6 +1545,9 @@ interface RollupDynamicImportVarsOptions {
1526
1545
  declare namespace Terser {
1527
1546
  export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
1528
1547
 
1548
+ export type ConsoleProperty = keyof typeof console
1549
+ type DropConsoleOption = boolean | ConsoleProperty[]
1550
+
1529
1551
  export interface ParseOptions {
1530
1552
  bare_returns?: boolean
1531
1553
  /** @deprecated legacy option. Currently, all supported EcmaScript is valid to parse. */
@@ -1546,7 +1568,7 @@ declare namespace Terser {
1546
1568
  dead_code?: boolean
1547
1569
  defaults?: boolean
1548
1570
  directives?: boolean
1549
- drop_console?: boolean
1571
+ drop_console?: DropConsoleOption
1550
1572
  drop_debugger?: boolean
1551
1573
  ecma?: ECMA
1552
1574
  evaluate?: boolean
@@ -1569,6 +1591,7 @@ declare namespace Terser {
1569
1591
  passes?: number
1570
1592
  properties?: boolean
1571
1593
  pure_funcs?: string[]
1594
+ pure_new?: boolean
1572
1595
  pure_getters?: boolean | 'strict'
1573
1596
  reduce_funcs?: boolean
1574
1597
  reduce_vars?: boolean
@@ -1618,7 +1641,7 @@ declare namespace Terser {
1618
1641
  * Obtains the nth most favored (usually shortest) identifier to rename a variable to.
1619
1642
  * The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word.
1620
1643
  * This function is expected to be stable; Evaluating get(n) === get(n) should always return true.
1621
- * @param n - The ordinal of the identifier.
1644
+ * @param n The ordinal of the identifier.
1622
1645
  */
1623
1646
  get(n: number): string
1624
1647
  }
@@ -1630,8 +1653,8 @@ declare namespace Terser {
1630
1653
  /**
1631
1654
  * Modifies the internal weighting of the input characters by the specified delta.
1632
1655
  * Will be invoked on the entire printed AST, and then deduct mangleable identifiers.
1633
- * @param chars - The characters to modify the weighting of.
1634
- * @param delta - The numeric weight to add to the characters.
1656
+ * @param chars The characters to modify the weighting of.
1657
+ * @param delta The numeric weight to add to the characters.
1635
1658
  */
1636
1659
  consider(chars: string, delta: number): number
1637
1660
  /**
@@ -1714,7 +1737,7 @@ declare namespace Terser {
1714
1737
  module?: boolean
1715
1738
  nameCache?: object
1716
1739
  format?: FormatOptions
1717
- /** @deprecated deprecated */
1740
+ /** @deprecated */
1718
1741
  output?: FormatOptions
1719
1742
  parse?: ParseOptions
1720
1743
  safari10?: boolean
@@ -1734,6 +1757,7 @@ declare namespace Terser {
1734
1757
  includeSources?: boolean
1735
1758
  filename?: string
1736
1759
  root?: string
1760
+ asObject?: boolean
1737
1761
  url?: string | 'inline'
1738
1762
  }
1739
1763
  }
@@ -1929,7 +1953,6 @@ interface BuildEnvironmentOptions {
1929
1953
  /**
1930
1954
  * Emit assets during SSR.
1931
1955
  * @default false
1932
- * @deprecated use emitAssets
1933
1956
  */
1934
1957
  ssrEmitAssets?: boolean;
1935
1958
  /**
@@ -1992,7 +2015,7 @@ interface LibraryOptions {
1992
2015
  */
1993
2016
  fileName?: string | ((format: ModuleFormat, entryName: string) => string);
1994
2017
  }
1995
- type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
2018
+ type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife' | 'system';
1996
2019
  interface ModulePreloadOptions {
1997
2020
  /**
1998
2021
  * Whether to inject a module preload polyfill.
@@ -2058,20 +2081,36 @@ declare function createBuilder(inlineConfig?: InlineConfig): Promise<ViteBuilder
2058
2081
 
2059
2082
  type Environment = DevEnvironment | BuildEnvironment | ScanEnvironment | FutureCompatEnvironment;
2060
2083
 
2061
- /**
2062
- * This file is refactored into TypeScript based on
2063
- * https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/rollup-plugin-container.js
2064
- */
2065
-
2066
- interface EnvironmentPluginContainer {
2067
- options: InputOptions;
2068
- buildStart(options: InputOptions): Promise<void>;
2069
- resolveId(id: string, importer: string | undefined, options?: {
2084
+ declare class EnvironmentPluginContainer {
2085
+ environment: Environment;
2086
+ plugins: Plugin[];
2087
+ watcher?: FSWatcher | undefined;
2088
+ private _pluginContextMap;
2089
+ private _resolvedRollupOptions?;
2090
+ private _processesing;
2091
+ private _seenResolves;
2092
+ private _moduleNodeToLoadAddedImports;
2093
+ getSortedPluginHooks: PluginHookUtils['getSortedPluginHooks'];
2094
+ getSortedPlugins: PluginHookUtils['getSortedPlugins'];
2095
+ moduleGraph: EnvironmentModuleGraph | undefined;
2096
+ watchFiles: Set<string>;
2097
+ minimalContext: MinimalPluginContext;
2098
+ private _closed;
2099
+ private _updateModuleLoadAddedImports;
2100
+ private _getAddedImports;
2101
+ private handleHookPromise;
2102
+ get options(): InputOptions;
2103
+ resolveRollupOptions(): Promise<InputOptions>;
2104
+ private _getPluginContext;
2105
+ private hookParallel;
2106
+ buildStart(_options?: InputOptions): Promise<void>;
2107
+ resolveId(rawId: string, importer?: string | undefined, options?: {
2070
2108
  attributes?: Record<string, string>;
2071
2109
  custom?: CustomPluginOptions;
2072
2110
  skip?: Set<Plugin>;
2073
2111
  isEntry?: boolean;
2074
2112
  }): Promise<PartialResolvedId | null>;
2113
+ load(id: string, options?: {}): Promise<LoadResult | null>;
2075
2114
  transform(code: string, id: string, options?: {
2076
2115
  inMap?: SourceDescription['map'];
2077
2116
  }): Promise<{
@@ -2080,38 +2119,39 @@ interface EnvironmentPluginContainer {
2080
2119
  mappings: '';
2081
2120
  } | null;
2082
2121
  }>;
2083
- load(id: string, options?: {}): Promise<LoadResult | null>;
2084
2122
  watchChange(id: string, change: {
2085
2123
  event: 'create' | 'update' | 'delete';
2086
2124
  }): Promise<void>;
2087
2125
  close(): Promise<void>;
2088
2126
  }
2089
- interface PluginContainer {
2090
- options: InputOptions;
2091
- buildStart(options: InputOptions): Promise<void>;
2092
- resolveId(id: string, importer?: string, options?: {
2127
+ declare class PluginContainer {
2128
+ private environments;
2129
+ constructor(environments: Record<string, Environment>);
2130
+ private _getEnvironment;
2131
+ private _getPluginContainer;
2132
+ get options(): InputOptions;
2133
+ buildStart(_options?: InputOptions): Promise<void>;
2134
+ resolveId(rawId: string, importer?: string, options?: {
2093
2135
  attributes?: Record<string, string>;
2094
2136
  custom?: CustomPluginOptions;
2095
2137
  skip?: Set<Plugin>;
2096
2138
  ssr?: boolean;
2097
- environment?: Environment;
2098
2139
  isEntry?: boolean;
2099
2140
  }): Promise<PartialResolvedId | null>;
2141
+ load(id: string, options?: {
2142
+ ssr?: boolean;
2143
+ }): Promise<LoadResult | null>;
2100
2144
  transform(code: string, id: string, options?: {
2101
- inMap?: SourceDescription['map'];
2102
2145
  ssr?: boolean;
2103
2146
  environment?: Environment;
2147
+ inMap?: SourceDescription['map'];
2104
2148
  }): Promise<{
2105
2149
  code: string;
2106
2150
  map: SourceMap | {
2107
2151
  mappings: '';
2108
2152
  } | null;
2109
2153
  }>;
2110
- load(id: string, options?: {
2111
- ssr?: boolean;
2112
- environment?: Environment;
2113
- }): Promise<LoadResult | null>;
2114
- watchChange(id: string, change: {
2154
+ watchChange(_id: string, _change: {
2115
2155
  event: 'create' | 'update' | 'delete';
2116
2156
  }): Promise<void>;
2117
2157
  close(): Promise<void>;
@@ -2691,10 +2731,14 @@ interface ServerOptions extends CommonServerOptions {
2691
2731
  * Configure HMR-specific options (port, host, path & protocol)
2692
2732
  */
2693
2733
  hmr?: HmrOptions | boolean;
2734
+ /**
2735
+ * Do not start the websocket connection.
2736
+ * @experimental
2737
+ */
2738
+ ws?: false;
2694
2739
  /**
2695
2740
  * Warm-up files to transform and cache the results in advance. This improves the
2696
2741
  * initial page load during server starts and prevents transform waterfalls.
2697
- * @deprecated use dev.warmup / environment.ssr.dev.warmup
2698
2742
  */
2699
2743
  warmup?: {
2700
2744
  /**
@@ -2721,7 +2765,7 @@ interface ServerOptions extends CommonServerOptions {
2721
2765
  *
2722
2766
  * This is needed to proxy WebSocket connections to the parent server.
2723
2767
  */
2724
- server: http.Server;
2768
+ server: HttpServer;
2725
2769
  };
2726
2770
  /**
2727
2771
  * Options for files served via '/\@fs/'.
@@ -2736,7 +2780,6 @@ interface ServerOptions extends CommonServerOptions {
2736
2780
  /**
2737
2781
  * Pre-transform known direct imports
2738
2782
  * @default true
2739
- * @deprecated use dev.preTransformRequests
2740
2783
  */
2741
2784
  preTransformRequests?: boolean;
2742
2785
  /**
@@ -2746,7 +2789,6 @@ interface ServerOptions extends CommonServerOptions {
2746
2789
  * By default, it excludes all paths containing `node_modules`. You can pass `false` to
2747
2790
  * disable this behavior, or, for full control, a function that takes the source path and
2748
2791
  * sourcemap path and returns whether to ignore the source path.
2749
- * @deprecated use dev.sourcemapIgnoreList
2750
2792
  */
2751
2793
  sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
2752
2794
  /**
@@ -2821,12 +2863,17 @@ interface ViteDevServer {
2821
2863
  watcher: FSWatcher;
2822
2864
  /**
2823
2865
  * web socket server with `send(payload)` method
2824
- * @deprecated use `environment.hot` instead
2825
2866
  */
2826
2867
  ws: WebSocketServer;
2868
+ /**
2869
+ * HMR broadcaster that can be used to send custom HMR messages to the client
2870
+ *
2871
+ * Always sends a message to at least a WebSocket client. Any third party can
2872
+ * add a channel to the broadcaster to process messages
2873
+ */
2874
+ hot: HotBroadcaster;
2827
2875
  /**
2828
2876
  * Rollup plugin container that can run plugin hooks on a given file
2829
- * @deprecated use `environment.pluginContainer` instead
2830
2877
  */
2831
2878
  pluginContainer: PluginContainer;
2832
2879
  /**
@@ -2836,7 +2883,6 @@ interface ViteDevServer {
2836
2883
  /**
2837
2884
  * Module graph that tracks the import relationships, url to file mapping
2838
2885
  * and hmr state.
2839
- * @deprecated use `environment.moduleGraph` instead
2840
2886
  */
2841
2887
  moduleGraph: ModuleGraph;
2842
2888
  /**
@@ -2847,14 +2893,12 @@ interface ViteDevServer {
2847
2893
  /**
2848
2894
  * Programmatically resolve, load and transform a URL and get the result
2849
2895
  * without going through the http request pipeline.
2850
- * @deprecated use environment.transformRequest
2851
2896
  */
2852
2897
  transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
2853
2898
  /**
2854
2899
  * Same as `transformRequest` but only warm up the URLs so the next request
2855
2900
  * will already be cached. The function will never throw as it handles and
2856
2901
  * reports errors internally.
2857
- * @deprecated use environment.warmupRequest
2858
2902
  */
2859
2903
  warmupRequest(url: string, options?: TransformOptions): Promise<void>;
2860
2904
  /**
@@ -2923,8 +2967,6 @@ interface ViteDevServer {
2923
2967
  * are processed. If called from a load or transform plugin hook, the id needs to be
2924
2968
  * passed as a parameter to avoid deadlocks. Calling this function after the first
2925
2969
  * static imports section of the module graph has been processed will resolve immediately.
2926
- * @experimental
2927
- * @deprecated use environment.waitForRequestsIdle()
2928
2970
  */
2929
2971
  waitForRequestsIdle: (ignoredId?: string) => Promise<void>;
2930
2972
  }
@@ -3007,7 +3049,7 @@ interface ResolvePluginOptions {
3007
3049
  scan?: boolean;
3008
3050
  ssrOptimizeCheck?: boolean;
3009
3051
  /**
3010
- * @deprecated environment.options are used instead
3052
+ * @deprecated environment.config are used instead
3011
3053
  */
3012
3054
  ssrConfig?: SSROptions;
3013
3055
  }
@@ -3066,6 +3108,7 @@ type LightningCSSOptions = {
3066
3108
  pseudoClasses?: PseudoClasses
3067
3109
  unusedSymbols?: string[]
3068
3110
  cssModules?: CSSModulesConfig
3111
+ errorRecovery?: boolean
3069
3112
  }
3070
3113
 
3071
3114
  interface CSSOptions {
@@ -3104,7 +3147,6 @@ interface CSSOptions {
3104
3147
  * Enables css sourcemaps during dev
3105
3148
  * @default false
3106
3149
  * @experimental
3107
- * @deprecated use dev.sourcemap instead
3108
3150
  */
3109
3151
  devSourcemap?: boolean;
3110
3152
  /**
@@ -3218,7 +3260,13 @@ type IndexHtmlTransform = IndexHtmlTransformHook | {
3218
3260
  * check if they have access to dev specific APIs.
3219
3261
  */
3220
3262
  interface PluginContextExtension {
3221
- environment?: Environment;
3263
+ /**
3264
+ * Vite-specific environment instance
3265
+ */
3266
+ environment: Environment;
3267
+ }
3268
+ interface HotUpdatePluginContext {
3269
+ environment: DevEnvironment;
3222
3270
  }
3223
3271
  interface PluginContext extends rollup.PluginContext, PluginContextExtension {
3224
3272
  }
@@ -3243,7 +3291,7 @@ declare module 'rollup' {
3243
3291
  interface Plugin<A = any> extends rollup.Plugin<A> {
3244
3292
  /**
3245
3293
  * Perform custom handling of HMR updates.
3246
- * The handler receives a context containing changed filename, timestamp, a
3294
+ * The handler receives an options containing changed filename, timestamp, a
3247
3295
  * list of modules affected by the file change, and the dev server instance.
3248
3296
  *
3249
3297
  * - The hook can return a filtered list of modules to narrow down the update.
@@ -3251,34 +3299,25 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
3251
3299
  * the descriptors.
3252
3300
  *
3253
3301
  * - The hook can also return an empty array and then perform custom updates
3254
- * by sending a custom hmr payload via server.hot.send().
3302
+ * by sending a custom hmr payload via environment.hot.send().
3255
3303
  *
3256
3304
  * - If the hook doesn't return a value, the hmr update will be performed as
3257
3305
  * normal.
3258
3306
  */
3259
- hotUpdate?: ObjectHook<(this: void, ctx: HotUpdateContext) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
3307
+ hotUpdate?: ObjectHook<(this: HotUpdatePluginContext, options: HotUpdateOptions) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
3260
3308
  /**
3261
3309
  * extend hooks with ssr flag
3262
3310
  */
3263
3311
  resolveId?: ObjectHook<(this: ResolveIdPluginContext, source: string, importer: string | undefined, options: {
3264
3312
  attributes: Record<string, string>;
3265
3313
  custom?: CustomPluginOptions;
3266
- /**
3267
- * @deprecated use this.environment
3268
- */
3269
3314
  ssr?: boolean;
3270
3315
  isEntry: boolean;
3271
3316
  }) => Promise<ResolveIdResult> | ResolveIdResult>;
3272
3317
  load?: ObjectHook<(this: PluginContext, id: string, options?: {
3273
- /**
3274
- * @deprecated use this.environment
3275
- */
3276
3318
  ssr?: boolean;
3277
3319
  }) => Promise<LoadResult> | LoadResult>;
3278
3320
  transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
3279
- /**
3280
- * @deprecated use this.environment
3281
- */
3282
3321
  ssr?: boolean;
3283
3322
  }) => Promise<rollup.TransformResult> | rollup.TransformResult>;
3284
3323
  /**
@@ -3374,7 +3413,6 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
3374
3413
  */
3375
3414
  transformIndexHtml?: IndexHtmlTransform;
3376
3415
  /**
3377
- * @deprecated
3378
3416
  * Perform custom handling of HMR updates.
3379
3417
  * The handler receives a context containing changed filename, timestamp, a
3380
3418
  * list of modules affected by the file change, and the dev server instance.
@@ -3415,17 +3453,8 @@ interface JsonOptions {
3415
3453
 
3416
3454
  type SSRTarget = 'node' | 'webworker';
3417
3455
  type SsrDepOptimizationConfig = DepOptimizationConfig;
3418
- /**
3419
- * @deprecated use environments.ssr
3420
- */
3421
3456
  interface SSROptions {
3422
- /**
3423
- * @deprecated use environment.resolve.noExternal
3424
- */
3425
3457
  noExternal?: string | RegExp | (string | RegExp)[] | true;
3426
- /**
3427
- * @deprecated use environment.resolve.external
3428
- */
3429
3458
  external?: string[] | true;
3430
3459
  /**
3431
3460
  * Define the target for the ssr build. The browser field in package.json
@@ -3438,7 +3467,6 @@ interface SSROptions {
3438
3467
  * }
3439
3468
  *
3440
3469
  * @default 'node'
3441
- * @deprecated use environment.webCompatible
3442
3470
  */
3443
3471
  target?: SSRTarget;
3444
3472
  /**
@@ -3448,12 +3476,8 @@ interface SSROptions {
3448
3476
  * During dev:
3449
3477
  * explicit no external CJS dependencies are optimized by default
3450
3478
  * @experimental
3451
- * @deprecated
3452
3479
  */
3453
3480
  optimizeDeps?: SsrDepOptimizationConfig;
3454
- /**
3455
- * @deprecated
3456
- */
3457
3481
  resolve?: {
3458
3482
  /**
3459
3483
  * Conditions that are used in the plugin pipeline. The default value is the root config's `resolve.conditions`.
@@ -3461,14 +3485,12 @@ interface SSROptions {
3461
3485
  * Use this to override the default ssr conditions for the ssr build.
3462
3486
  *
3463
3487
  * @default rootConfig.resolve.conditions
3464
- * @deprecated
3465
3488
  */
3466
3489
  conditions?: string[];
3467
3490
  /**
3468
3491
  * Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies.
3469
3492
  *
3470
3493
  * @default []
3471
- * @deprecated
3472
3494
  */
3473
3495
  externalConditions?: string[];
3474
3496
  };
@@ -3478,6 +3500,15 @@ interface ResolvedSSROptions extends SSROptions {
3478
3500
  optimizeDeps: SsrDepOptimizationConfig;
3479
3501
  }
3480
3502
 
3503
+ interface FutureDeprecationWarningsOptions {
3504
+ pluginHookHandleHotUpdate?: boolean;
3505
+ pluginHookSsrArgument?: boolean;
3506
+ serverModuleGraph?: boolean;
3507
+ serverHot?: boolean;
3508
+ serverTransformRequest?: boolean;
3509
+ ssrLoadModule?: boolean;
3510
+ }
3511
+
3481
3512
  interface ConfigEnv {
3482
3513
  /**
3483
3514
  * 'serve': during dev (`vite` command)
@@ -3570,6 +3601,11 @@ interface SharedEnvironmentOptions {
3570
3601
  * Configure resolver
3571
3602
  */
3572
3603
  resolve?: EnvironmentResolveOptions;
3604
+ /**
3605
+ * Define if this environment is used for Server Side Rendering
3606
+ * @default 'server' if it isn't the client environment
3607
+ */
3608
+ consumer?: 'client' | 'server';
3573
3609
  /**
3574
3610
  * Runtime Compatibility
3575
3611
  * Temporal options, we should remove these in favor of fine-grained control
@@ -3597,13 +3633,14 @@ interface EnvironmentOptions extends SharedEnvironmentOptions {
3597
3633
  type ResolvedEnvironmentResolveOptions = Required<EnvironmentResolveOptions>;
3598
3634
  type ResolvedEnvironmentOptions = {
3599
3635
  resolve: ResolvedEnvironmentResolveOptions;
3636
+ consumer: 'client' | 'server';
3600
3637
  nodeCompatible: boolean;
3601
3638
  webCompatible: boolean;
3602
3639
  injectInvalidationTimestamp: boolean;
3603
3640
  dev: ResolvedDevEnvironmentOptions;
3604
3641
  build: ResolvedBuildEnvironmentOptions;
3605
3642
  };
3606
- type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'build' | 'nodeCompatible' | 'webCompatible'> & {
3643
+ type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'build' | 'consumer' | 'nodeCompatible' | 'webCompatible' | 'injectInvalidationTimestamp'> & {
3607
3644
  build?: BuildOptions;
3608
3645
  };
3609
3646
  interface UserConfig extends DefaultEnvironmentOptions {
@@ -3692,6 +3729,10 @@ interface UserConfig extends DefaultEnvironmentOptions {
3692
3729
  * @experimental
3693
3730
  */
3694
3731
  experimental?: ExperimentalOptions;
3732
+ /**
3733
+ * Options to opt-in to future behavior
3734
+ */
3735
+ future?: FutureOptions;
3695
3736
  /**
3696
3737
  * Legacy options
3697
3738
  *
@@ -3773,6 +3814,14 @@ interface HTMLOptions {
3773
3814
  */
3774
3815
  cspNonce?: string;
3775
3816
  }
3817
+ interface FutureOptions {
3818
+ /**
3819
+ * Emit warning messages for deprecated/will-deprecated features at runtime.
3820
+ *
3821
+ * Setting to `true` to enable all warnings
3822
+ */
3823
+ deprecationWarnings?: boolean | FutureDeprecationWarningsOptions;
3824
+ }
3776
3825
  interface ExperimentalOptions {
3777
3826
  /**
3778
3827
  * Append fake `&lang.(ext)` when queries are specified, to preserve the file extension for following plugins to process.
@@ -3876,6 +3925,13 @@ declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, c
3876
3925
  dependencies: string[];
3877
3926
  } | null>;
3878
3927
 
3928
+ type ResolveIdFn = (environment: PartialEnvironment, id: string, importer?: string, aliasOnly?: boolean) => Promise<string | undefined>;
3929
+ /**
3930
+ * Create an internal resolver to be used in special scenarios, e.g.
3931
+ * optimizer and handling css @imports
3932
+ */
3933
+ declare function createIdResolver(config: ResolvedConfig, options: Partial<InternalResolveOptions>): ResolveIdFn;
3934
+
3879
3935
  declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
3880
3936
 
3881
3937
  declare function createNodeDevEnvironment(name: string, config: ResolvedConfig, options: DevEnvironmentSetup): DevEnvironment;
@@ -3959,12 +4015,6 @@ declare const rollupVersion: string;
3959
4015
  declare function normalizePath(id: string): string;
3960
4016
  declare function mergeConfig<D extends Record<string, any>, O extends Record<string, any>>(defaults: D extends Function ? never : D, overrides: O extends Function ? never : O, isRoot?: boolean): Record<string, any>;
3961
4017
  declare function mergeAlias(a?: AliasOptions, b?: AliasOptions): AliasOptions | undefined;
3962
- /**
3963
- * Creates a function that hides the complexities of a WeakMap with an initial value
3964
- * to implement object metadata. Used by plugins to implement cross hooks per
3965
- * environment metadata
3966
- */
3967
- declare function createWeakData<Key extends object | symbol, Data>(initial: (key: Key) => Data): (key: Key) => Data;
3968
4018
 
3969
4019
  interface SendOptions {
3970
4020
  etag?: string;
@@ -3983,7 +4033,6 @@ declare function searchForWorkspaceRoot(current: string, root?: string): string;
3983
4033
 
3984
4034
  /**
3985
4035
  * Check if the url is allowed to be served, via the `server.fs` config.
3986
- * @deprecated use isFileLoadingAllowed
3987
4036
  */
3988
4037
  declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
3989
4038
  declare function isFileLoadingAllowed(config: ResolvedConfig, filePath: string): boolean;
@@ -4004,4 +4053,4 @@ interface ManifestChunk {
4004
4053
  dynamicImports?: string[];
4005
4054
  }
4006
4055
 
4007
- export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, 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 DevEnvironmentOptions, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotUpdateContext, type HtmlTagDescriptor, HttpProxy, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type OptimizedDepInfo, type Plugin, type PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, RemoteEnvironmentTransport, 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, type SSROptions, type SSRTarget, type SendOptions, ServerHMRConnector, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationConfig, 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, createLogger, createNodeDevEnvironment, createServer, createServerModuleRunner, createWeakData, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
4056
+ export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, 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 DevEnvironmentOptions, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, 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 HotUpdateOptions, type HtmlTagDescriptor, HttpProxy, type HttpServer, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, 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, RemoteEnvironmentTransport, 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, type SSROptions, type SSRTarget, type SendOptions, type ServerHMRChannel, ServerHMRConnector, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationConfig, 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, createNodeDevEnvironment, createServer, createServerModuleRunner, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };