vite 6.0.0-beta.1 → 6.0.0-beta.2

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,4 +1,4 @@
1
- import { J as getDefaultExportFromCjs } from './dep-BZ_CwQkz.js';
1
+ import { L as getDefaultExportFromCjs } from './dep-BHXIdTzn.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-IQS-Za7F.js';
@@ -1,4 +1,4 @@
1
- import { K as commonjsGlobal, J as getDefaultExportFromCjs } from './dep-BZ_CwQkz.js';
1
+ import { M as commonjsGlobal, L as getDefaultExportFromCjs } from './dep-BHXIdTzn.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs__default from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { I as colors, A as createLogger, r as resolveConfig } from './chunks/dep-BZ_CwQkz.js';
5
+ import { K as colors, E as createLogger, r as resolveConfig } from './chunks/dep-BHXIdTzn.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -30,13 +30,13 @@ import 'node:crypto';
30
30
  import 'node:dns';
31
31
  import 'vite/module-runner';
32
32
  import 'rollup/parseAst';
33
+ import 'node:readline';
34
+ import 'crypto';
33
35
  import 'module';
34
36
  import 'node:assert';
35
37
  import 'node:v8';
36
38
  import 'node:worker_threads';
37
- import 'crypto';
38
39
  import 'node:buffer';
39
- import 'node:readline';
40
40
  import 'zlib';
41
41
  import 'buffer';
42
42
  import 'https';
@@ -736,7 +736,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
736
736
  `[boolean] force the optimizer to ignore the cache and re-bundle`
