vite 5.0.0-beta.3 → 5.0.0-beta.5

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 { E as commonjsGlobal, D as getDefaultExportFromCjs } from './dep-dc9999ab.js';
1
+ import { E as commonjsGlobal, D as getDefaultExportFromCjs } from './dep-4109817a.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -1,4 +1,4 @@
1
- import { D as getDefaultExportFromCjs } from './dep-dc9999ab.js';
1
+ import { D as getDefaultExportFromCjs } from './dep-4109817a.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-c423598f.js';
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-dc9999ab.js';
5
+ import { C as colors, x as createLogger, h as resolveConfig } from './chunks/dep-4109817a.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -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-dc9999ab.js').then(function (n) { return n.H; });
762
+ const { createServer } = await import('./chunks/dep-4109817a.js').then(function (n) { return n.H; });
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-dc9999ab.js').then(function (n) { return n.G; });
843
+ const { build } = await import('./chunks/dep-4109817a.js').then(function (n) { return n.G; });
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-dc9999ab.js').then(function (n) { return n.F; });
871
+ const { optimizeDeps } = await import('./chunks/dep-4109817a.js').then(function (n) { return n.F; });
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-dc9999ab.js').then(function (n) { return n.I; });
898
+ const { preview } = await import('./chunks/dep-4109817a.js').then(function (n) { return n.I; });
899
899
  try {
900
900
  const server = await preview({
901
901
  root,
@@ -225,8 +225,11 @@ export declare interface BuildOptions {
225
225
  /**
226
226
  * Options for terser
227
227
  * https://terser.org/docs/api-reference#minify-options
228
+ *
229
+ * In addition, you can also pass a `maxWorkers: number` option to specify the
230
+ * max number of workers to spawn. Defaults to the number of CPUs minus 1.
228
231
  */
229
- terserOptions?: Terser.MinifyOptions;
232
+ terserOptions?: TerserOptions;
230
233
  /**
231
234
  * Will be merged with internal rollup options.
232
235
  * https://rollupjs.org/configuration-options/
@@ -2191,13 +2194,6 @@ export declare interface ServerOptions extends CommonServerOptions {
2191
2194
  * sourcemap path and returns whether to ignore the source path.
2192
2195
  */
2193
2196
  sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
2194
- /**
2195
- * Force dep pre-optimization regardless of whether deps have changed.
2196
- *
2197
- * @deprecated Use optimizeDeps.force instead, this option may be removed
2198
- * in a future minor version without following semver
2199
- */
2200
- force?: boolean;
2201
2197
  }
2202
2198
 
2203
2199
  export declare function sortUserPlugins(plugins: (Plugin_2 | Plugin_2[])[] | undefined): [Plugin_2[], Plugin_2[], Plugin_2[]];
@@ -2234,6 +2230,22 @@ export declare interface SSROptions {
2234
2230
  * @experimental
2235
2231
  */
2236
2232
  optimizeDeps?: SsrDepOptimizationOptions;
2233
+ resolve?: {
2234
+ /**
2235
+ * Conditions that are used in the plugin pipeline. The default value is the root config's `resolve.conditions`.
2236
+ *
2237
+ * Use this to override the default ssr conditions for the ssr build.
2238
+ *
2239
+ * @default rootConfig.resolve.conditions
2240
+ */
2241
+ conditions?: string[];
2242
+ /**
2243
+ * Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies.
2244
+ *
2245
+ * @default []
2246
+ */
2247
+ externalConditions?: string[];
2248
+ };
2237
2249
  }
2238
2250
 
2239
2251
  export declare type SSRTarget = 'node' | 'webworker';
@@ -2465,6 +2477,16 @@ export declare namespace Terser {
2465
2477
  }
2466
2478
  }
2467
2479
 
2480
+ export declare interface TerserOptions extends Terser.MinifyOptions {
2481
+ /**
2482
+ * Vite-specific option to specify the max number of workers to spawn
2483
+ * when minifying files with terser.
2484
+ *
2485
+ * @default number of CPUs minus 1
2486
+ */
2487
+ maxWorkers?: number;
2488
+ }
2489
+
2468
2490
  export declare interface TransformOptions {
2469
2491
  ssr?: boolean;
2470
2492
  html?: boolean;
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-dc9999ab.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-dc9999ab.js';
1
+ import { i as isInNodeModules } from './chunks/dep-4109817a.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-4109817a.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';
@@ -3374,7 +3374,7 @@ function isInNodeModules(id) {
3374
3374
  return id.includes('node_modules');
3375
3375
  }
3376
3376
  // TODO: use import()
3377
- const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)));
3377
+ node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)));
3378
3378
  // set in bin/vite.js
