vite 5.1.0-beta.7 → 5.1.1

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/LICENSE.md CHANGED
@@ -1912,7 +1912,7 @@ Repository: lydell/js-tokens
1912
1912
 
1913
1913
  > The MIT License (MIT)
1914
1914
  >
1915
- > Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
1915
+ > Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Simon Lydell
1916
1916
  >
1917
1917
  > Permission is hereby granted, free of charge, to any person obtaining a copy
1918
1918
  > of this software and associated documentation files (the "Software"), to deal
@@ -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
@@ -15952,6 +15995,7 @@ function svgToDataURL(content) {
15952
15995
  }
15953
15996
  }
15954
15997
 
15998
+ const endsWithJSRE = /\.[cm]?js$/;
15955
15999
  function manifestPlugin(config) {
15956
16000
  const manifest = {};
15957
16001
  let outputCount;
@@ -16042,7 +16086,8 @@ function manifestPlugin(config) {
16042
16086
  const asset = createAsset(chunk, src, assetMeta?.isEntry);
16043
16087
  // If JS chunk and asset chunk are both generated from the same source file,
16044
16088
  // prioritize JS chunk as it contains more information
16045
- if (manifest[src]?.file.endsWith('.js'))
16089
+ const file = manifest[src]?.file;
16090
+ if (file && endsWithJSRE.test(file))
16046
16091
  continue;
16047
16092
  manifest[src] = asset;
16048
16093
  fileNameToAsset.set(chunk.fileName, asset);
@@ -29094,19 +29139,19 @@ var postcssrc = /*@__PURE__*/getDefaultExportFromCjs(src$1);
29094
29139
  // Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
29095
29140
  // License: MIT.
29096
29141
  var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
29097
- RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\\]).|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
29142
+ RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:[^\]\\\n\r\u2028\u2029]+|\\.)*\]|[^\/\\\n\r\u2028\u2029]+|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
29098
29143
  Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