737
737
  ).action(async (root, options) => {
738
738
  filterDuplicateOptions(options);
739
- const { createServer } = await import('./chunks/dep-BZ_CwQkz.js').then(function (n) { return n.M; });
739
+ const { createServer } = await import('./chunks/dep-BHXIdTzn.js').then(function (n) { return n.O; });
740
740
  try {
741
741
  const server = await createServer({
742
742
  root,
@@ -829,7 +829,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
829
829
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as builder.entireApp`).action(
830
830
  async (root, options) => {
831
831
  filterDuplicateOptions(options);
832
- const build = await import('./chunks/dep-BZ_CwQkz.js').then(function (n) { return n.N; });
832
+ const build = await import('./chunks/dep-BHXIdTzn.js').then(function (n) { return n.P; });
833
833
  const buildOptions = cleanGlobalCLIOptions(
834
834
  cleanBuilderCLIOptions(options)
835
835
  );
@@ -884,7 +884,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
884
884
  ).action(
885
885
  async (root, options) => {
886
886
  filterDuplicateOptions(options);
887
- const { optimizeDeps } = await import('./chunks/dep-BZ_CwQkz.js').then(function (n) { return n.L; });
887
+ const { optimizeDeps } = await import('./chunks/dep-BHXIdTzn.js').then(function (n) { return n.N; });
888
888
  try {
889
889
  const config = await resolveConfig(
890
890
  {
@@ -910,7 +910,7 @@ ${e.stack}`),
910
910
  cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
911
911
  async (root, options) => {
912
912
  filterDuplicateOptions(options);
913
- const { preview } = await import('./chunks/dep-BZ_CwQkz.js').then(function (n) { return n.O; });
913
+ const { preview } = await import('./chunks/dep-BHXIdTzn.js').then(function (n) { return n.Q; });
914
914
  try {
915
915
  const server = await preview({
916
916
  root,
@@ -6,6 +6,7 @@ const { version } = JSON.parse(
6
6
  readFileSync(new URL("../../package.json", import.meta.url)).toString()
7
7
  );
8
8
  const ROLLUP_HOOKS = [
9
+ "options",
9
10
  "buildStart",
10
11
  "buildEnd",
11
12
  "renderStart",
@@ -30,7 +31,8 @@ const ROLLUP_HOOKS = [
30
31
  "resolveDynamicImport",
31
32
  "resolveId",
32
33
  "shouldTransformCachedModule",
33
- "transform"
34
+ "transform",
35
+ "onLog"
34
36
  ];
35
37
  const VERSION = version;
36
38
  const DEFAULT_MAIN_FIELDS = [
@@ -135,5 +137,8 @@ const DEFAULT_DEV_PORT = 5173;
135
137
  const DEFAULT_PREVIEW_PORT = 4173;
136
138
  const DEFAULT_ASSETS_INLINE_LIMIT = 4096;
137
139
  const METADATA_FILENAME = "_metadata.json";
140
+ const ERR_OPTIMIZE_DEPS_PROCESSING_ERROR = "ERR_OPTIMIZE_DEPS_PROCESSING_ERROR";
141
+ const ERR_OUTDATED_OPTIMIZED_DEP = "ERR_OUTDATED_OPTIMIZED_DEP";
142
+ const ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR = "ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR";
138
143
 
139
- export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, ROLLUP_HOOKS, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
144
+ export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_OUTDATED_OPTIMIZED_DEP, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, ROLLUP_HOOKS, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
@@ -15,7 +15,7 @@ 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, FetchFunctionOptions, ModuleRunnerOptions, ModuleRunnerHMRConnection, ModuleRunnerHmr, ModuleEvaluator, ModuleRunner } from 'vite/module-runner';
18
+ import { FetchFunctionOptions, FetchResult, ModuleRunner, ModuleRunnerOptions, ModuleRunnerHMRConnection, ModuleRunnerHmr, ModuleEvaluator } 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';
@@ -619,7 +619,7 @@ interface ProxyOptions extends HttpProxy.ServerOptions {
619
619
  */
620
620
  bypass?: (req: http.IncomingMessage, res: http.ServerResponse, options: ProxyOptions) => void | null | undefined | false | string;
621
621
  /**
622
- * rewrite the Origin header of a WebSocket request to match the the target
622
+ * rewrite the Origin header of a WebSocket request to match the target
623
623
  *
624
624
  * **Exercise caution as rewriting the Origin can leave the proxying open to [CSRF attacks](https://owasp.org/www-community/attacks/csrf).**
625
625
  */
@@ -822,17 +822,6 @@ declare class UnknownEnvironment extends BaseEnvironment {
822
822
  mode: "unknown";
823
823
  }
824
824
 
825
- interface FetchModuleOptions {
826
- cached?: boolean;
827
- inlineSourceMap?: boolean;
828
- processSourceMap?<T extends NonNullable<TransformResult['map']>>(map: T): T;
829
- }
830
- /**
831
- * Fetch module information for Vite runner.
832
- * @experimental
833
- */
834
- declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
835
-
836
825
  declare class ScanEnvironment extends BaseEnvironment {
837
826
  mode: "scan";
838
827
  get pluginContainer(): EnvironmentPluginContainer;
@@ -1229,7 +1218,7 @@ interface HotChannel {
1229
1218
  /**
1230
1219
  * Disconnect all clients, called when server is closed or restarted.
1231
1220
  */
1232
- close(): void;
1221
+ close(): Promise<unknown> | void;
1233
1222
  }
1234
1223
  /** @deprecated use `HotChannel` instead */
1235
1224
  type HMRChannel = HotChannel;
@@ -1267,7 +1256,8 @@ declare class RemoteEnvironmentTransport {
1267
1256
  interface DevEnvironmentContext {
1268
1257
  hot: false | HotChannel;
1269
1258
  options?: EnvironmentOptions;
1270
- runner?: FetchModuleOptions & {
1259
+ remoteRunner?: {
1260
+ inlineSourceMap?: boolean;
1271
1261
  transport?: RemoteEnvironmentTransport;
1272
1262
  };
1273
1263
  depsOptimizer?: DepsOptimizer;
@@ -2705,7 +2695,9 @@ declare namespace WebSocket {
2705
2695
  }
2706
2696
 
2707
2697
  type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
2698
+ declare const isWebSocketServer: unique symbol;
2708
2699
  interface WebSocketServer extends HotChannel {
2700
+ [isWebSocketServer]: true;
2709
2701
  /**
2710
2702
  * Listen on port and host
2711
2703
  */
@@ -3107,7 +3099,15 @@ interface CSSModulesConfig {
3107
3099
  /** The pattern to use when renaming class names and other identifiers. Default is `[hash]_[local]`. */
3108
3100
  pattern?: string,
3109
3101
  /** Whether to rename dashed identifiers, e.g. custom properties. */
3110
- dashedIdents?: boolean
3102
+ dashedIdents?: boolean,
3103
+ /** Whether to enable hashing for `@keyframes`. */
3104
+ animation?: boolean,
3105
+ /** Whether to enable hashing for CSS grid identifiers. */
3106
+ grid?: boolean,
3107
+ /** Whether to enable hashing for custom identifiers. */
3108
+ customIdents?: boolean,
3109
+ /** Whether to require at least one class or id selector in each rule. */
3110
+ pure?: boolean
3111
3111
  }
3112
3112
 
3113
3113
  /**
@@ -3287,7 +3287,7 @@ interface ResolveIdPluginContext extends rollup.PluginContext, PluginContextExte
3287
3287
  interface TransformPluginContext extends rollup.TransformPluginContext, PluginContextExtension {
3288
3288
  }
3289
3289
  declare module 'rollup' {
3290
- interface PluginContext extends PluginContextExtension {
3290
+ interface MinimalPluginContext extends PluginContextExtension {
3291
3291
  }
3292
3292
  }
3293
3293
  /**
@@ -3933,7 +3933,29 @@ declare function createIdResolver(config: ResolvedConfig, options?: Partial<Inte
3933
3933
 
3934
3934
  declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
3935
3935
 
3936
- declare function createNodeDevEnvironment(name: string, config: ResolvedConfig, context: DevEnvironmentContext): DevEnvironment;
3936
+ declare function createRunnableDevEnvironment(name: string, config: ResolvedConfig, context?: RunnableDevEnvironmentContext): DevEnvironment;
3937
+ interface RunnableDevEnvironmentContext extends Omit<DevEnvironmentContext, 'hot'> {
3938
+ runner?: (environment: RunnableDevEnvironment) => ModuleRunner;
3939
+ hot?: false | HotChannel;
3940
+ }
3941
+ declare function isRunnableDevEnvironment(environment: Environment): environment is RunnableDevEnvironment;
3942
+ declare class RunnableDevEnvironment extends DevEnvironment {
3943
+ private _runner;
3944
+ private _runnerFactory;
3945
+ constructor(name: string, config: ResolvedConfig, context: RunnableDevEnvironmentContext);
3946
+ get runner(): ModuleRunner;
3947
+ }
3948
+
3949
+ interface FetchModuleOptions {
3950
+ cached?: boolean;
3951
+ inlineSourceMap?: boolean;
3952
+ startOffset?: number;
3953
+ }
3954
+ /**
3955
+ * Fetch module information for Vite runner.
3956
+ * @experimental
3957
+ */
3958
+ declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<FetchResult>;
3937
3959
 
3938
3960
  /**
3939
3961
  * @experimental
@@ -3968,7 +3990,7 @@ declare class ServerHMRConnector implements ModuleRunnerHMRConnection {
3968
3990
  private connected;
3969
3991
  constructor(hotChannel: ServerHotChannel);
3970
3992
  isReady(): boolean;
3971
- send(message: string): void;
3993
+ send(payload_: HotPayload): void;
3972
3994
  onUpdate(handler: (payload: HotPayload) => void): void;
3973
3995
  }
3974
3996
 
@@ -4056,4 +4078,4 @@ interface ManifestChunk {
4056
4078
  dynamicImports?: string[];
4057
4079
  }
4058
4080
 
4059
- 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 DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type EnvironmentOptions, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type 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, createServerHotChannel, 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 };
4081
+ 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 DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type EnvironmentOptions, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type 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, RunnableDevEnvironment, type RunnableDevEnvironmentContext, 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, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
@@ -1,10 +1,9 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-BZ_CwQkz.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, b as build, j as buildErrorMessage, e as createBuilder, x as createFilter, f as createIdResolver, A as createLogger, k as createNodeDevEnvironment, c as createServer, n as createServerHotChannel, d as defineConfig, m as fetchModule, g as formatPostcssSourceMap, F as isFileLoadingAllowed, E as isFileServingAllowed, l as loadConfigFromFile, G as loadEnv, w as mergeAlias, v as mergeConfig, q as moduleRunnerTransform, u as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, H as resolveEnvPrefix, y as rollupVersion, C as searchForWorkspaceRoot, z as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BZ_CwQkz.js';
4
- import { existsSync, readFileSync } from 'node:fs';
5
- import { ModuleRunner, ESModulesEvaluator } from 'vite/module-runner';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-BHXIdTzn.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, j as buildErrorMessage, e as createBuilder, z as createFilter, f as createIdResolver, E as createLogger, k as createRunnableDevEnvironment, c as createServer, u as createServerHotChannel, q as createServerModuleRunner, d as defineConfig, n as fetchModule, g as formatPostcssSourceMap, H as isFileLoadingAllowed, G as isFileServingAllowed, m as isRunnableDevEnvironment, l as loadConfigFromFile, I as loadEnv, y as mergeAlias, x as mergeConfig, v as moduleRunnerTransform, w as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, J as resolveEnvPrefix, A as rollupVersion, F as searchForWorkspaceRoot, C as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BHXIdTzn.js';
6
4
  export { VERSION as version } from './constants.js';
7
5
  export { version as esbuildVersion } from 'esbuild';
6
+ import 'node:fs';
8
7
  import 'node:fs/promises';
9
8
  import 'node:path';
10
9
  import 'node:url';
@@ -31,13 +30,14 @@ import 'child_process';
31
30
  import 'node:os';
32
31
  import 'node:crypto';
33
32
  import 'node:dns';
33
+ import 'vite/module-runner';
34
+ import 'node:readline';
35
+ import 'crypto';
34
36
  import 'module';
35
37
  import 'node:assert';
36
38
  import 'node:v8';
37
39
  import 'node:worker_threads';
38
- import 'crypto';
39
40
  import 'node:buffer';
40
- import 'node:readline';
41
41
  import 'zlib';
42
42
  import 'buffer';
43
43
  import 'https';
@@ -181,112 +181,4 @@ class RemoteEnvironmentTransport {
181
181
  }
182
182
  }
183
183
 
184
- class ServerHMRBroadcasterClient {
185
- constructor(hotChannel) {
186
- this.hotChannel = hotChannel;
187
- }
188
- send(...args) {
189
- let payload;
190
- if (typeof args[0] === "string") {
191
- payload = {
192
- type: "custom",
193
- event: args[0],
194
- data: args[1]
195
- };
196
- } else {
197
- payload = args[0];
198
- }
199
- if (payload.type !== "custom") {
200
- throw new Error(
201
- "Cannot send non-custom events from the client to the server."
202
- );
203
- }
204
- this.hotChannel.send(payload);
205
- }
206
- }
207
- class ServerHMRConnector {
208
- constructor(hotChannel) {
209
- this.hotChannel = hotChannel;
210
- this.hmrClient = new ServerHMRBroadcasterClient(hotChannel);
211
- hotChannel.api.outsideEmitter.on("send", (payload) => {
212
- this.handlers.forEach((listener) => listener(payload));
213
- });
214
- this.hotChannel = hotChannel;
215
- }
216
- handlers = [];
217
- hmrClient;
218
- connected = false;
219
- isReady() {
220
- return this.connected;
221
- }
222
- send(message) {
223
- const payload = JSON.parse(message);
224
- this.hotChannel.api.innerEmitter.emit(
225
- payload.event,
226
- payload.data,
227
- this.hmrClient
228
- );
229
- }
230
- onUpdate(handler) {
231
- this.handlers.push(handler);
232
- handler({ type: "connected" });
233
- this.connected = true;
234
- }
235
- }
236
-
237
- function createHMROptions(environment, options) {
238
- if (environment.config.server.hmr === false || options.hmr === false) {
239
- return false;
240
- }
241
- if (options.hmr?.connection) {
242
- return {
243
- connection: options.hmr.connection,
244
- logger: options.hmr.logger
245
- };
246
- }
247
- if (!("api" in environment.hot)) return false;
248
- const connection = new ServerHMRConnector(environment.hot);
249
- return {
250
- connection,
251
- logger: options.hmr?.logger
252
- };
253
- }
254
- const prepareStackTrace = {
255
- retrieveFile(id) {
256
- if (existsSync(id)) {
257
- return readFileSync(id, "utf-8");
258
- }
259
- }
260
- };
261
- function resolveSourceMapOptions(options) {
262
- if (options.sourcemapInterceptor != null) {
263
- if (options.sourcemapInterceptor === "prepareStackTrace") {
264
- return prepareStackTrace;
265
- }
266
- if (typeof options.sourcemapInterceptor === "object") {
267
- return { ...prepareStackTrace, ...options.sourcemapInterceptor };
268
- }
269
- return options.sourcemapInterceptor;
270
- }
271
- if (typeof process !== "undefined" && "setSourceMapsEnabled" in process) {
272
- return "node";
273
- }
274
- return prepareStackTrace;
275
- }
276
- function createServerModuleRunner(environment, options = {}) {
277
- const hmr = createHMROptions(environment, options);
278
- return new ModuleRunner(
279
- {
280
- ...options,
281
- root: environment.config.root,
282
- transport: {
283
- fetchModule: (id, importer, options2) => environment.fetchModule(id, importer, options2)
284
- },
285
- hmr,
286
- sourcemapInterceptor: resolveSourceMapOptions(options)
287
- },
288
- options.evaluator || new ESModulesEvaluator()
289
- );
290
- }
291
-
292
- export { RemoteEnvironmentTransport, ServerHMRConnector, createServerModuleRunner, isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
184
+ export { RemoteEnvironmentTransport, isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
@@ -1,5 +1,5 @@
1
1
  import { ModuleNamespace, ViteHotContext } from '../../types/hot.js';
2
- import { Update, HotPayload } from '../../types/hmrPayload.js';
2
+ import { HotPayload, Update } from '../../types/hmrPayload.js';
3
3
  import { InferCustomEventPayload } from '../../types/customEvent.js';
4
4
 
5
5
  interface SourceMapLike {
@@ -47,13 +47,13 @@ interface HMRConnection {
47
47
  /**
48
48
  * Send message to the client.
49
49
  */
50
- send(messages: string): void;
50
+ send(messages: HotPayload): void;
51
51
  }
52
52
  declare class HMRMessenger {
53
53
  private connection;
54
54
  constructor(connection: HMRConnection);
55
55
  private queue;
56
- send(message: string): void;
56
+ send(payload: HotPayload): void;
57
57
  flush(): void;
58
58
  }
59
59
  declare class HMRClient {
@@ -111,19 +111,13 @@ declare class ModuleRunner {
111
111
  options: ModuleRunnerOptions;
112
112
  evaluator: ModuleEvaluator;
113
113
  private debug?;
114
- /**
115
- * Holds the cache of modules
116
- * Keys of the map are ids
117
- */
118
- moduleCache: ModuleCacheMap;
114
+ evaluatedModules: EvaluatedModules;
119
115
  hmrClient?: HMRClient;
120
- private readonly urlToIdMap;
121
- private readonly fileToIdMap;
122
116
  private readonly envProxy;
123
117
  private readonly transport;
124
118
  private readonly resetSourceMapSupport?;
125
119
  private readonly root;
126
- private readonly moduleInfoCache;
120
+ private readonly concurrentModuleNodePromises;
127
121
  private destroyed;
128
122
  constructor(options: ModuleRunnerOptions, evaluator: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
129
123
  /**
@@ -149,7 +143,7 @@ declare class ModuleRunner {
149
143
  private cachedRequest;
150
144
  private cachedModule;
151
145
  private getModuleInformation;
152
- protected directRequest(id: string, mod: ModuleCache, _callstack: string[]): Promise<any>;
146
+ protected directRequest(url: string, mod: EvaluatedModuleNode, _callstack: string[]): Promise<any>;
153
147
  }
154
148
 
155
149
  interface RetrieveFileHandler {
@@ -202,31 +196,23 @@ interface ModuleRunnerContext {
202
196
  [ssrImportMetaKey]: ModuleRunnerImportMeta;
203
197
  }
204
198
  interface ModuleEvaluator {
199
+ /**
200
+ * Number of prefixed lines in the transformed code.
201
+ */
202
+ startOffset?: number;
205
203
  /**
206
204
  * Run code that was transformed by Vite.
207
205
  * @param context Function context
208
206
  * @param code Transformed code
209
- * @param id ID that was used to fetch the module
207
+ * @param module The module node
210
208
  */
211
- runInlinedModule(context: ModuleRunnerContext, code: string, id: string): Promise<any>;
209
+ runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
212
210
  /**
213
211
  * Run externalized module.
214
212
  * @param file File URL to the external module
215
213
  */
216
214
  runExternalModule(file: string): Promise<any>;
217
215
  }
218
- interface ModuleCache {
219
- promise?: Promise<any>;
220
- exports?: any;
221
- evaluated?: boolean;
222
- map?: DecodedMap;
223
- meta?: ResolvedResult;
224
- /**
225
- * Module ids that imports this module
226
- */
227
- importers?: Set<string>;
228
- imports?: Set<string>;
229
- }
230
216
  type FetchResult = CachedFetchResult | ExternalFetchResult | ViteFetchResult;
231
217
  interface CachedFetchResult {
232
218
  /**
@@ -246,7 +232,7 @@ interface ExternalFetchResult {
246
232
  * Type of the module. Will be used to determine if import statement is correct.
247
233
  * For example, if Vite needs to throw an error if variable is not actually exported
248
234
  */
249
- type?: 'module' | 'commonjs' | 'builtin' | 'network';
235
+ type: 'module' | 'commonjs' | 'builtin' | 'network';
250
236
  }
251
237
  interface ViteFetchResult {
252
238
  /**
@@ -263,7 +249,11 @@ interface ViteFetchResult {
263
249
  /**
264
250
  * Module ID in the server module graph.
265
251
  */
266
- serverId: string;
252
+ id: string;
253
+ /**
254
+ * Module URL used in the import.
255
+ */
256
+ url: string;
267
257
  /**
268
258
  * Invalidate module on the client side.
269
259
  */
@@ -271,10 +261,12 @@ interface ViteFetchResult {
271
261
  }
272
262
  type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & {
273
263
  url: string;
264
+ id: string;
274
265
  };
275
266
  type FetchFunction = (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
276
267
  interface FetchFunctionOptions {
277
268
  cached?: boolean;
269
+ startOffset?: number;
278
270
  }
279
271
  interface ModuleRunnerHmr {
280
272
  /**
@@ -308,7 +300,7 @@ interface ModuleRunnerOptions {
308
300
  /**
309
301
  * Custom module cache. If not provided, creates a separate module cache for each ModuleRunner instance.
310
302
  */
311
- moduleCache?: ModuleCacheMap;
303
+ evaluatedModules?: EvaluatedModules;
312
304
  }
313
305
  interface ImportMetaEnv {
314
306
  [key: string]: any;
@@ -319,36 +311,66 @@ interface ImportMetaEnv {
319
311
  SSR: boolean;
320
312
  }
321
313
 
322
- declare class ModuleCacheMap extends Map<string, ModuleCache> {
323
- private root;
324
- constructor(root: string, entries?: [string, ModuleCache][]);
325
- normalize(fsPath: string): string;
314
+ declare class EvaluatedModuleNode {
315
+ id: string;
316
+ url: string;
317
+ importers: Set<string>;
318
+ imports: Set<string>;
319
+ evaluated: boolean;
320
+ meta: ResolvedResult | undefined;
321
+ promise: Promise<any> | undefined;
322
+ exports: any | undefined;
323
+ file: string;
324
+ map: DecodedMap | undefined;
325
+ constructor(id: string, url: string);
326
+ }
327
+ declare class EvaluatedModules {
328
+ readonly idToModuleMap: Map<string, EvaluatedModuleNode>;
329
+ readonly fileToModulesMap: Map<string, Set<EvaluatedModuleNode>>;
330
+ readonly urlToIdModuleMap: Map<string, EvaluatedModuleNode>;
331
+ /**
332
+ * Returns the module node by the resolved module ID. Usually, module ID is
333
+ * the file system path with query and/or hash. It can also be a virtual module.
334
+ *
335
+ * Module runner graph will have 1 to 1 mapping with the server module graph.
336
+ * @param id Resolved module ID
337
+ */
338
+ getModuleById(id: string): EvaluatedModuleNode | undefined;
326
339
  /**
327
- * Assign partial data to the map
340
+ * Returns all modules related to the file system path. Different modules
341
+ * might have different query parameters or hash, so it's possible to have
342
+ * multiple modules for the same file.
343
+ * @param file The file system path of the module
328
344
  */
329
- update(fsPath: string, mod: ModuleCache): this;
330
- setByModuleId(modulePath: string, mod: ModuleCache): this;
331
- set(fsPath: string, mod: ModuleCache): this;
332
- getByModuleId(modulePath: string): ModuleCache;
333
- get(fsPath: string): ModuleCache;
334
- deleteByModuleId(modulePath: string): boolean;
335
- delete(fsPath: string): boolean;
336
- invalidateUrl(id: string): void;
337
- invalidateModule(module: ModuleCache): void;
345
+ getModulesByFile(file: string): Set<EvaluatedModuleNode> | undefined;
338
346
  /**
339
- * Invalidate modules that dependent on the given modules, up to the main entry
347
+ * Returns the module node by the URL that was used in the import statement.
348
+ * Unlike module graph on the server, the URL is not resolved and is used as is.
349
+ * @param url Server URL that was used in the import statement
340
350
  */
341
- invalidateDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
351
+ getModuleByUrl(url: string): EvaluatedModuleNode | undefined;
342
352
  /**
343
- * Invalidate dependency modules of the given modules, down to the bottom-level dependencies
353
+ * Ensure that module is in the graph. If the module is already in the graph,
354
+ * it will return the existing module node. Otherwise, it will create a new
355
+ * module node and add it to the graph.
356
+ * @param id Resolved module ID
357
+ * @param url URL that was used in the import statement
344
358
  */
345
- invalidateSubDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
346
- getSourceMap(moduleId: string): null | DecodedMap;
359
+ ensureModule(id: string, url: string): EvaluatedModuleNode;
360
+ invalidateModule(node: EvaluatedModuleNode): void;
361
+ /**
362
+ * Extracts the inlined source map from the module code and returns the decoded
363
+ * source map. If the source map is not inlined, it will return null.
364
+ * @param id Resolved module ID
365
+ */
366
+ getModuleSourceMapById(id: string): DecodedMap | null;
367
+ clear(): void;
347
368
  }
348
369
 
349
370
  declare class ESModulesEvaluator implements ModuleEvaluator {
371
+ startOffset: number;
350
372
  runInlinedModule(context: ModuleRunnerContext, code: string): Promise<any>;
351
373
  runExternalModule(filepath: string): Promise<any>;
352
374
  }
353
375
 
354
- export { ESModulesEvaluator, type FetchFunction, type FetchFunctionOptions, type FetchResult, type HMRConnection, type HMRLogger, type ModuleCache, ModuleCacheMap, type ModuleEvaluator, ModuleRunner, type ModuleRunnerContext, type ModuleRunnerHMRConnection, type ModuleRunnerHmr, type ModuleRunnerImportMeta, type ModuleRunnerOptions, RemoteRunnerTransport, type ResolvedResult, type RunnerTransport, type SSRImportMetadata, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
376
+ export { ESModulesEvaluator, EvaluatedModuleNode, EvaluatedModules, type FetchFunction, type FetchFunctionOptions, type FetchResult, type HMRConnection, type HMRLogger, type ModuleEvaluator, ModuleRunner, type ModuleRunnerContext, type ModuleRunnerHMRConnection, type ModuleRunnerHmr, type ModuleRunnerImportMeta, type ModuleRunnerOptions, RemoteRunnerTransport, type ResolvedResult, type RunnerTransport, type SSRImportMetadata, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };