vite 5.1.0-beta.7 → 5.1.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.
@@ -1,4 +1,4 @@
1
- import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-G1t0FnMB.js';
1
+ import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-nGG-_oRu.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 { B as getDefaultExportFromCjs } from './dep-G1t0FnMB.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-nGG-_oRu.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-8a-6Quh6.js';
@@ -6421,6 +6421,16 @@ class Chunk {
6421
6421
  this.intro = content + this.intro;
6422
6422
  }
6423
6423
 
6424
+ reset() {
6425
+ this.intro = '';
6426
+ this.outro = '';
6427
+ if (this.edited) {
6428
+ this.content = this.original;
6429
+ this.storeName = false;
6430
+ this.edited = false;
6431
+ }
6432
+ }
6433
+
6424
6434
  split(index) {
6425
6435
  const sliceIndex = index - this.start;
6426
6436
 
@@ -6511,8 +6521,8 @@ class Chunk {
6511
6521
  }
6512
6522
 
6513
6523
  function getBtoa() {
6514
- if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
6515
- return (str) => window.btoa(unescape(encodeURIComponent(str)));
6524
+ if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
6525
+ return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
6516
6526
  } else if (typeof Buffer === 'function') {
6517
6527
  return (str) => Buffer.from(str, 'utf-8').toString('base64');
6518
6528
  } else {
@@ -7189,6 +7199,28 @@ class MagicString {
7189
7199
  return this;
7190
7200
  }
7191
7201
 
7202
+ reset(start, end) {
7203
+ while (start < 0) start += this.original.length;
7204
+ while (end < 0) end += this.original.length;
7205
+
7206
+ if (start === end) return this;
7207
+
7208
+ if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
7209
+ if (start > end) throw new Error('end must be greater than start');
7210
+
7211
+ this._split(start);
7212
+ this._split(end);
7213
+
7214
+ let chunk = this.byStart[start];
7215
+
7216
+ while (chunk) {
7217
+ chunk.reset();
7218
+
7219
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
7220
+ }
7221
+ return this;
7222
+ }
7223
+
7192
7224
  lastChar() {
7193
7225
  if (this.outro.length) return this.outro[this.outro.length - 1];
7194
7226
  let chunk = this.lastChunk;
@@ -13973,19 +14005,7 @@ async function parse$f(filename, options) {
13973
14005
  /** @type {import('./cache.js').TSConfckCache} */
13974
14006
  const cache = options?.cache;
13975
14007
  if (cache?.hasParseResult(filename)) {
13976
- const result = await cache.getParseResult(filename);
13977
- if (
13978
- (result.tsconfig.extends && !result.extended) ||
13979
- (result.tsconfig.references && !result.referenced)
13980
- ) {
13981
- const promise = Promise.all([
13982
- parseExtends(result, cache),
13983
- parseReferences(result, options)
13984
- ]).then(() => result);
13985
- cache.setParseResult(filename, promise);
13986
- await promise;
13987
- }
13988
- return result;
14008
+ return getParsedDeep(filename, cache, options);
13989
14009
  }
13990
14010
  const {
13991
14011
  resolve,
@@ -14003,7 +14023,7 @@ async function parse$f(filename, options) {
14003
14023
  }
14004
14024
  let result;
14005
14025
  if (filename !== tsconfigFile && cache?.hasParseResult(tsconfigFile)) {
14006
- result = await cache.getParseResult(tsconfigFile);
14026
+ result = await getParsedDeep(tsconfigFile, cache, options);
14007
14027
  } else {
14008
14028
  result = await parseFile$1(tsconfigFile, cache, filename === tsconfigFile);
14009
14029
  await Promise.all([parseExtends(result, cache), parseReferences(result, options)]);
@@ -14015,6 +14035,29 @@ async function parse$f(filename, options) {
14015
14035
  return promise;
14016
14036
  }
14017
14037
 
14038
+ /**
14039
+ * ensure extends and references are parsed
14040
+ *
14041
+ * @param {string} filename - cached file
14042
+ * @param {import('./cache.js').TSConfckCache} cache - cache
14043
+ * @param {import('./public.d.ts').TSConfckParseOptions} options - options
14044
+ */
14045
+ async function getParsedDeep(filename, cache, options) {
14046
+ const result = await cache.getParseResult(filename);
14047
+ if (
14048
+ (result.tsconfig.extends && !result.extended) ||
14049
+ (result.tsconfig.references && !result.referenced)
14050
+ ) {
14051
+ const promise = Promise.all([
14052
+ parseExtends(result, cache),
14053
+ parseReferences(result, options)
14054
+ ]).then(() => result);
14055
+ cache.setParseResult(filename, promise);
14056
+ return promise;
14057
+ }
14058
+ return result;
14059
+ }
14060
+
14018
14061
  /**
14019
14062
  *
14020
14063
  * @param {string} tsconfigFile - path to tsconfig file
@@ -29558,7 +29601,7 @@ function stripLiteralDetailed(code, options) {
29558
29601
  var main$1 = {exports: {}};
29559
29602
 
29560
29603
  var name = "dotenv";
29561
- var version$2 = "16.3.2";
29604
+ var version$2 = "16.4.1";
29562
29605
  var description = "Loads environment variables from .env file";
29563
29606
  var main = "lib/main.js";
29564
29607
  var types$2 = "lib/main.d.ts";
@@ -29692,7 +29735,9 @@ function _parseVault (options) {
29692
29735
  // Parse .env.vault
29693
29736
  const result = DotenvModule.configDotenv({ path: vaultPath });
29694
29737
  if (!result.parsed) {
29695
- throw new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)
29738
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
29739
+ err.code = 'MISSING_DATA';
29740
+ throw err
29696
29741
  }
29697
29742
 
29698
29743
  // handle scenario for comma separated keys - for use with key rotation
@@ -29760,7 +29805,9 @@ function _instructions (result, dotenvKey) {
29760
29805
  uri = new URL(dotenvKey);
29761
29806
  } catch (error) {
29762
29807
  if (error.code === 'ERR_INVALID_URL') {
29763
- throw new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development')
29808
+ const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development');
29809
+ err.code = 'INVALID_DOTENV_KEY';
29810
+ throw err
29764
29811
  }
29765
29812
 
29766
29813
  throw error
@@ -29769,34 +29816,53 @@ function _instructions (result, dotenvKey) {
29769
29816
  // Get decrypt key
29770
29817
  const key = uri.password;
29771
29818
  if (!key) {
29772
- throw new Error('INVALID_DOTENV_KEY: Missing key part')
29819
+ const err = new Error('INVALID_DOTENV_KEY: Missing key part');
29820
+ err.code = 'INVALID_DOTENV_KEY';
29821
+ throw err
29773
29822
  }
29774
29823
 
29775
29824
  // Get environment
29776
29825
  const environment = uri.searchParams.get('environment');
29777
29826
  if (!environment) {
29778
- throw new Error('INVALID_DOTENV_KEY: Missing environment part')
29827
+ const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
29828
+ err.code = 'INVALID_DOTENV_KEY';
29829
+ throw err
29779
29830
  }
29780
29831
 
29781
29832
  // Get ciphertext payload
29782
29833
  const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
29783
29834
  const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
29784
29835
  if (!ciphertext) {
29785
- throw new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)
29836
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
29837
+ err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
29838
+ throw err
29786
29839
  }
29787
29840
 
29788
29841
  return { ciphertext, key }
29789
29842
  }
29790
29843
 
29791
29844
  function _vaultPath (options) {
29792
- let dotenvPath = path$9.resolve(process.cwd(), '.env');
29845
+ let possibleVaultPath = null;
29793
29846
 
29794
29847
  if (options && options.path && options.path.length > 0) {
29795
- dotenvPath = options.path;
29848
+ if (Array.isArray(options.path)) {
29849
+ for (const filepath of options.path) {
29850
+ if (fs$9.existsSync(filepath)) {
29851
+ possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
29852
+ }
29853
+ }
29854
+ } else {
29855
+ possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
29856
+ }
29857
+ } else {
29858
+ possibleVaultPath = path$9.resolve(process.cwd(), '.env.vault');
29859
+ }
29860
+
29861
+ if (fs$9.existsSync(possibleVaultPath)) {
29862
+ return possibleVaultPath
29796
29863
  }
29797
29864
 
29798
- // Locate .env.vault
29799
- return dotenvPath.endsWith('.vault') ? dotenvPath : `${dotenvPath}.vault`
29865
+ return null
29800
29866
  }
29801
29867
 
29802
29868
  function _resolveHome (envPath) {
@@ -29825,7 +29891,18 @@ function configDotenv (options) {
29825
29891
 
29826
29892
  if (options) {
29827
29893
  if (options.path != null) {
29828
- dotenvPath = _resolveHome(options.path);
29894
+ let envPath = options.path;
29895
+
29896
+ if (Array.isArray(envPath)) {
29897
+ for (const filepath of options.path) {
29898
+ if (fs$9.existsSync(filepath)) {
29899
+ envPath = filepath;
29900
+ break
29901
+ }
29902
+ }
29903
+ }
29904
+
29905
+ dotenvPath = _resolveHome(envPath);
29829
29906
  }
29830
29907
  if (options.encoding != null) {
29831
29908
  encoding = options.encoding;
@@ -29859,15 +29936,15 @@ function configDotenv (options) {
29859
29936
 
29860
29937
  // Populates process.env from .env file
29861
29938
  function config (options) {
29862
- const vaultPath = _vaultPath(options);
29863
-
29864
29939
  // fallback to original dotenv if DOTENV_KEY is not set
29865
29940
  if (_dotenvKey(options).length === 0) {
29866
29941
  return DotenvModule.configDotenv(options)
29867
29942
  }
29868
29943
 
29944
+ const vaultPath = _vaultPath(options);
29945
+
29869
29946
  // dotenvKey exists but .env.vault file does not exist
29870
- if (!fs$9.existsSync(vaultPath)) {
29947
+ if (!vaultPath) {
29871
29948
  _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
29872
29949
 
29873
29950
  return DotenvModule.configDotenv(options)
@@ -29894,14 +29971,14 @@ function decrypt (encrypted, keyStr) {
29894
29971
  const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
29895
29972
 
29896
29973
  if (isRange || invalidKeyLength) {
29897
- const msg = 'INVALID_DOTENV_KEY: It must be 64 characters long (or more)';
29898
- throw new Error(msg)
29974
+ const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
29975
+ err.code = 'INVALID_DOTENV_KEY';
29976
+ throw err
29899
29977
  } else if (decryptionFailed) {
29900
- const msg = 'DECRYPTION_FAILED: Please check your DOTENV_KEY';
29901
- throw new Error(msg)
29978
+ const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
29979
+ err.code = 'DECRYPTION_FAILED';
29980
+ throw err
29902
29981
  } else {
29903
- console.error('Error: ', error.code);
29904
- console.error('Error: ', error.message);
29905
29982
  throw error
29906
29983
  }
29907
29984
  }
@@ -29913,7 +29990,9 @@ function populate (processEnv, parsed, options = {}) {
29913
29990
  const override = Boolean(options && options.override);
29914
29991
 
29915
29992
  if (typeof parsed !== 'object') {
29916
- throw new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')
29993
+ const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
29994
+ err.code = 'OBJECT_REQUIRED';
29995
+ throw err
29917
29996
  }
29918
29997
 
29919
29998
  // Set process.env
@@ -32002,8 +32081,8 @@ function createCachedImport(imp) {
32002
32081
  return cached;
32003
32082
  };
32004
32083
  }
32005
- const importPostcssImport = createCachedImport(() => import('./dep-ma2Y1b9q.js').then(function (n) { return n.i; }));
32006
- const importPostcssModules = createCachedImport(() => import('./dep-go6jvlFO.js').then(function (n) { return n.i; }));
32084
+ const importPostcssImport = createCachedImport(() => import('./dep-QywIN17l.js').then(function (n) { return n.i; }));
32085
+ const importPostcssModules = createCachedImport(() => import('./dep-BWGc69YA.js').then(function (n) { return n.i; }));
32007
32086
  const importPostcss = createCachedImport(() => import('postcss'));
32008
32087
  const preprocessorWorkerControllerCache = new WeakMap();
32009
32088
  let alwaysFakeWorkerWorkerControllerCache;
@@ -38984,6 +39063,7 @@ function tokenizer(input, options) {
38984
39063
 
38985
39064
  const HASH_RE = /#/g;
38986
39065
  const AMPERSAND_RE = /&/g;
39066
+ const SLASH_RE = /\//g;
38987
39067
  const EQUAL_RE = /=/g;
38988
39068
  const PLUS_RE = /\+/g;
38989
39069
  const ENC_CARET_RE = /%5e/gi;
@@ -38994,7 +39074,7 @@ function encode(text) {
38994
39074
  return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
38995
39075
  }
38996
39076
  function encodeQueryValue(input) {
38997
- return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^");
39077
+ return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
38998
39078
  }
38999
39079
  function encodeQueryKey(text) {
39000
39080
  return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
@@ -43831,6 +43911,7 @@ var constants$1 = {};
43831
43911
  exports.FSEVENT_MOVED = 'moved';
43832
43912
  exports.FSEVENT_CLONED = 'cloned';
43833
43913
  exports.FSEVENT_UNKNOWN = 'unknown';
43914
+ exports.FSEVENT_FLAG_MUST_SCAN_SUBDIRS = 1;
43834
43915
  exports.FSEVENT_TYPE_FILE = 'file';
43835
43916
  exports.FSEVENT_TYPE_DIRECTORY = 'directory';
43836
43917
  exports.FSEVENT_TYPE_SYMLINK = 'symlink';
@@ -44554,6 +44635,7 @@ const {
44554
44635
  FSEVENT_MOVED,
44555
44636
  // FSEVENT_CLONED,
44556
44637
  FSEVENT_UNKNOWN,
44638
+ FSEVENT_FLAG_MUST_SCAN_SUBDIRS,
44557
44639
  FSEVENT_TYPE_FILE,
44558
44640
  FSEVENT_TYPE_DIRECTORY,
44559
44641
  FSEVENT_TYPE_SYMLINK,
@@ -44665,6 +44747,7 @@ function setFSEventsListener(path, realPath, listener, rawEmitter) {
44665
44747
  rawEmitter,
44666
44748
  watcher: createFSEventsInstance(watchPath, (fullPath, flags) => {
44667
44749
  if (!cont.listeners.size) return;
44750
+ if (flags & FSEVENT_FLAG_MUST_SCAN_SUBDIRS) return;
44668
44751
  const info = fsevents.getInfo(fullPath, flags);
44669
44752
  cont.listeners.forEach(list => {
44670
44753
  list(fullPath, flags, info);
@@ -45484,7 +45567,7 @@ add(paths_, _origAdd, _internal) {
45484
45567
 
45485
45568
  if (this.options.useFsEvents && this._fsEventsHandler) {
45486
45569
  if (!this._readyCount) this._readyCount = paths.length;
45487
- if (this.options.persistent) this._readyCount *= 2;
45570
+ if (this.options.persistent) this._readyCount += paths.length;
45488
45571
  paths.forEach((path) => this._fsEventsHandler._addToFsEvents(path));
45489
45572
  } else {
45490
45573
  if (!this._readyCount) this._readyCount = 0;
@@ -50937,16 +51020,15 @@ function orderedDependencies(deps) {
50937
51020
  return Object.fromEntries(depsList);
50938
51021
  }
50939
51022
  function globEntries(pattern, config) {
50940
- const rootPattern = glob.convertPathToPattern(config.root);
50941
51023
  return glob(pattern, {
50942
51024
  cwd: config.root,
50943
51025
  ignore: [
50944
- `${rootPattern}/**/node_modules/**`,
50945
- `${rootPattern}/**/${config.build.outDir}/**`,
51026
+ '**/node_modules/**',
51027
+ `**/${config.build.outDir}/**`,
50946
51028
  // if there aren't explicit entries, also ignore other common folders
50947
51029
  ...(config.optimizeDeps.entries
50948
51030
  ? []
50949
- : [`${rootPattern}/**/__tests__/**`, `${rootPattern}/**/coverage/**`]),
51031
+ : [`**/__tests__/**`, `**/coverage/**`]),
50950
51032
  ],
50951
51033
  absolute: true,
50952
51034
  suppressErrors: true, // suppress EACCES errors
@@ -67493,7 +67575,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
67493
67575
  };
67494
67576
  let { configFile } = config;
67495
67577
  if (configFile !== false) {
67496
- const loadResult = await loadConfigFromFile(configEnv, configFile, config.root, config.logLevel);
67578
+ const loadResult = await loadConfigFromFile(configEnv, configFile, config.root, config.logLevel, config.customLogger);
67497
67579
  if (loadResult) {
67498
67580
  config = mergeConfig(loadResult.config, config);
67499
67581
  configFile = loadResult.path;
@@ -67855,7 +67937,7 @@ function sortUserPlugins(plugins) {
67855
67937
  }
67856
67938
  return [prePlugins, normalPlugins, postPlugins];
67857
67939
  }
67858
- async function loadConfigFromFile(configEnv, configFile, configRoot = process.cwd(), logLevel) {
67940
+ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cwd(), logLevel, customLogger) {
67859
67941
  const start = performance.now();
67860
67942
  const getTime = () => `${(performance.now() - start).toFixed(2)}ms`;
67861
67943
  let resolvedPath;
@@ -67896,7 +67978,9 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
67896
67978
  };
67897
67979
  }
67898
67980
  catch (e) {
67899
- createLogger(logLevel).error(colors$1.red(`failed to load config from ${resolvedPath}`), { error: e });
67981
+ createLogger(logLevel, { customLogger }).error(colors$1.red(`failed to load config from ${resolvedPath}`), {
67982
+ error: e,
67983
+ });
67900
67984
  throw e;
67901
67985
  }
67902
67986
  }
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, a as createLogger, r as resolveConfig } from './chunks/dep-G1t0FnMB.js';
5
+ import { c as colors, a as createLogger, r as resolveConfig } from './chunks/dep-nGG-_oRu.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -757,7 +757,7 @@ cli
757
757
  filterDuplicateOptions(options);
758
758
  // output structure is preserved even after bundling so require()
759
759
  // is ok here
760
- const { createServer } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.E; });
760
+ const { createServer } = await import('./chunks/dep-nGG-_oRu.js').then(function (n) { return n.E; });
761
761
  try {
762
762
  const server = await createServer({
763
763
  root,
@@ -832,12 +832,11 @@ cli
832
832
  `or specify minifier to use (default: esbuild)`)
833
833
  .option('--manifest [name]', `[boolean | string] emit build manifest json`)
834
834
  .option('--ssrManifest [name]', `[boolean | string] emit ssr manifest json`)
835
- .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle (experimental)`)
836
835
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
837
836
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
838
837
  .action(async (root, options) => {
839
838
  filterDuplicateOptions(options);
840
- const { build } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.F; });
839
+ const { build } = await import('./chunks/dep-nGG-_oRu.js').then(function (n) { return n.F; });
841
840
  const buildOptions = cleanOptions(options);
842
841
  try {
843
842
  await build({
@@ -847,7 +846,6 @@ cli
847
846
  configFile: options.config,
848
847
  logLevel: options.logLevel,
849
848
  clearScreen: options.clearScreen,
850
- optimizeDeps: { force: options.force },
851
849
  build: buildOptions,
852
850
  });
853
851
  }
@@ -865,7 +863,7 @@ cli
865
863
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
866
864
  .action(async (root, options) => {
867
865
  filterDuplicateOptions(options);
868
- const { optimizeDeps } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.D; });
866
+ const { optimizeDeps } = await import('./chunks/dep-nGG-_oRu.js').then(function (n) { return n.D; });
869
867
  try {
870
868
  const config = await resolveConfig({
871
869
  root,
@@ -891,7 +889,7 @@ cli
891
889
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
892
890
  .action(async (root, options) => {
893
891
  filterDuplicateOptions(options);
894
- const { preview } = await import('./chunks/dep-G1t0FnMB.js').then(function (n) { return n.G; });
892
+ const { preview } = await import('./chunks/dep-nGG-_oRu.js').then(function (n) { return n.G; });
895
893
  try {
896
894
  const server = await preview({
897
895
  root,
@@ -3386,7 +3386,7 @@ interface PluginHookUtils {
3386
3386
  type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
3387
3387
  declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean): Promise<ResolvedConfig>;
3388
3388
  declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
3389
- declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
3389
+ declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, customLogger?: Logger): Promise<{
3390
3390
  path: string;
3391
3391
  config: UserConfig;
3392
3392
  dependencies: string[];
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, b as arraify } from './chunks/dep-G1t0FnMB.js';
3
- export { f as build, j as buildErrorMessage, u as createFilter, a as createLogger, e as createServer, d as defineConfig, k as fetchModule, g as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-G1t0FnMB.js';
2
+ import { i as isInNodeModules, b as arraify } from './chunks/dep-nGG-_oRu.js';
3
+ export { f as build, j as buildErrorMessage, u as createFilter, a as createLogger, e as createServer, d as defineConfig, k as fetchModule, g as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, h as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-nGG-_oRu.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import { existsSync, readFileSync } from 'node:fs';
@@ -4169,6 +4169,16 @@ class Chunk {
4169
4169
  this.intro = content + this.intro;
4170
4170
  }
4171
4171
 
4172
+ reset() {
4173
+ this.intro = '';
4174
+ this.outro = '';
4175
+ if (this.edited) {
4176
+ this.content = this.original;
4177
+ this.storeName = false;
4178
+ this.edited = false;
4179
+ }
4180
+ }
4181
+
4172
4182
  split(index) {
4173
4183
  const sliceIndex = index - this.start;
4174
4184
 
@@ -4259,8 +4269,8 @@ class Chunk {
4259
4269
  }
4260
4270
 
4261
4271
  function getBtoa() {
4262
- if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
4263
- return (str) => window.btoa(unescape(encodeURIComponent(str)));
4272
+ if (typeof globalThis !== 'undefined' && typeof globalThis.btoa === 'function') {
4273
+ return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
4264
4274
  } else if (typeof Buffer === 'function') {
4265
4275
  return (str) => Buffer.from(str, 'utf-8').toString('base64');
4266
4276
  } else {
@@ -4937,6 +4947,28 @@ class MagicString {
4937
4947
  return this;
4938
4948
  }
4939
4949
 
4950
+ reset(start, end) {
4951
+ while (start < 0) start += this.original.length;
4952
+ while (end < 0) end += this.original.length;
4953
+
4954
+ if (start === end) return this;
4955
+
4956
+ if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
4957
+ if (start > end) throw new Error('end must be greater than start');
4958
+
4959
+ this._split(start);
4960
+ this._split(end);
4961
+
4962
+ let chunk = this.byStart[start];
4963
+
4964
+ while (chunk) {
4965
+ chunk.reset();
4966
+
4967
+ chunk = end > chunk.end ? this.byStart[chunk.end] : null;
4968
+ }
4969
+ return this;
4970
+ }
4971
+
4940
4972
  lastChar() {
4941
4973
  if (this.outro.length) return this.outro[this.outro.length - 1];
4942
4974
  let chunk = this.lastChunk;
@@ -5545,7 +5577,7 @@ function isFileServingAllowed(url, server) {
5545
5577
  var main$1 = {exports: {}};
5546
5578
 
5547
5579
  var name = "dotenv";
5548
- var version$1 = "16.3.2";
5580
+ var version$1 = "16.4.1";
5549
5581
  var description = "Loads environment variables from .env file";
5550
5582
  var main = "lib/main.js";
5551
5583
  var types = "lib/main.d.ts";
@@ -5679,7 +5711,9 @@ function _parseVault (options) {
5679
5711
  // Parse .env.vault
5680
5712
  const result = DotenvModule.configDotenv({ path: vaultPath });
5681
5713
  if (!result.parsed) {
5682
- throw new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)
5714
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
5715
+ err.code = 'MISSING_DATA';
5716
+ throw err
5683
5717
  }
5684
5718
 
5685
5719
  // handle scenario for comma separated keys - for use with key rotation
@@ -5747,7 +5781,9 @@ function _instructions (result, dotenvKey) {
5747
5781
  uri = new URL(dotenvKey);
5748
5782
  } catch (error) {
5749
5783
  if (error.code === 'ERR_INVALID_URL') {
5750
- throw new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development')
5784
+ const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development');
5785
+ err.code = 'INVALID_DOTENV_KEY';
5786
+ throw err
5751
5787
  }
5752
5788
 
5753
5789
  throw error
@@ -5756,34 +5792,53 @@ function _instructions (result, dotenvKey) {
5756
5792
  // Get decrypt key
5757
5793
  const key = uri.password;
5758
5794
  if (!key) {
5759
- throw new Error('INVALID_DOTENV_KEY: Missing key part')
5795
+ const err = new Error('INVALID_DOTENV_KEY: Missing key part');
5796
+ err.code = 'INVALID_DOTENV_KEY';
5797
+ throw err
5760
5798
  }
5761
5799
 
5762
5800
  // Get environment
5763
5801
  const environment = uri.searchParams.get('environment');
5764
5802
  if (!environment) {
5765
- throw new Error('INVALID_DOTENV_KEY: Missing environment part')
5803
+ const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
5804
+ err.code = 'INVALID_DOTENV_KEY';
5805
+ throw err
5766
5806
  }
5767
5807
 
5768
5808
  // Get ciphertext payload
5769
5809
  const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
5770
5810
  const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
5771
5811
  if (!ciphertext) {
5772
- throw new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)
5812
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
5813
+ err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
5814
+ throw err
5773
5815
  }
5774
5816
 
5775
5817
  return { ciphertext, key }
5776
5818
  }
5777
5819
 
5778
5820
  function _vaultPath (options) {
5779
- let dotenvPath = path.resolve(process.cwd(), '.env');
5821
+ let possibleVaultPath = null;
5780
5822
 
5781
5823
  if (options && options.path && options.path.length > 0) {
5782
- dotenvPath = options.path;
5824
+ if (Array.isArray(options.path)) {
5825
+ for (const filepath of options.path) {
5826
+ if (fs.existsSync(filepath)) {
5827
+ possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
5828
+ }
5829
+ }
5830
+ } else {
5831
+ possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
5832
+ }
5833
+ } else {
5834
+ possibleVaultPath = path.resolve(process.cwd(), '.env.vault');
5783
5835
  }
5784
5836
 
5785
- // Locate .env.vault
5786
- return dotenvPath.endsWith('.vault') ? dotenvPath : `${dotenvPath}.vault`
5837
+ if (fs.existsSync(possibleVaultPath)) {
5838
+ return possibleVaultPath
5839
+ }
5840
+
5841
+ return null
5787
5842
  }
5788
5843
 
5789
5844
  function _resolveHome (envPath) {
@@ -5812,7 +5867,18 @@ function configDotenv (options) {
5812
5867
 
5813
5868
  if (options) {
5814
5869
  if (options.path != null) {
5815
- dotenvPath = _resolveHome(options.path);
5870
+ let envPath = options.path;
5871
+
5872
+ if (Array.isArray(envPath)) {
5873
+ for (const filepath of options.path) {
5874
+ if (fs.existsSync(filepath)) {
5875
+ envPath = filepath;
5876
+ break
5877
+ }
5878
+ }
5879
+ }
5880
+
5881
+ dotenvPath = _resolveHome(envPath);
5816
5882
  }
5817
5883
  if (options.encoding != null) {
5818
5884
  encoding = options.encoding;
@@ -5846,15 +5912,15 @@ function configDotenv (options) {
5846
5912
 
5847
5913
  // Populates process.env from .env file
5848
5914
  function config (options) {
5849
- const vaultPath = _vaultPath(options);
5850
-
5851
5915
  // fallback to original dotenv if DOTENV_KEY is not set
5852
5916
  if (_dotenvKey(options).length === 0) {
5853
5917
  return DotenvModule.configDotenv(options)
5854
5918
  }
5855
5919
 
5920
+ const vaultPath = _vaultPath(options);
5921
+
5856
5922
  // dotenvKey exists but .env.vault file does not exist
5857
- if (!fs.existsSync(vaultPath)) {
5923
+ if (!vaultPath) {
5858
5924
  _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
5859
5925
 
5860
5926
  return DotenvModule.configDotenv(options)
@@ -5881,14 +5947,14 @@ function decrypt (encrypted, keyStr) {
5881
5947
  const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
5882
5948
 
5883
5949
  if (isRange || invalidKeyLength) {
5884
- const msg = 'INVALID_DOTENV_KEY: It must be 64 characters long (or more)';
5885
- throw new Error(msg)
5950
+ const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
5951
+ err.code = 'INVALID_DOTENV_KEY';
5952
+ throw err
5886
5953
  } else if (decryptionFailed) {
5887
- const msg = 'DECRYPTION_FAILED: Please check your DOTENV_KEY';
5888
- throw new Error(msg)
5954
+ const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
5955
+ err.code = 'DECRYPTION_FAILED';
5956
+ throw err
5889
5957
  } else {
5890
- console.error('Error: ', error.code);
5891
- console.error('Error: ', error.message);
5892
5958
  throw error
5893
5959
  }
5894
5960
  }
@@ -5900,7 +5966,9 @@ function populate (processEnv, parsed, options = {}) {
5900
5966
  const override = Boolean(options && options.override);
5901
5967
 
5902
5968
  if (typeof parsed !== 'object') {
5903
- throw new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')
5969
+ const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
5970
+ err.code = 'OBJECT_REQUIRED';
5971
+ throw err
5904
5972
  }
5905
5973
 
5906
5974
  // Set process.env
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.1.0-beta.7",
3
+ "version": "5.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -73,7 +73,7 @@
73
73
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
74
74
  "dependencies": {
75
75
  "esbuild": "^0.19.3",
76
- "postcss": "^8.4.33",
76
+ "postcss": "^8.4.35",
77
77
  "rollup": "^4.2.0"
78
78
  },
79
79
  "optionalDependencies": {
@@ -81,7 +81,7 @@
81
81
  },
82
82
  "devDependencies": {
83
83
  "@ampproject/remapping": "^2.2.1",
84
- "@babel/parser": "^7.23.6",
84
+ "@babel/parser": "^7.23.9",
85
85
  "@jridgewell/trace-mapping": "^0.3.22",
86
86
  "@rollup/plugin-alias": "^5.1.0",
87
87
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -96,14 +96,14 @@
96
96
  "acorn-walk": "^8.3.2",
97
97
  "artichokie": "^0.2.0",
98
98
  "cac": "^6.7.14",
99
- "chokidar": "^3.5.3",
99
+ "chokidar": "^3.6.0",
100
100
  "connect": "^3.7.0",
101
101
  "convert-source-map": "^2.0.0",
102
102
  "cors": "^2.8.5",
103
103
  "cross-spawn": "^7.0.3",
104
104
  "debug": "^4.3.4",
105
105
  "dep-types": "link:./src/types",
106
- "dotenv": "^16.3.2",
106
+ "dotenv": "^16.4.1",
107
107
  "dotenv-expand": "^10.0.0",
108
108
  "es-module-lexer": "^1.4.1",
109
109
  "escape-html": "^1.0.3",
@@ -113,7 +113,7 @@
113
113
  "http-proxy": "^1.18.1",
114
114
  "launch-editor-middleware": "^2.6.1",
115
115
  "lightningcss": "^1.23.0",
116
- "magic-string": "^0.30.5",
116
+ "magic-string": "^0.30.7",
117
117
  "micromatch": "^4.0.5",
118
118
  "mlly": "^1.5.0",
119
119
  "mrmime": "^2.0.0",
@@ -132,10 +132,10 @@
132
132
  "source-map-support": "^0.5.21",
133
133
  "strip-ansi": "^7.1.0",
134
134
  "strip-literal": "^2.0.0",
135
- "tsconfck": "^3.0.1",
135
+ "tsconfck": "^3.0.2",
136
136
  "tslib": "^2.6.2",
137
137
  "types": "link:./types",
138
- "ufo": "^1.3.2",
138
+ "ufo": "^1.4.0",
139
139
  "ws": "^8.16.0"
140
140
  },
141
141
  "peerDependencies": {