29099
- Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
29100
- StringLiteral = /(['"])(?:(?!\1)[^\\\n\r]|\\(?:\r\n|[^]))*(\1)?/y;
29144
+ Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]+|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
29145
+ StringLiteral = /(['"])(?:[^'"\\\n\r]+|(?!\1)['"]|\\(?:\r\n|[^]))*(\1)?/y;
29101
29146
  NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
29102
- Template = /[`}](?:[^`\\$]|\\[^]|\$(?!\{))*(`|\$\{)?/y;
29147
+ Template = /[`}](?:[^`\\$]+|\\[^]|\$(?!\{))*(`|\$\{)?/y;
29103
29148
  WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/yu;
29104
29149
  LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
29105
- MultiLineComment = /\/\*(?:[^*]|\*(?!\/))*(\*\/)?/y;
29150
+ MultiLineComment = /\/\*(?:[^*]+|\*(?!\/))*(\*\/)?/y;
29106
29151
  SingleLineComment = /\/\/.*/y;
29107
29152
  JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
29108
29153
  JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/yu;
29109
- JSXString = /(['"])(?:(?!\1)[^])*(\1)?/y;
29154
+ JSXString = /(['"])(?:[^'"]+|(?!\1)['"])*(\1)?/y;
29110
29155
  JSXText = /[^<>{}]+/y;
29111
29156
  TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
29112
29157
  TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
@@ -29558,7 +29603,7 @@ function stripLiteralDetailed(code, options) {
29558
29603
  var main$1 = {exports: {}};
29559
29604
 
29560
29605
  var name = "dotenv";
29561
- var version$2 = "16.3.2";
29606
+ var version$2 = "16.4.1";
29562
29607
  var description = "Loads environment variables from .env file";
29563
29608
  var main = "lib/main.js";
29564
29609
  var types$2 = "lib/main.d.ts";
@@ -29692,7 +29737,9 @@ function _parseVault (options) {
29692
29737
  // Parse .env.vault
29693
29738
  const result = DotenvModule.configDotenv({ path: vaultPath });
29694
29739
  if (!result.parsed) {
29695
- throw new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)
29740
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
29741
+ err.code = 'MISSING_DATA';
29742
+ throw err
29696
29743
  }
29697
29744
 
29698
29745
  // handle scenario for comma separated keys - for use with key rotation
@@ -29760,7 +29807,9 @@ function _instructions (result, dotenvKey) {
29760
29807
  uri = new URL(dotenvKey);
29761
29808
  } catch (error) {
29762
29809
  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')
29810
+ 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');
29811
+ err.code = 'INVALID_DOTENV_KEY';
29812
+ throw err
29764
29813
  }
29765
29814
 
29766
29815
  throw error
@@ -29769,34 +29818,53 @@ function _instructions (result, dotenvKey) {
29769
29818
  // Get decrypt key
29770
29819
  const key = uri.password;
29771
29820
  if (!key) {
29772
- throw new Error('INVALID_DOTENV_KEY: Missing key part')
29821
+ const err = new Error('INVALID_DOTENV_KEY: Missing key part');
29822
+ err.code = 'INVALID_DOTENV_KEY';
29823
+ throw err
29773
29824
  }
29774
29825
 
29775
29826
  // Get environment
29776
29827
  const environment = uri.searchParams.get('environment');
29777
29828
  if (!environment) {
29778
- throw new Error('INVALID_DOTENV_KEY: Missing environment part')
29829
+ const err = new Error('INVALID_DOTENV_KEY: Missing environment part');
29830
+ err.code = 'INVALID_DOTENV_KEY';
29831
+ throw err
29779
29832
  }
29780
29833
 
29781
29834
  // Get ciphertext payload
29782
29835
  const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
29783
29836
  const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION
29784
29837
  if (!ciphertext) {
29785
- throw new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)
29838
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
29839
+ err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT';
29840
+ throw err
29786
29841
  }
29787
29842
 
29788
29843
  return { ciphertext, key }
29789
29844
  }
29790
29845
 
29791
29846
  function _vaultPath (options) {
29792
- let dotenvPath = path$9.resolve(process.cwd(), '.env');
29847
+ let possibleVaultPath = null;
29793
29848
 
29794
29849
  if (options && options.path && options.path.length > 0) {
29795
- dotenvPath = options.path;
29850
+ if (Array.isArray(options.path)) {
29851
+ for (const filepath of options.path) {
29852
+ if (fs$9.existsSync(filepath)) {
29853
+ possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`;
29854
+ }
29855
+ }
29856
+ } else {
29857
+ possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`;
29858
+ }
29859
+ } else {
29860
+ possibleVaultPath = path$9.resolve(process.cwd(), '.env.vault');
29796
29861
  }
29797
29862
 
29798
- // Locate .env.vault
29799
- return dotenvPath.endsWith('.vault') ? dotenvPath : `${dotenvPath}.vault`
29863
+ if (fs$9.existsSync(possibleVaultPath)) {
29864
+ return possibleVaultPath
29865
+ }
29866
+
29867
+ return null
29800
29868
  }
29801
29869
 
29802
29870
  function _resolveHome (envPath) {
@@ -29825,7 +29893,18 @@ function configDotenv (options) {
29825
29893
 
29826
29894
  if (options) {
29827
29895
  if (options.path != null) {
29828
- dotenvPath = _resolveHome(options.path);
29896
+ let envPath = options.path;
29897
+
29898
+ if (Array.isArray(envPath)) {
29899
+ for (const filepath of options.path) {
29900
+ if (fs$9.existsSync(filepath)) {
29901
+ envPath = filepath;
29902
+ break
29903
+ }
29904
+ }
29905
+ }
29906
+
29907
+ dotenvPath = _resolveHome(envPath);
29829
29908
  }
29830
29909
  if (options.encoding != null) {
29831
29910
  encoding = options.encoding;
@@ -29859,15 +29938,15 @@ function configDotenv (options) {
29859
29938
 
29860
29939
  // Populates process.env from .env file
29861
29940
  function config (options) {
29862
- const vaultPath = _vaultPath(options);
29863
-
29864
29941
  // fallback to original dotenv if DOTENV_KEY is not set
29865
29942
  if (_dotenvKey(options).length === 0) {
29866
29943
  return DotenvModule.configDotenv(options)
29867
29944
  }
29868
29945
 
29946
+ const vaultPath = _vaultPath(options);
29947
+
29869
29948
  // dotenvKey exists but .env.vault file does not exist
29870
- if (!fs$9.existsSync(vaultPath)) {
29949
+ if (!vaultPath) {
29871
29950
  _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
29872
29951
 
29873
29952
  return DotenvModule.configDotenv(options)
@@ -29894,14 +29973,14 @@ function decrypt (encrypted, keyStr) {
29894
29973
  const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data';
29895
29974
 
29896
29975
  if (isRange || invalidKeyLength) {
29897
- const msg = 'INVALID_DOTENV_KEY: It must be 64 characters long (or more)';
29898
- throw new Error(msg)
29976
+ const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)');
29977
+ err.code = 'INVALID_DOTENV_KEY';
29978
+ throw err
29899
29979
  } else if (decryptionFailed) {
29900
- const msg = 'DECRYPTION_FAILED: Please check your DOTENV_KEY';
29901
- throw new Error(msg)
29980
+ const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY');
29981
+ err.code = 'DECRYPTION_FAILED';
29982
+ throw err
29902
29983
  } else {
29903
- console.error('Error: ', error.code);
29904
- console.error('Error: ', error.message);
29905
29984
  throw error
29906
29985
  }
29907
29986
  }
@@ -29913,7 +29992,9 @@ function populate (processEnv, parsed, options = {}) {
29913
29992
  const override = Boolean(options && options.override);
29914
29993
 
29915
29994
  if (typeof parsed !== 'object') {
29916
- throw new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')
29995
+ const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate');
29996
+ err.code = 'OBJECT_REQUIRED';
29997
+ throw err
29917
29998
  }
29918
29999
 
29919
30000
  // Set process.env
@@ -31472,75 +31553,74 @@ function cssPostPlugin(config) {
31472
31553
  s.update(start, end, replacementString);
31473
31554
  }
31474
31555
  }
31475
- if (!chunkCSS && !s) {
31476
- return null;
31477
- }
31478
- if (config.build.cssCodeSplit) {
31479
- if (opts.format === 'es' || opts.format === 'cjs') {
31480
- if (isPureCssChunk) {
31481
- // this is a shared CSS-only chunk that is empty.
31482
- pureCssChunks.add(chunk);
31483
- }
31484
- const isEntry = chunk.isEntry && isPureCssChunk;
31485
- const cssFullAssetName = ensureFileExt(chunk.name, '.css');
31486
- // if facadeModuleId doesn't exist or doesn't have a CSS extension,
31487
- // that means a JS entry file imports a CSS file.
31488
- // in this case, only use the filename for the CSS chunk name like JS chunks.
31489
- const cssAssetName = chunk.isEntry &&
31490
- (!chunk.facadeModuleId || !isCSSRequest(chunk.facadeModuleId))
31491
- ? path$o.basename(cssFullAssetName)
31492
- : cssFullAssetName;
31493
- const originalFilename = getChunkOriginalFileName(chunk, config.root, opts.format);
31494
- chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName);
31495
- // wait for previous tasks as well
31496
- chunkCSS = await codeSplitEmitQueue.run(async () => {
31497
- return finalizeCss(chunkCSS, true, config);
31498
- });
31499
- // emit corresponding css file
31500
- const referenceId = this.emitFile({
31501
- name: cssAssetName,
31502
- type: 'asset',
31503
- source: chunkCSS,
31504
- });
31505
- generatedAssets
31506
- .get(config)
31507
- .set(referenceId, { originalName: originalFilename, isEntry });
31508
- chunk.viteMetadata.importedCss.add(this.getFileName(referenceId));
31509
- }
31510
- else if (!config.build.ssr) {
31511
- // legacy build and inline css
31512
- // Entry chunk CSS will be collected into `chunk.viteMetadata.importedCss`
31513
- // and injected later by the `'vite:build-html'` plugin into the `index.html`
31514
- // so it will be duplicated. (https://github.com/vitejs/vite/issues/2062#issuecomment-782388010)
31515
- // But because entry chunk can be imported by dynamic import,
31516
- // we shouldn't remove the inlined CSS. (#10285)
31517
- chunkCSS = await finalizeCss(chunkCSS, true, config);
31518
- let cssString = JSON.stringify(chunkCSS);
31519
- cssString =
31520
- renderAssetUrlInJS(this, config, chunk, opts, cssString)?.toString() || cssString;
31521
- const style = `__vite_style__`;
31522
- const injectCode = `var ${style} = document.createElement('style');` +
31523
- `${style}.textContent = ${cssString};` +
31524
- `document.head.appendChild(${style});`;
31525
- let injectionPoint;
31526
- const wrapIdx = code.indexOf('System.register');
31527
- if (wrapIdx >= 0) {
31528
- const executeFnStart = code.indexOf('execute:', wrapIdx);
31529
- injectionPoint = code.indexOf('{', executeFnStart) + 1;
31556
+ if (chunkCSS) {
31557
+ if (config.build.cssCodeSplit) {
31558
+ if (opts.format === 'es' || opts.format === 'cjs') {
31559
+ if (isPureCssChunk) {
31560
+ // this is a shared CSS-only chunk that is empty.
31561
+ pureCssChunks.add(chunk);
31562
+ }
31563
+ const isEntry = chunk.isEntry && isPureCssChunk;
31564
+ const cssFullAssetName = ensureFileExt(chunk.name, '.css');
31565
+ // if facadeModuleId doesn't exist or doesn't have a CSS extension,
31566
+ // that means a JS entry file imports a CSS file.
31567
+ // in this case, only use the filename for the CSS chunk name like JS chunks.
31568
+ const cssAssetName = chunk.isEntry &&
31569
+ (!chunk.facadeModuleId || !isCSSRequest(chunk.facadeModuleId))
31570
+ ? path$o.basename(cssFullAssetName)
31571
+ : cssFullAssetName;
31572
+ const originalFilename = getChunkOriginalFileName(chunk, config.root, opts.format);
31573
+ chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName);
31574
+ // wait for previous tasks as well
31575
+ chunkCSS = await codeSplitEmitQueue.run(async () => {
31576
+ return finalizeCss(chunkCSS, true, config);
31577
+ });
31578
+ // emit corresponding css file
31579
+ const referenceId = this.emitFile({
31580
+ name: cssAssetName,
31581
+ type: 'asset',
31582
+ source: chunkCSS,
31583
+ });
31584
+ generatedAssets
31585
+ .get(config)
31586
+ .set(referenceId, { originalName: originalFilename, isEntry });
31587
+ chunk.viteMetadata.importedCss.add(this.getFileName(referenceId));
31530
31588
  }
31531
- else {
31532
- const insertMark = "'use strict';";
31533
- injectionPoint = code.indexOf(insertMark) + insertMark.length;
31589
+ else if (!config.build.ssr) {
31590
+ // legacy build and inline css
31591
+ // Entry chunk CSS will be collected into `chunk.viteMetadata.importedCss`
31592
+ // and injected later by the `'vite:build-html'` plugin into the `index.html`
31593
+ // so it will be duplicated. (https://github.com/vitejs/vite/issues/2062#issuecomment-782388010)
31594
+ // But because entry chunk can be imported by dynamic import,
31595
+ // we shouldn't remove the inlined CSS. (#10285)
31596
+ chunkCSS = await finalizeCss(chunkCSS, true, config);
31597
+ let cssString = JSON.stringify(chunkCSS);
31598
+ cssString =
31599
+ renderAssetUrlInJS(this, config, chunk, opts, cssString)?.toString() || cssString;
31600
+ const style = `__vite_style__`;
31601
+ const injectCode = `var ${style} = document.createElement('style');` +
31602
+ `${style}.textContent = ${cssString};` +
31603
+ `document.head.appendChild(${style});`;
31604
+ let injectionPoint;
31605
+ const wrapIdx = code.indexOf('System.register');
31606
+ if (wrapIdx >= 0) {
31607
+ const executeFnStart = code.indexOf('execute:', wrapIdx);
31608
+ injectionPoint = code.indexOf('{', executeFnStart) + 1;
31609
+ }
31610
+ else {
31611
+ const insertMark = "'use strict';";
31612
+ injectionPoint = code.indexOf(insertMark) + insertMark.length;
31613
+ }
31614
+ s ||= new MagicString(code);
31615
+ s.appendRight(injectionPoint, injectCode);
31534
31616
  }
31535
- s ||= new MagicString(code);
31536
- s.appendRight(injectionPoint, injectCode);
31537
31617
  }
31538
- }
31539
- else {
31540
- // resolve public URL from CSS paths, we need to use absolute paths
31541
- chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssBundleName);
31542
- // finalizeCss is called for the aggregated chunk in generateBundle
31543
- chunkCSSMap.set(chunk.fileName, chunkCSS);
31618
+ else {
31619
+ // resolve public URL from CSS paths, we need to use absolute paths
31620
+ chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssBundleName);
31621
+ // finalizeCss is called for the aggregated chunk in generateBundle
31622
+ chunkCSSMap.set(chunk.fileName, chunkCSS);
31623
+ }
31544
31624
  }
31545
31625
  if (s) {
31546
31626
  if (config.build.sourcemap) {
@@ -32002,8 +32082,8 @@ function createCachedImport(imp) {
32002
32082
  return cached;
32003
32083
  };
32004
32084
  }
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; }));
32085
+ const importPostcssImport = createCachedImport(() => import('./dep-xESY8DUV.js').then(function (n) { return n.i; }));
32086
+ const importPostcssModules = createCachedImport(() => import('./dep-XbJJvsnO.js').then(function (n) { return n.i; }));
32007
32087
  const importPostcss = createCachedImport(() => import('postcss'));
32008
32088
  const preprocessorWorkerControllerCache = new WeakMap();
32009
32089
  let alwaysFakeWorkerWorkerControllerCache;
@@ -38984,6 +39064,7 @@ function tokenizer(input, options) {
38984
39064
 
38985
39065
  const HASH_RE = /#/g;
38986
39066
  const AMPERSAND_RE = /&/g;
39067
+ const SLASH_RE = /\//g;
38987
39068
  const EQUAL_RE = /=/g;
38988
39069
  const PLUS_RE = /\+/g;
38989
39070
  const ENC_CARET_RE = /%5e/gi;
@@ -38994,7 +39075,7 @@ function encode(text) {
38994
39075
  return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
38995
39076
  }
38996
39077
  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, "^");
39078
+ 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
39079
  }
38999
39080
  function encodeQueryKey(text) {
39000
39081
  return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
@@ -43831,6 +43912,7 @@ var constants$1 = {};
43831
43912
  exports.FSEVENT_MOVED = 'moved';
43832
43913
  exports.FSEVENT_CLONED = 'cloned';
43833
43914
  exports.FSEVENT_UNKNOWN = 'unknown';
43915
+ exports.FSEVENT_FLAG_MUST_SCAN_SUBDIRS = 1;
43834
43916
  exports.FSEVENT_TYPE_FILE = 'file';
43835
43917
  exports.FSEVENT_TYPE_DIRECTORY = 'directory';
43836
43918
  exports.FSEVENT_TYPE_SYMLINK = 'symlink';
@@ -44554,6 +44636,7 @@ const {
44554
44636
  FSEVENT_MOVED,
44555
44637
  // FSEVENT_CLONED,
44556
44638
  FSEVENT_UNKNOWN,
44639
+ FSEVENT_FLAG_MUST_SCAN_SUBDIRS,
44557
44640
  FSEVENT_TYPE_FILE,
44558
44641
  FSEVENT_TYPE_DIRECTORY,
44559
44642
  FSEVENT_TYPE_SYMLINK,
@@ -44665,6 +44748,7 @@ function setFSEventsListener(path, realPath, listener, rawEmitter) {
44665
44748
  rawEmitter,
44666
44749
  watcher: createFSEventsInstance(watchPath, (fullPath, flags) => {
44667
44750
  if (!cont.listeners.size) return;
44751
+ if (flags & FSEVENT_FLAG_MUST_SCAN_SUBDIRS) return;
44668
44752
  const info = fsevents.getInfo(fullPath, flags);
44669
44753
  cont.listeners.forEach(list => {
44670
44754
  list(fullPath, flags, info);
@@ -45484,7 +45568,7 @@ add(paths_, _origAdd, _internal) {
45484
45568
 
45485
45569
  if (this.options.useFsEvents && this._fsEventsHandler) {
45486
45570
  if (!this._readyCount) this._readyCount = paths.length;
45487
- if (this.options.persistent) this._readyCount *= 2;
45571
+ if (this.options.persistent) this._readyCount += paths.length;
45488
45572
  paths.forEach((path) => this._fsEventsHandler._addToFsEvents(path));
45489
45573
  } else {
45490
45574
  if (!this._readyCount) this._readyCount = 0;
@@ -50937,16 +51021,15 @@ function orderedDependencies(deps) {
50937
51021
  return Object.fromEntries(depsList);
50938
51022
  }
50939
51023
  function globEntries(pattern, config) {
50940
- const rootPattern = glob.convertPathToPattern(config.root);
50941
51024
  return glob(pattern, {
50942
51025
  cwd: config.root,
50943
51026
  ignore: [
50944
- `${rootPattern}/**/node_modules/**`,
50945
- `${rootPattern}/**/${config.build.outDir}/**`,
51027
+ '**/node_modules/**',
51028
+ `**/${config.build.outDir}/**`,
50946
51029
  // if there aren't explicit entries, also ignore other common folders
50947
51030
  ...(config.optimizeDeps.entries
50948
51031
  ? []
50949
- : [`${rootPattern}/**/__tests__/**`, `${rootPattern}/**/coverage/**`]),
51032
+ : [`**/__tests__/**`, `**/coverage/**`]),
50950
51033
  ],
50951
51034
  absolute: true,
50952
51035
  suppressErrors: true, // suppress EACCES errors
@@ -67493,7 +67576,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
67493
67576
  };
67494
67577
  let { configFile } = config;
67495
67578
  if (configFile !== false) {
67496
- const loadResult = await loadConfigFromFile(configEnv, configFile, config.root, config.logLevel);
67579
+ const loadResult = await loadConfigFromFile(configEnv, configFile, config.root, config.logLevel, config.customLogger);
67497
67580
  if (loadResult) {
67498
67581
  config = mergeConfig(loadResult.config, config);
67499
67582
  configFile = loadResult.path;
@@ -67855,7 +67938,7 @@ function sortUserPlugins(plugins) {
67855
67938
  }
67856
67939
  return [prePlugins, normalPlugins, postPlugins];
67857
67940
  }
67858
- async function loadConfigFromFile(configEnv, configFile, configRoot = process.cwd(), logLevel) {
67941
+ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cwd(), logLevel, customLogger) {
67859
67942
  const start = performance.now();
67860
67943
  const getTime = () => `${(performance.now() - start).toFixed(2)}ms`;
67861
67944
  let resolvedPath;
@@ -67896,7 +67979,9 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
67896
67979
  };
67897
67980
  }
67898
67981
  catch (e) {
67899
- createLogger(logLevel).error(colors$1.red(`failed to load config from ${resolvedPath}`), { error: e });
67982
+ createLogger(logLevel, { customLogger }).error(colors$1.red(`failed to load config from ${resolvedPath}`), {
67983
+ error: e,
67984
+ });
67900
67985
  throw e;
67901
67986
  }
67902
67987
  }
@@ -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-94_H5fT6.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-94_H5fT6.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';
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-94_H5fT6.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-94_H5fT6.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-94_H5fT6.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-94_H5fT6.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-94_H5fT6.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-94_H5fT6.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-94_H5fT6.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.1",
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": {