vite 6.0.0-alpha.0 → 6.0.0-alpha.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.
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { E as colors, x as createLogger, r as resolveConfig, F as Environment } from './chunks/dep-hQh5_mg-.js';
5
+ import { E as colors, x as createLogger, r as resolveConfig, F as Environment } from './chunks/dep-E4cF1RpV.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -766,7 +766,7 @@ cli
766
766
  filterDuplicateOptions(options);
767
767
  // output structure is preserved even after bundling so require()
768
768
  // is ok here
769
- const { createServer } = await import('./chunks/dep-hQh5_mg-.js').then(function (n) { return n.I; });
769
+ const { createServer } = await import('./chunks/dep-E4cF1RpV.js').then(function (n) { return n.I; });
770
770
  try {
771
771
  const server = await createServer({
772
772
  root,
@@ -847,7 +847,7 @@ cli
847
847
  .option('--all', `[boolean] build all environments`)
848
848
  .action(async (root, options) => {
849
849
  filterDuplicateOptions(options);
850
- const { build, createViteBuilder } = await import('./chunks/dep-hQh5_mg-.js').then(function (n) { return n.K; });
850
+ const { build, createViteBuilder } = await import('./chunks/dep-E4cF1RpV.js').then(function (n) { return n.K; });
851
851
  const buildOptions = cleanGlobalCLIOptions(cleanBuilderCLIOptions(options));
852
852
  const config = {
853
853
  root,
@@ -891,7 +891,7 @@ cli
891
891
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
892
892
  .action(async (root, options) => {
893
893
  filterDuplicateOptions(options);
894
- const { optimizeDeps } = await import('./chunks/dep-hQh5_mg-.js').then(function (n) { return n.J; });
894
+ const { optimizeDeps } = await import('./chunks/dep-E4cF1RpV.js').then(function (n) { return n.J; });
895
895
  try {
896
896
  const config = await resolveConfig({
897
897
  root,
@@ -918,7 +918,7 @@ cli
918
918
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
919
919
  .action(async (root, options) => {
920
920
  filterDuplicateOptions(options);
921
- const { preview } = await import('./chunks/dep-hQh5_mg-.js').then(function (n) { return n.L; });
921
+ const { preview } = await import('./chunks/dep-E4cF1RpV.js').then(function (n) { return n.L; });
922
922
  try {
923
923
  const server = await preview({
924
924
  root,
@@ -2627,7 +2627,7 @@ interface TerserOptions extends Terser.MinifyOptions {
2627
2627
  maxWorkers?: number;
2628
2628
  }
2629
2629
 
2630
- interface BuildOptions {
2630
+ interface BuildEnvironmentOptions {
2631
2631
  /**
2632
2632
  * Compatibility transform target. The transform is performed with esbuild
2633
2633
  * and the lowest supported target is es2015/es6. Note this only handles
@@ -2770,13 +2770,6 @@ interface BuildOptions {
2770
2770
  * @default false
2771
2771
  */
2772
2772
  manifest?: boolean | string;
2773
- /**
2774
- * Build in library mode. The value should be the global name of the lib in
2775
- * UMD mode. This will produce esm + cjs + umd bundle formats with default
2776
- * configurations that are suitable for distributing libraries.
2777
- * @default false
2778
- */
2779
- lib?: LibraryOptions | false;
2780
2773
  /**
2781
2774
  * Produce SSR oriented build. Note this requires specifying SSR entry via
2782
2775
  * `rollupOptions.input`.
@@ -2822,7 +2815,16 @@ interface BuildOptions {
2822
2815
  /**
2823
2816
  * create the Build Environment instance
2824
2817
  */
2825
- createEnvironment?: (builder: ViteBuilder, name: string) => BuildEnvironment;
2818
+ createEnvironment?: (builder: ViteBuilder, name: string) => Promise<BuildEnvironment> | BuildEnvironment;
2819
+ }
2820
+ interface BuildOptions extends BuildEnvironmentOptions {
2821
+ /**
2822
+ * Build in library mode. The value should be the global name of the lib in
2823
+ * UMD mode. This will produce esm + cjs + umd bundle formats with default
2824
+ * configurations that are suitable for distributing libraries.
2825
+ * @default false
2826
+ */
2827
+ lib?: LibraryOptions | false;
2826
2828
  }
2827
2829
  interface LibraryOptions {
2828
2830
  /**
@@ -2868,6 +2870,9 @@ type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], con
2868
2870
  hostId: string;
2869
2871
  hostType: 'html' | 'js';
2870
2872
  }) => string[];
2873
+ interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, 'polyfillModulePreload'>> {
2874
+ modulePreload: false | ResolvedModulePreloadOptions;
2875
+ }
2871
2876
  interface ResolvedBuildOptions extends Required<Omit<BuildOptions, 'polyfillModulePreload'>> {
2872
2877
  modulePreload: false | ResolvedModulePreloadOptions;
2873
2878
  }
@@ -3439,7 +3444,7 @@ declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
3439
3444
  declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
3440
3445
  declare function defineConfig(config: UserConfigExport): UserConfigExport;
3441
3446
  type PluginOption = Plugin | false | null | undefined | PluginOption[] | Promise<Plugin | false | null | undefined | PluginOption[]>;
3442
- interface DevOptions {
3447
+ interface DevEnvironmentOptions {
3443
3448
  /**
3444
3449
  * The files to be pre-transformed. Supports glob patterns.
3445
3450
  */
@@ -3476,10 +3481,17 @@ interface DevOptions {
3476
3481
  /**
3477
3482
  * create the Dev Environment instance
3478
3483
  */
3479
- createEnvironment?: (server: ViteDevServer, name: string) => DevEnvironment;
3484
+ createEnvironment?: (server: ViteDevServer, name: string) => Promise<DevEnvironment> | DevEnvironment;
3485
+ /**
3486
+ * For environments that support a full-reload, like the client, we can short-circuit when
3487
+ * restarting the server throwing early to stop processing current files. We avoided this for
3488
+ * SSR requests. Maybe this is no longer needed.
3489
+ * @experimental
3490
+ */
3491
+ recoverable?: boolean;
3480
3492
  }
3481
- type ResolvedDevOptions = Required<Omit<DevOptions, 'createEnvironment'>> & {
3482
- createEnvironment: ((server: ViteDevServer, name: string) => DevEnvironment) | undefined;
3493
+ type ResolvedDevEnvironmentOptions = Required<Omit<DevEnvironmentOptions, 'createEnvironment'>> & {
3494
+ createEnvironment: ((server: ViteDevServer, name: string) => Promise<DevEnvironment> | DevEnvironment) | undefined;
3483
3495
  };
3484
3496
  type EnvironmentResolveOptions = ResolveOptions & {
3485
3497
  alias?: AliasOptions;
@@ -3500,21 +3512,23 @@ interface EnvironmentOptions extends SharedEnvironmentOptions {
3500
3512
  /**
3501
3513
  * Dev specific options
3502
3514
  */
3503
- dev?: DevOptions;
3515
+ dev?: DevEnvironmentOptions;
3504
3516
  /**
3505
3517
  * Build specific options
3506
3518
  */
3507
- build?: BuildOptions;
3519
+ build?: BuildEnvironmentOptions;
3508
3520
  }
3509
3521
  type ResolvedEnvironmentResolveOptions = Required<EnvironmentResolveOptions>;
3510
3522
  type ResolvedEnvironmentOptions = {
3511
3523
  resolve: ResolvedEnvironmentResolveOptions;
3512
3524
  nodeCompatible: boolean;
3513
3525
  webCompatible: boolean;
3514
- dev: ResolvedDevOptions;
3515
- build: ResolvedBuildOptions;
3526
+ dev: ResolvedDevEnvironmentOptions;
3527
+ build: ResolvedBuildEnvironmentOptions;
3528
+ };
3529
+ type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'build' | 'nodeCompatible' | 'webCompatible'> & {
3530
+ build?: BuildOptions;
3516
3531
  };
3517
- type DefaultEnvironmentOptions = Omit<EnvironmentOptions, 'nodeCompatible' | 'webCompatible'>;
3518
3532
  interface UserConfig extends DefaultEnvironmentOptions {
3519
3533
  /**
3520
3534
  * Project root directory. Can be an absolute path, or a path relative from
@@ -3755,7 +3769,7 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
3755
3769
  css: ResolvedCSSOptions;
3756
3770
  esbuild: ESBuildOptions | false;
3757
3771
  server: ResolvedServerOptions;
3758
- dev: ResolvedDevOptions;
3772
+ dev: ResolvedDevEnvironmentOptions;
3759
3773
  builder: ResolvedBuilderOptions;
3760
3774
  build: ResolvedBuildOptions;
3761
3775
  preview: ResolvedPreviewOptions;
@@ -3893,4 +3907,4 @@ interface ManifestChunk {
3893
3907
  dynamicImports?: string[];
3894
3908
  }
3895
3909
 
3896
- export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, BuildEnvironment, type BuildOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, 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 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 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 ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, 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 ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createFilter, createLogger, createNodeDevEnvironment, createServer, createServerModuleRunner, createViteBuilder, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
3910
+ export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, BuildEnvironment, type BuildEnvironmentOptions, type BuildOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, DevEnvironment, type DevEnvironmentSetup, type ESBuildOptions, type ESBuildTransformResult, 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 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 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 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 ServerModuleRunnerOptions, type ServerOptions, SplitVendorChunkCache, type SsrDepOptimizationOptions, Terser, type TerserOptions, type TransformOptions, type TransformResult, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type ViteDevServer, type WatchOptions, WebSocket, WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, WebSocketServer, build, buildErrorMessage, createFilter, createLogger, createNodeDevEnvironment, createServer, createServerModuleRunner, createViteBuilder, defineConfig, fetchModule, formatPostcssSourceMap, isCSSRequest, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rollupVersion, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-hQh5_mg-.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, b as build, h as buildErrorMessage, u as createFilter, x as createLogger, j as createNodeDevEnvironment, c as createServer, e as createViteBuilder, d as defineConfig, k as fetchModule, f as formatPostcssSourceMap, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, g as preprocessCSS, p as preview, r as resolveConfig, C as resolveEnvPrefix, v as rollupVersion, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-hQh5_mg-.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-E4cF1RpV.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, b as build, h as buildErrorMessage, u as createFilter, x as createLogger, j as createNodeDevEnvironment, c as createServer, e as createViteBuilder, d as defineConfig, k as fetchModule, f as formatPostcssSourceMap, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, g as preprocessCSS, p as preview, r as resolveConfig, C as resolveEnvPrefix, v as rollupVersion, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-E4cF1RpV.js';
4
4
  import { existsSync, readFileSync } from 'node:fs';
5
5
  import { ModuleRunner, ESModulesEvaluator } from 'vite/module-runner';
6
6
  export { VERSION as version } from './constants.js';
@@ -5241,21 +5241,29 @@ class MagicString {
5241
5241
  if (searchValue.global) {
5242
5242
  const matches = matchAll(searchValue, this.original);
5243
5243
  matches.forEach((match) => {
5244
- if (match.index != null)
5244
+ if (match.index != null) {
5245
+ const replacement = getReplacement(match, this.original);
5246
+ if (replacement !== match[0]) {
5247
+ this.overwrite(
5248
+ match.index,
5249
+ match.index + match[0].length,
5250
+ replacement
5251
+ );
5252
+ }
5253
+ }
5254
+ });
5255
+ } else {
5256
+ const match = this.original.match(searchValue);
5257
+ if (match && match.index != null) {
5258
+ const replacement = getReplacement(match, this.original);
5259
+ if (replacement !== match[0]) {
5245
5260
  this.overwrite(
5246
5261
  match.index,
5247
5262
  match.index + match[0].length,
5248
- getReplacement(match, this.original),
5263
+ replacement
5249
5264
  );
5250
- });
5251
- } else {
5252
- const match = this.original.match(searchValue);
5253
- if (match && match.index != null)
5254
- this.overwrite(
5255
- match.index,
5256
- match.index + match[0].length,
5257
- getReplacement(match, this.original),
5258
- );
5265
+ }
5266
+ }
5259
5267
  }
5260
5268
  return this;
5261
5269
  }
@@ -5287,7 +5295,9 @@ class MagicString {
5287
5295
  index !== -1;
5288
5296
  index = original.indexOf(string, index + stringLength)
5289
5297
  ) {
5290
- this.overwrite(index, index + stringLength, replacement);
5298
+ const previous = original.slice(index, index + stringLength);
5299
+ if (previous !== replacement)
5300
+ this.overwrite(index, index + stringLength, replacement);
5291
5301
  }
5292
5302
 
5293
5303
  return this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.0.0-alpha.0",
3
+ "version": "6.0.0-alpha.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -81,7 +81,7 @@
81
81
  },
82
82
  "devDependencies": {
83
83
  "@ampproject/remapping": "^2.3.0",
84
- "@babel/parser": "^7.24.1",
84
+ "@babel/parser": "^7.24.4",
85
85
  "@jridgewell/trace-mapping": "^0.3.25",
86
86
  "@polka/compression": "^1.0.0-next.25",
87
87
  "@rollup/plugin-alias": "^5.1.0",
@@ -114,7 +114,7 @@
114
114
  "http-proxy": "^1.18.1",
115
115
  "launch-editor-middleware": "^2.6.1",
116
116
  "lightningcss": "^1.24.1",
117
- "magic-string": "^0.30.8",
117
+ "magic-string": "^0.30.9",
118
118
  "micromatch": "^4.0.5",
119
119
  "mlly": "^1.6.1",
120
120
  "mrmime": "^2.0.0",
@@ -131,10 +131,11 @@
131
131
  "rollup-plugin-dts": "^6.1.0",
132
132
  "rollup-plugin-esbuild": "^6.1.1",
133
133
  "rollup-plugin-license": "^3.3.1",
134
+ "sass": "^1.74.1",
134
135
  "sirv": "^2.0.4",
135
136
  "source-map-support": "^0.5.21",
136
137
  "strip-ansi": "^7.1.0",
137
- "strip-literal": "^2.0.0",
138
+ "strip-literal": "^2.1.0",
138
139
  "tsconfck": "^3.0.3",
139
140
  "tslib": "^2.6.2",
140
141
  "types": "link:./types",