vite 6.2.2 → 6.3.0-beta.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.
package/dist/node/cli.js CHANGED
@@ -2,13 +2,14 @@ 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 { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-B0fRCRkQ.js';
5
+ import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-Bt1yO2CH.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
9
9
  import 'node:util';
10
10
  import 'node:module';
11
11
  import 'node:crypto';
12
+ import 'picomatch';
12
13
  import 'esbuild';
13
14
  import 'path';
14
15
  import 'fs';
@@ -33,6 +34,7 @@ import 'module';
33
34
  import 'node:readline';
34
35
  import 'node:process';
35
36
  import 'node:events';
37
+ import 'tinyglobby';
36
38
  import 'crypto';
37
39
  import 'node:assert';
38
40
  import 'node:v8';
@@ -745,7 +747,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
745
747
  `[boolean] force the optimizer to ignore the cache and re-bundle`
746
748
  ).action(async (root, options) => {
747
749
  filterDuplicateOptions(options);
748
- const { createServer } = await import('./chunks/dep-B0fRCRkQ.js').then(function (n) { return n.S; });
750
+ const { createServer } = await import('./chunks/dep-Bt1yO2CH.js').then(function (n) { return n.S; });
749
751
  try {
750
752
  const server = await createServer({
751
753
  root,
@@ -840,7 +842,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
840
842
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
841
843
  async (root, options) => {
842
844
  filterDuplicateOptions(options);
843
- const { createBuilder } = await import('./chunks/dep-B0fRCRkQ.js').then(function (n) { return n.T; });
845
+ const { createBuilder } = await import('./chunks/dep-Bt1yO2CH.js').then(function (n) { return n.T; });
844
846
  const buildOptions = cleanGlobalCLIOptions(
845
847
  cleanBuilderCLIOptions(options)
846
848
  );
@@ -879,7 +881,7 @@ cli.command(
879
881
  ).action(
880
882
  async (root, options) => {
881
883
  filterDuplicateOptions(options);
882
- const { optimizeDeps } = await import('./chunks/dep-B0fRCRkQ.js').then(function (n) { return n.R; });
884
+ const { optimizeDeps } = await import('./chunks/dep-Bt1yO2CH.js').then(function (n) { return n.R; });
883
885
  try {
884
886
  const config = await resolveConfig(
885
887
  {
@@ -906,7 +908,7 @@ ${e.stack}`),
906
908
  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(
907
909
  async (root, options) => {
908
910
  filterDuplicateOptions(options);
909
- const { preview } = await import('./chunks/dep-B0fRCRkQ.js').then(function (n) { return n.U; });
911
+ const { preview } = await import('./chunks/dep-Bt1yO2CH.js').then(function (n) { return n.U; });
910
912
  try {
911
913
  const server = await preview({
912
914
  root,
@@ -31,7 +31,7 @@ export { LightningCSSOptions } from '../../types/internal/lightningcssOptions.js
31
31
  import { SassLegacyPreprocessBaseOptions, SassModernPreprocessBaseOptions, LessPreprocessorBaseOptions, StylusPreprocessorBaseOptions } from '../../types/internal/cssPreprocessorOptions.js';
32
32
  import { M as ModuleRunnerTransport } from './moduleRunnerTransport.d-CXw_Ws6P.js';
33
33
  export { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownAsTypeMap } from '../../types/importGlob.js';
34
- export { ChunkMetadata } from '../../types/metadata.js';
34
+ export { ChunkMetadata, CustomPluginOptionsVite } from '../../types/metadata.js';
35
35
 
36
36
  interface Alias {
37
37
  find: string | RegExp
@@ -3200,6 +3200,11 @@ type IndexHtmlTransform = IndexHtmlTransformHook | {
3200
3200
  handler: IndexHtmlTransformHook;
3201
3201
  };
3202
3202
 
3203
+ type StringFilter = string | RegExp | Array<string | RegExp> | {
3204
+ include?: string | RegExp | Array<string | RegExp>;
3205
+ exclude?: string | RegExp | Array<string | RegExp>;
3206
+ };
3207
+
3203
3208
  /**
3204
3209
  * Vite plugins extends the Rollup plugin interface with a few extra
3205
3210
  * vite-specific options. A valid vite plugin is also a valid Rollup plugin.
@@ -3280,13 +3285,26 @@ interface Plugin<A = any> extends rollup.Plugin<A> {
3280
3285
  custom?: CustomPluginOptions;
3281
3286
  ssr?: boolean;
3282
3287
  isEntry: boolean;
3283
- }) => Promise<ResolveIdResult> | ResolveIdResult>;
3288
+ }) => Promise<ResolveIdResult> | ResolveIdResult, {
3289
+ filter?: {
3290
+ id?: StringFilter;
3291
+ };
3292
+ }>;
3284
3293
  load?: ObjectHook<(this: PluginContext, id: string, options?: {
3285
3294
  ssr?: boolean;
3286
- }) => Promise<LoadResult> | LoadResult>;
3295
+ }) => Promise<LoadResult> | LoadResult, {
3296
+ filter?: {
3297
+ id?: StringFilter;
3298
+ };
3299
+ }>;
3287
3300
  transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
3288
3301
  ssr?: boolean;
3289
- }) => Promise<rollup.TransformResult> | rollup.TransformResult>;
3302
+ }) => Promise<rollup.TransformResult> | rollup.TransformResult, {
3303
+ filter?: {
3304
+ id?: StringFilter;
3305
+ code?: StringFilter;
3306
+ };
3307
+ }>;
3290
3308
  /**
3291
3309
  * Opt-in this plugin into the shared plugins pipeline.
3292
3310
  * For backward-compatibility, plugins are re-recreated for each environment
@@ -3427,7 +3445,7 @@ interface CSSOptions {
3427
3445
  /**
3428
3446
  * Using lightningcss is an experimental option to handle CSS modules,
3429
3447
  * assets and imports via Lightning CSS. It requires to install it as a
3430
- * peer dependency. This is incompatible with the use of preprocessors.
3448
+ * peer dependency.
3431
3449
  *
3432
3450
  * @default 'postcss'
3433
3451
  * @experimental
@@ -3484,7 +3502,7 @@ interface CSSModulesOptions {
3484
3502
  */
3485
3503
  localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | ((originalClassName: string, generatedClassName: string, inputFile: string) => string);
3486
3504
  }
3487
- type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & Required<Pick<CSSOptions, 'transformer'>> & {
3505
+ type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & Required<Pick<CSSOptions, 'transformer' | 'devSourcemap'>> & {
3488
3506
  lightningcss?: LightningCSSOptions;
3489
3507
  };
3490
3508
  interface PreprocessCSSResult {
@@ -4081,6 +4099,17 @@ declare class RunnableDevEnvironment extends DevEnvironment {
4081
4099
  close(): Promise<void>;
4082
4100
  }
4083
4101
 
4102
+ interface FetchableDevEnvironmentContext extends DevEnvironmentContext {
4103
+ handleRequest(request: Request): Promise<Response> | Response;
4104
+ }
4105
+ declare function createFetchableDevEnvironment(name: string, config: ResolvedConfig, context: FetchableDevEnvironmentContext): FetchableDevEnvironment;
4106
+ declare function isFetchableDevEnvironment(environment: Environment): environment is FetchableDevEnvironment;
4107
+ declare class FetchableDevEnvironment extends DevEnvironment {
4108
+ private _handleRequest;
4109
+ constructor(name: string, config: ResolvedConfig, context: FetchableDevEnvironmentContext);
4110
+ dispatchFetch(request: Request): Promise<Response>;
4111
+ }
4112
+
4084
4113
  interface RunnerImportResult<T> {
4085
4114
  module: T;
4086
4115
  dependencies: string[];
@@ -4191,4 +4220,4 @@ interface ManifestChunk {
4191
4220
  dynamicImports?: string[];
4192
4221
  }
4193
4222
 
4194
- export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type EnvironmentOptions, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotChannelListener, type HotUpdateOptions, type HtmlTagDescriptor, HttpProxy, type HttpServer, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LessPreprocessorOptions, type LibraryFormats, type LibraryOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type NormalizedHotChannel, type NormalizedHotChannelClient, type NormalizedServerHotChannel, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, RunnableDevEnvironment, type RunnableDevEnvironmentContext, type SSROptions, type SSRTarget, type SassPreprocessorOptions, type SendOptions, type ServerHMRChannel, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, type SkipInformation, SplitVendorChunkCache, type SsrDepOptimizationConfig, type StylusPreprocessorOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteBuilder, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createBuilder, createFilter, createIdResolver, createLogger, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, createServerModuleRunnerTransport, defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, perEnvironmentPlugin, perEnvironmentState, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, runnerImport, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
4223
+ export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESBuildTransformResult, type Environment, EnvironmentModuleGraph, EnvironmentModuleNode, type EnvironmentOptions, type ExperimentalOptions, type ExportsData, FSWatcher, type FetchModuleOptions, FetchableDevEnvironment, type FetchableDevEnvironmentContext, type FileSystemServeOptions, type FilterPattern, type HMRBroadcaster, type HMRBroadcasterClient, type HMRChannel, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotChannelListener, type HotUpdateOptions, type HtmlTagDescriptor, HttpProxy, type HttpServer, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InlineConfig, type InternalResolveOptions, type JsonOptions, type LegacyOptions, type LessPreprocessorOptions, type LibraryFormats, type LibraryOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, ModuleGraph, ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type NormalizedHotChannel, type NormalizedHotChannelClient, type NormalizedServerHotChannel, type OptimizedDepInfo, type Plugin, PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, RunnableDevEnvironment, type RunnableDevEnvironmentContext, type SSROptions, type SSRTarget, type SassPreprocessorOptions, type SendOptions, type ServerHMRChannel, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions, type SkipInformation, SplitVendorChunkCache, type SsrDepOptimizationConfig, type StylusPreprocessorOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteBuilder, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createBuilder, createFetchableDevEnvironment, createFilter, createIdResolver, createLogger, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, createServerModuleRunnerTransport, defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFetchableDevEnvironment, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, perEnvironmentPlugin, perEnvironmentState, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, runnerImport, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { a as arraify, i as isInNodeModules } from './chunks/dep-B0fRCRkQ.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-B0fRCRkQ.js';
2
+ import { a as arraify, i as isInNodeModules, D as DevEnvironment } from './chunks/dep-Bt1yO2CH.js';
3
+ export { B as BuildEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-Bt1yO2CH.js';
4
4
  export { defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import 'node:fs';
@@ -11,6 +11,7 @@ import 'node:util';
11
11
  import 'node:perf_hooks';
12
12
  import 'node:module';
13
13
  import 'node:crypto';
14
+ import 'picomatch';
14
15
  import 'path';
15
16
  import 'fs';
16
17
  import 'node:child_process';
@@ -34,6 +35,7 @@ import 'module';
34
35
  import 'node:readline';
35
36
  import 'node:process';
36
37
  import 'node:events';
38
+ import 'tinyglobby';
37
39
  import 'crypto';
38
40
  import 'node:assert';
39
41
  import 'node:v8';
@@ -150,4 +152,42 @@ function splitVendorChunkPlugin() {
150
152
  };
151
153
  }
152
154
 
153
- export { isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
155
+ function createFetchableDevEnvironment(name, config, context) {
156
+ if (typeof Request === "undefined" || typeof Response === "undefined") {
157
+ throw new TypeError(
158
+ "FetchableDevEnvironment requires a global `Request` and `Response` object."
159
+ );
160
+ }
161
+ if (!context.handleRequest) {
162
+ throw new TypeError(
163
+ "FetchableDevEnvironment requires a `handleRequest` method during initialisation."
164
+ );
165
+ }
166
+ return new FetchableDevEnvironment(name, config, context);
167
+ }
168
+ function isFetchableDevEnvironment(environment) {
169
+ return environment instanceof FetchableDevEnvironment;
170
+ }
171
+ class FetchableDevEnvironment extends DevEnvironment {
172
+ _handleRequest;
173
+ constructor(name, config, context) {
174
+ super(name, config, context);
175
+ this._handleRequest = context.handleRequest;
176
+ }
177
+ async dispatchFetch(request) {
178
+ if (!(request instanceof Request)) {
179
+ throw new TypeError(
180
+ "FetchableDevEnvironment `dispatchFetch` must receive a `Request` object."
181
+ );
182
+ }
183
+ const response = await this._handleRequest(request);
184
+ if (!(response instanceof Response)) {
185
+ throw new TypeError(
186
+ "FetchableDevEnvironment `context.handleRequest` must return a `Response` object."
187
+ );
188
+ }
189
+ return response;
190
+ }
191
+ }
192
+
193
+ export { DevEnvironment, createFetchableDevEnvironment, isCSSRequest, isFetchableDevEnvironment, splitVendorChunk, splitVendorChunkPlugin };