3379
3379
  const filter = process.env.VITE_DEBUG_FILTER;
3380
3380
  const DEBUG = process.env.DEBUG;
@@ -3487,20 +3487,12 @@ function isFileReadable(filename) {
3487
3487
  function arraify(target) {
3488
3488
  return Array.isArray(target) ? target : [target];
3489
3489
  }
3490
- // @ts-expect-error jest only exists when running Jest
3491
- const usingDynamicImport = typeof jest === 'undefined';
3492
3490
  /**
3493
3491
  * Dynamically import files. It will make sure it's not being compiled away by TS/Rollup.
3494
3492
  *
3495
- * As a temporary workaround for Jest's lack of stable ESM support, we fallback to require
3496
- * if we're in a Jest environment.
3497
- * See https://github.com/vitejs/vite/pull/5197#issuecomment-938054077
3498
- *
3499
3493
  * @param file File path to import.
3500
3494
  */
3501
- usingDynamicImport
3502
- ? new Function('file', 'return import(file)')
3503
- : _require;
3495
+ new Function('file', 'return import(file)');
3504
3496
  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))));
3505
3497
  function mergeConfigRecursively(defaults, overrides, rootPath) {
3506
3498
  const merged = { ...defaults };
@@ -4379,16 +4371,35 @@ class Mappings {
4379
4371
 
4380
4372
  addEdit(sourceIndex, content, loc, nameIndex) {
4381
4373
  if (content.length) {
4374
+ let contentLineEnd = content.indexOf('\n', 0);
4375
+ let previousContentLineEnd = -1;
4376
+ while (contentLineEnd >= 0) {
4377
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
4378
+ if (nameIndex >= 0) {
4379
+ segment.push(nameIndex);
4380
+ }
4381
+ this.rawSegments.push(segment);
4382
+
4383
+ this.generatedCodeLine += 1;
4384
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
4385
+ this.generatedCodeColumn = 0;
4386
+
4387
+ previousContentLineEnd = contentLineEnd;
4388
+ contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
4389
+ }
4390
+
4382
4391
  const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
4383
4392
  if (nameIndex >= 0) {
4384
4393
  segment.push(nameIndex);
4385
4394
  }
4386
4395
  this.rawSegments.push(segment);
4396
+
4397
+ this.advance(content.slice(previousContentLineEnd + 1));
4387
4398
  } else if (this.pending) {
4388
4399
  this.rawSegments.push(this.pending);
4400
+ this.advance(content);
4389
4401
  }
4390
4402
 
4391
- this.advance(content);
4392
4403
  this.pending = null;
4393
4404
  }
4394
4405
 
@@ -5987,6 +5998,14 @@ function expand (config) {
5987
5998
 
5988
5999
  var expand_1 = expand;
5989
6000
 
6001
+ function getEnvFilesForMode(mode) {
6002
+ return [
6003
+ /** default file */ `.env`,
6004
+ /** local file */ `.env.local`,
6005
+ /** mode file */ `.env.${mode}`,
6006
+ /** mode local file */ `.env.${mode}.local`,
6007
+ ];
6008
+ }
5990
6009
  function loadEnv(mode, envDir, prefixes = 'VITE_') {
5991
6010
  if (mode === 'local') {
5992
6011
  throw new Error(`"local" cannot be used as a mode name because it conflicts with ` +
@@ -5994,12 +6013,7 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
5994
6013
  }
5995
6014
  prefixes = arraify(prefixes);
5996
6015
  const env = {};
5997
- const envFiles = [
5998
- /** default file */ `.env`,
5999
- /** local file */ `.env.local`,
6000
- /** mode file */ `.env.${mode}`,
6001
- /** mode local file */ `.env.${mode}.local`,
6002
- ];
6016
+ const envFiles = getEnvFilesForMode(mode);
6003
6017
  const parsed = Object.fromEntries(envFiles.flatMap((file) => {
6004
6018
  const filePath = path$3.join(envDir, file);
6005
6019
  if (!tryStatSync(filePath)?.isFile())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.0.0-beta.3",
3
+ "version": "5.0.0-beta.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -62,7 +62,7 @@
62
62
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
63
63
  "dependencies": {
64
64
  "esbuild": "^0.19.3",
65
- "postcss": "^8.4.30",
65
+ "postcss": "^8.4.31",
66
66
  "rollup": "^3.29.2"
67
67
  },
68
68
  "optionalDependencies": {
@@ -70,16 +70,16 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@ampproject/remapping": "^2.2.1",
73
- "@babel/parser": "^7.22.16",
74
- "@babel/types": "^7.22.19",
73
+ "@babel/parser": "^7.23.0",
74
+ "@babel/types": "^7.23.0",
75
75
  "@jridgewell/trace-mapping": "^0.3.19",
76
- "@rollup/plugin-alias": "^5.0.0",
77
- "@rollup/plugin-commonjs": "^25.0.4",
78
- "@rollup/plugin-dynamic-import-vars": "^2.0.5",
79
- "@rollup/plugin-json": "^6.0.0",
80
- "@rollup/plugin-node-resolve": "15.2.1",
81
- "@rollup/plugin-typescript": "^11.1.3",
82
- "@rollup/pluginutils": "^5.0.4",
76
+ "@rollup/plugin-alias": "^5.0.1",
77
+ "@rollup/plugin-commonjs": "^25.0.5",
78
+ "@rollup/plugin-dynamic-import-vars": "^2.0.6",
79
+ "@rollup/plugin-json": "^6.0.1",
80
+ "@rollup/plugin-node-resolve": "15.2.3",
81
+ "@rollup/plugin-typescript": "^11.1.5",
82
+ "@rollup/pluginutils": "^5.0.5",
83
83
  "@types/escape-html": "^1.0.2",
84
84
  "@types/pnpapi": "^0.0.3",
85
85
  "acorn": "^8.10.0",
@@ -103,9 +103,9 @@
103
103
  "fast-glob": "^3.3.1",
104
104
  "http-proxy": "^1.18.1",
105
105
  "json-stable-stringify": "^1.0.2",
106
- "launch-editor-middleware": "^2.6.0",
106
+ "launch-editor-middleware": "^2.6.1",
107
107
  "lightningcss": "^1.22.0",
108
- "magic-string": "^0.30.3",
108
+ "magic-string": "^0.30.4",
109
109
  "micromatch": "^4.0.5",
110
110
  "mlly": "^1.4.2",
111
111
  "mrmime": "^1.0.1",
@@ -124,10 +124,10 @@
124
124
  "source-map-support": "^0.5.21",
125
125
  "strip-ansi": "^7.1.0",
126
126
  "strip-literal": "^1.3.0",
127
- "tsconfck": "^3.0.0-next.8",
127
+ "tsconfck": "^3.0.0-next.9",
128
128
  "tslib": "^2.6.2",
129
129
  "types": "link:./types",
130
- "ufo": "^1.3.0",
130
+ "ufo": "^1.3.1",
131
131
  "ws": "^8.14.2"
132
132
  },
133
133
  "peerDependencies": {