vite 5.0.0-beta.7 → 5.0.0-beta.9

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 { C as colors, x as createLogger, h as resolveConfig } from './chunks/dep-7af400e9.js';
5
+ import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-ffdf177d.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -13,6 +13,7 @@ import 'esbuild';
13
13
  import 'path';
14
14
  import 'fs';
15
15
  import 'assert';
16
+ import 'node:http';
16
17
  import 'util';
17
18
  import 'net';
18
19
  import 'url';
@@ -27,21 +28,20 @@ import 'node:dns';
27
28
  import 'crypto';
28
29
  import 'node:buffer';
29
30
  import 'module';
30
- import 'rollup';
31
31
  import 'node:assert';
32
32
  import 'node:process';
33
33
  import 'node:v8';
34
- import 'node:http';
34
+ import 'rollup';
35
+ import 'querystring';
36
+ import 'node:readline';
37
+ import 'node:events';
35
38
  import 'node:https';
36
39
  import 'zlib';
37
40
  import 'buffer';
38
41
  import 'https';
39
42
  import 'tls';
40
- import 'worker_threads';
41
- import 'querystring';
42
- import 'node:readline';
43
- import 'node:events';
44
43
  import 'node:zlib';
44
+ import 'worker_threads';
45
45
 
46
46
  function toArr(any) {
47
47
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -759,7 +759,7 @@ cli
759
759
  filterDuplicateOptions(options);
760
760
  // output structure is preserved even after bundling so require()
761
761
  // is ok here
762
- const { createServer } = await import('./chunks/dep-7af400e9.js').then(function (n) { return n.H; });
762
+ const { createServer } = await import('./chunks/dep-ffdf177d.js').then(function (n) { return n.C; });
763
763
  try {
764
764
  const server = await createServer({
765
765
  root,
@@ -840,7 +840,7 @@ cli
840
840
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
841
841
  .action(async (root, options) => {
842
842
  filterDuplicateOptions(options);
843
- const { build } = await import('./chunks/dep-7af400e9.js').then(function (n) { return n.G; });
843
+ const { build } = await import('./chunks/dep-ffdf177d.js').then(function (n) { return n.B; });
844
844
  const buildOptions = cleanOptions(options);
845
845
  try {
846
846
  await build({
@@ -868,7 +868,7 @@ cli
868
868
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
869
869
  .action(async (root, options) => {
870
870
  filterDuplicateOptions(options);
871
- const { optimizeDeps } = await import('./chunks/dep-7af400e9.js').then(function (n) { return n.F; });
871
+ const { optimizeDeps } = await import('./chunks/dep-ffdf177d.js').then(function (n) { return n.A; });
872
872
  try {
873
873
  const config = await resolveConfig({
874
874
  root,
@@ -895,7 +895,7 @@ cli
895
895
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
896
896
  .action(async (root, options) => {
897
897
  filterDuplicateOptions(options);
898
- const { preview } = await import('./chunks/dep-7af400e9.js').then(function (n) { return n.I; });
898
+ const { preview } = await import('./chunks/dep-ffdf177d.js').then(function (n) { return n.D; });
899
899
  try {
900
900
  const server = await preview({
901
901
  root,
@@ -1460,6 +1460,20 @@ interface ServerOptions extends CommonServerOptions {
1460
1460
  * Configure HMR-specific options (port, host, path & protocol)
1461
1461
  */
1462
1462
  hmr?: HmrOptions | boolean;
1463
+ /**
1464
+ * Warm-up files to transform and cache the results in advance. This improves the
1465
+ * initial page load during server starts and prevents transform waterfalls.
1466
+ */
1467
+ warmup?: {
1468
+ /**
1469
+ * The files to be transformed and used on the client-side. Supports glob patterns.
1470
+ */
1471
+ clientFiles?: string[];
1472
+ /**
1473
+ * The files to be transformed and used in SSR. Supports glob patterns.
1474
+ */
1475
+ ssrFiles?: string[];
1476
+ };
1463
1477
  /**
1464
1478
  * chokidar watch options or null to disable FS watching
1465
1479
  * https:
@@ -1636,6 +1650,29 @@ interface ResolvedServerUrls {
1636
1650
  }
1637
1651
  declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
1638
1652
 
1653
+ /** Cache for package.json resolution and package.json contents */
1654
+ type PackageCache = Map<string, PackageData>;
1655
+ interface PackageData {
1656
+ dir: string;
1657
+ hasSideEffects: (id: string) => boolean | 'no-treeshake';
1658
+ webResolvedImports: Record<string, string | undefined>;
1659
+ nodeResolvedImports: Record<string, string | undefined>;
1660
+ setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
1661
+ getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
1662
+ data: {
1663
+ [field: string]: any;
1664
+ name: string;
1665
+ type: string;
1666
+ version: string;
1667
+ main: string;
1668
+ module: string;
1669
+ browser: string | Record<string, string | false>;
1670
+ exports: string | Record<string, any> | string[];
1671
+ imports: Record<string, any>;
1672
+ dependencies: Record<string, string>;
1673
+ };
1674
+ }
1675
+
1639
1676
  interface RollupCommonJSOptions {
1640
1677
  /**
1641
1678
  * A minimatch pattern, or array of patterns, which specifies the files in
@@ -2103,30 +2140,6 @@ interface TerserOptions extends Terser.MinifyOptions {
2103
2140
  maxWorkers?: number;
2104
2141
  }
2105
2142
 
2106
- /** Cache for package.json resolution and package.json contents */
2107
- type PackageCache = Map<string, PackageData>;
2108
- interface PackageData {
2109
- dir: string;
2110
- hasSideEffects: (id: string) => boolean | 'no-treeshake';
2111
- webResolvedImports: Record<string, string | undefined>;
2112
- nodeResolvedImports: Record<string, string | undefined>;
2113
- setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
2114
- getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
2115
- data: {
2116
- [field: string]: any;
2117
- name: string;
2118
- type: string;
2119
- version: string;
2120
- main: string;
2121
- module: string;
2122
- browser: string | Record<string, string | false>;
2123
- exports: string | Record<string, any> | string[];
2124
- imports: Record<string, any>;
2125
- dependencies: Record<string, string>;
2126
- };
2127
- }
2128
- declare function resolvePackageData(pkgName: string, basedir: string, preserveSymlinks?: boolean, packageCache?: PackageCache): PackageData | null;
2129
-
2130
2143
  interface BuildOptions {
2131
2144
  /**
2132
2145
  * Compatibility transform target. The transform is performed with esbuild
@@ -2482,20 +2495,6 @@ type DepOptimizationOptions = DepOptimizationConfig & {
2482
2495
  */
2483
2496
  force?: boolean;
2484
2497
  };
2485
- interface DepOptimizationResult {
2486
- metadata: DepOptimizationMetadata;
2487
- /**
2488
- * When doing a re-run, if there are newly discovered dependencies
2489
- * the page reload will be delayed until the next rerun so we need
2490
- * to be able to discard the result
2491
- */
2492
- commit: () => Promise<void>;
2493
- cancel: () => void;
2494
- }
2495
- interface DepOptimizationProcessing {
2496
- promise: Promise<void>;
2497
- resolve: () => void;
2498
- }
2499
2498
  interface OptimizedDepInfo {
2500
2499
  id: string;
2501
2500
  file: string;
@@ -2635,7 +2634,6 @@ interface InternalResolveOptions extends Required<ResolveOptions> {
2635
2634
  getDepsOptimizer?: (ssr: boolean) => DepsOptimizer | undefined;
2636
2635
  shouldExternalize?: (id: string, importer?: string) => boolean | undefined;
2637
2636
  }
2638
- declare function resolvePackageEntry(id: string, { dir, data, setResolvedCache, getResolvedCache }: PackageData, targetWeb: boolean, options: InternalResolveOptions): string | undefined;
2639
2637
 
2640
2638
  interface Targets {
2641
2639
  android?: number,
@@ -3145,7 +3143,7 @@ interface ExperimentalOptions {
3145
3143
  }
3146
3144
  interface LegacyOptions {
3147
3145
  }
3148
- interface ResolveWorkerOptions extends PluginHookUtils {
3146
+ interface ResolvedWorkerOptions extends PluginHookUtils {
3149
3147
  format: 'es' | 'iife';
3150
3148
  plugins: Plugin[];
3151
3149
  rollupOptions: RollupOptions;
@@ -3182,7 +3180,7 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
3182
3180
  logger: Logger;
3183
3181
  createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
3184
3182
  optimizeDeps: DepOptimizationOptions;
3185
- worker: ResolveWorkerOptions;
3183
+ worker: ResolvedWorkerOptions;
3186
3184
  appType: AppType;
3187
3185
  experimental: ExperimentalOptions;
3188
3186
  } & PluginHookUtils>;
@@ -3192,19 +3190,12 @@ interface PluginHookUtils {
3192
3190
  }
3193
3191
  type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
3194
3192
  declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string): Promise<ResolvedConfig>;
3195
- /**
3196
- * Resolve base url. Note that some users use Vite to build for non-web targets like
3197
- * electron or expects to deploy
3198
- */
3199
- declare function resolveBaseUrl(base: string | undefined, isBuild: boolean, logger: Logger): string;
3200
3193
  declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
3201
3194
  declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
3202
3195
  path: string;
3203
3196
  config: UserConfig;
3204
3197
  dependencies: string[];
3205
3198
  } | null>;
3206
- declare function getDepOptimizationConfig(config: ResolvedConfig, ssr: boolean): DepOptimizationConfig;
3207
- declare function isDepsOptimizerEnabled(config: ResolvedConfig, ssr: boolean): boolean;
3208
3199
 
3209
3200
  declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
3210
3201
 
@@ -3267,4 +3258,4 @@ interface ManifestChunk {
3267
3258
  dynamicImports?: string[];
3268
3259
  }
3269
3260
 
3270
- export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, type BuildOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, type DepOptimizationProcessing, type DepOptimizationResult, type DepsOptimizer, type ESBuildOptions, type ESBuildTransformResult, type ExperimentalOptions, type ExportsData, FSWatcher, type FileSystemServeOptions, type FilterPattern, type HmrContext, type HmrOptions, type HookHandler, 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 PackageCache, type PackageData, type Plugin, type PluginContainer, type PluginHookUtils, type PluginOption, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolveWorkerOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolverFunction, type ResolverObject, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type SSROptions, type SSRTarget, type SendOptions, type ServerHook, 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, createServer, defineConfig, formatPostcssSourceMap, getDepOptimizationConfig, isCSSRequest, isDepsOptimizerEnabled, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, normalizePath, optimizeDeps, preprocessCSS, preview, resolveBaseUrl, resolveConfig, resolveEnvPrefix, resolvePackageData, resolvePackageEntry, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
3261
+ export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type AwaitWriteFinishOptions, type BindCLIShortcutsOptions, type BuildOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type CommonServerOptions, type ConfigEnv, Connect, type CorsOptions, type CorsOrigin, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, type ESBuildOptions, type ESBuildTransformResult, type ExperimentalOptions, type ExportsData, FSWatcher, type FileSystemServeOptions, type FilterPattern, type HmrContext, type HmrOptions, type HookHandler, 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, 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 ServerHook, 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, createServer, defineConfig, formatPostcssSourceMap, isCSSRequest, isFileServingAllowed, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, normalizePath, optimizeDeps, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, searchForWorkspaceRoot, send, sortUserPlugins, splitVendorChunk, splitVendorChunkPlugin, transformWithEsbuild, VERSION as version };
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-7af400e9.js';
2
- export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-7af400e9.js';
1
+ import { i as isInNodeModules } from './chunks/dep-ffdf177d.js';
2
+ export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-ffdf177d.js';
3
3
  export { VERSION as version } from './constants.js';
4
4
  export { version as esbuildVersion } from 'esbuild';
5
5
  export { VERSION as rollupVersion } from 'rollup';
@@ -15,6 +15,7 @@ import 'path';
15
15
  import 'fs';
16
16
  import 'events';
17
17
  import 'assert';
18
+ import 'node:http';
18
19
  import 'util';
19
20
  import 'net';
20
21
  import 'url';
@@ -32,17 +33,16 @@ import 'module';
32
33
  import 'node:assert';
33
34
  import 'node:process';
34
35
  import 'node:v8';
35
- import 'node:http';
36
+ import 'querystring';
37
+ import 'node:readline';
38
+ import 'node:events';
36
39
  import 'node:https';
37
40
  import 'zlib';
38
41
  import 'buffer';
39
42
  import 'https';
40
43
  import 'tls';
41
- import 'worker_threads';
42
- import 'querystring';
43
- import 'node:readline';
44
- import 'node:events';
45
44
  import 'node:zlib';
45
+ import 'worker_threads';
46
46
 
47
47
  // This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
48
48
  // copy from constants.ts
@@ -3487,12 +3487,6 @@ function isFileReadable(filename) {
3487
3487
  function arraify(target) {
3488
3488
  return Array.isArray(target) ? target : [target];
3489
3489
  }
3490
- /**
3491
- * Dynamically import files. It will make sure it's not being compiled away by TS/Rollup.
3492
- *
3493
- * @param file File path to import.
3494
- */
3495
- new Function('file', 'return import(file)');
3496
3490
  path$3.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))));
3497
3491
  function mergeConfigRecursively(defaults, overrides, rootPath) {
3498
3492
  const merged = { ...defaults };
package/index.cjs CHANGED
@@ -25,16 +25,6 @@ asyncFunctions.forEach((name) => {
25
25
  import('./dist/node/index.js').then((i) => i[name](...args))
26
26
  })
27
27
 
28
- // some sync functions are marked not supported due to their complexity and uncommon usage
29
- const unsupportedCJS = ['resolvePackageEntry', 'resolvePackageData']
30
- unsupportedCJS.forEach((name) => {
31
- module.exports[name] = () => {
32
- throw new Error(
33
- `"${name}" is not supported in CJS build of Vite 4.\nPlease use ESM or dynamic imports \`const { ${name} } = await import('vite')\`.`,
34
- )
35
- }
36
- })
37
-
38
28
  function warnCjsUsage() {
39
29
  if (process.env.VITE_CJS_IGNORE_WARNING) return
40
30
  globalThis.__vite_cjs_skip_clear_screen = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.0.0-beta.7",
3
+ "version": "5.0.0-beta.9",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -72,8 +72,8 @@
72
72
  "@ampproject/remapping": "^2.2.1",
73
73
  "@jridgewell/trace-mapping": "^0.3.19",
74
74
  "@rollup/plugin-alias": "^5.0.1",
75
- "@rollup/plugin-commonjs": "^25.0.5",
76
- "@rollup/plugin-dynamic-import-vars": "^2.0.6",
75
+ "@rollup/plugin-commonjs": "^25.0.7",
76
+ "@rollup/plugin-dynamic-import-vars": "^2.0.7",
77
77
  "@rollup/plugin-json": "^6.0.1",
78
78
  "@rollup/plugin-node-resolve": "15.2.3",
79
79
  "@rollup/plugin-typescript": "^11.1.5",
@@ -103,7 +103,7 @@
103
103
  "json-stable-stringify": "^1.0.2",
104
104
  "launch-editor-middleware": "^2.6.1",
105
105
  "lightningcss": "^1.22.0",
106
- "magic-string": "^0.30.4",
106
+ "magic-string": "^0.30.5",
107
107
  "micromatch": "^4.0.5",
108
108
  "mlly": "^1.4.2",
109
109
  "mrmime": "^1.0.1",
@@ -118,12 +118,12 @@
118
118
  "postcss-modules": "^6.0.0",
119
119
  "resolve.exports": "^2.0.2",
120
120
  "rollup-plugin-dts": "^6.1.0",
121
- "rollup-plugin-license": "^3.1.0",
121
+ "rollup-plugin-license": "^3.2.0",
122
122
  "sirv": "^2.0.3",
123
123
  "source-map-support": "^0.5.21",
124
124
  "strip-ansi": "^7.1.0",
125
125
  "strip-literal": "^1.3.0",
126
- "tsconfck": "^3.0.0-next.9",
126
+ "tsconfck": "^3.0.0",
127
127
  "tslib": "^2.6.2",
128
128
  "types": "link:./types",
129
129
  "ufo": "^1.3.1",
@@ -0,0 +1,5 @@
1
+ /// <reference path="./importMeta.d.ts" />
2
+
3
+ // https://github.com/microsoft/TypeScript/issues/45096
4
+ // TypeScript has a bug that makes <reference types="vite/types/importMeta" />
5
+ // not possible in userland. This file provides a workaround for now.