vite 4.4.6 → 4.4.8

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -6080,7 +6080,7 @@ var globExports = requireGlob();
6080
6080
  var glob$1 = /*@__PURE__*/getDefaultExportFromCjs(globExports);
6081
6081
 
6082
6082
  const comma$1 = ','.charCodeAt(0);
6083
- const semicolon$1 = ';'.charCodeAt(0);
6083
+ const semicolon = ';'.charCodeAt(0);
6084
6084
  const chars$2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
6085
6085
  const intToChar$1 = new Uint8Array(64); // 64 possible chars.
6086
6086
  const charToInt$1 = new Uint8Array(128); // z is 122 in ASCII
@@ -6090,7 +6090,7 @@ for (let i = 0; i < chars$2.length; i++) {
6090
6090
  charToInt$1[c] = i;
6091
6091
  }
6092
6092
  // Provide a fallback for older environments.
6093
- const td$1 = typeof TextDecoder !== 'undefined'
6093
+ const td = typeof TextDecoder !== 'undefined'
6094
6094
  ? /* #__PURE__ */ new TextDecoder()
6095
6095
  : typeof Buffer !== 'undefined'
6096
6096
  ? {
@@ -6108,81 +6108,7 @@ const td$1 = typeof TextDecoder !== 'undefined'
6108
6108
  return out;
6109
6109
  },
6110
6110
  };
6111
- function decode(mappings) {
6112
- const state = new Int32Array(5);
6113
- const decoded = [];
6114
- let index = 0;
6115
- do {
6116
- const semi = indexOf(mappings, index);
6117
- const line = [];
6118
- let sorted = true;
6119
- let lastCol = 0;
6120
- state[0] = 0;
6121
- for (let i = index; i < semi; i++) {
6122
- let seg;
6123
- i = decodeInteger(mappings, i, state, 0); // genColumn
6124
- const col = state[0];
6125
- if (col < lastCol)
6126
- sorted = false;
6127
- lastCol = col;
6128
- if (hasMoreVlq(mappings, i, semi)) {
6129
- i = decodeInteger(mappings, i, state, 1); // sourcesIndex
6130
- i = decodeInteger(mappings, i, state, 2); // sourceLine
6131
- i = decodeInteger(mappings, i, state, 3); // sourceColumn
6132
- if (hasMoreVlq(mappings, i, semi)) {
6133
- i = decodeInteger(mappings, i, state, 4); // namesIndex
6134
- seg = [col, state[1], state[2], state[3], state[4]];
6135
- }
6136
- else {
6137
- seg = [col, state[1], state[2], state[3]];
6138
- }
6139
- }
6140
- else {
6141
- seg = [col];
6142
- }
6143
- line.push(seg);
6144
- }
6145
- if (!sorted)
6146
- sort(line);
6147
- decoded.push(line);
6148
- index = semi + 1;
6149
- } while (index <= mappings.length);
6150
- return decoded;
6151
- }
6152
- function indexOf(mappings, index) {
6153
- const idx = mappings.indexOf(';', index);
6154
- return idx === -1 ? mappings.length : idx;
6155
- }
6156
- function decodeInteger(mappings, pos, state, j) {
6157
- let value = 0;
6158
- let shift = 0;
6159
- let integer = 0;
6160
- do {
6161
- const c = mappings.charCodeAt(pos++);
6162
- integer = charToInt$1[c];
6163
- value |= (integer & 31) << shift;
6164
- shift += 5;
6165
- } while (integer & 32);
6166
- const shouldNegate = value & 1;
6167
- value >>>= 1;
6168
- if (shouldNegate) {
6169
- value = -0x80000000 | -value;
6170
- }
6171
- state[j] += value;
6172
- return pos;
6173
- }
6174
- function hasMoreVlq(mappings, i, length) {
6175
- if (i >= length)
6176
- return false;
6177
- return mappings.charCodeAt(i) !== comma$1;
6178
- }
6179
- function sort(line) {
6180
- line.sort(sortComparator$1);
6181
- }
6182
- function sortComparator$1(a, b) {
6183
- return a[0] - b[0];
6184
- }
6185
- function encode$2(decoded) {
6111
+ function encode$1(decoded) {
6186
6112
  const state = new Int32Array(5);
6187
6113
  const bufLength = 1024 * 16;
6188
6114
  const subLength = bufLength - 36;
@@ -6194,10 +6120,10 @@ function encode$2(decoded) {
6194
6120
  const line = decoded[i];
6195
6121
  if (i > 0) {
6196
6122
  if (pos === bufLength) {
6197
- out += td$1.decode(buf);
6123
+ out += td.decode(buf);
6198
6124
  pos = 0;
6199
6125
  }
6200
- buf[pos++] = semicolon$1;
6126
+ buf[pos++] = semicolon;
6201
6127
  }
6202
6128
  if (line.length === 0)
6203
6129
  continue;
@@ -6207,26 +6133,26 @@ function encode$2(decoded) {
6207
6133
  // We can push up to 5 ints, each int can take at most 7 chars, and we
6208
6134
  // may push a comma.
6209
6135
  if (pos > subLength) {
6210
- out += td$1.decode(sub);
6136
+ out += td.decode(sub);
6211
6137
  buf.copyWithin(0, subLength, pos);
6212
6138
  pos -= subLength;
6213
6139
  }
6214
6140
  if (j > 0)
6215
6141
  buf[pos++] = comma$1;
6216
- pos = encodeInteger$1(buf, pos, state, segment, 0); // genColumn
6142
+ pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
6217
6143
  if (segment.length === 1)
6218
6144
  continue;
6219
- pos = encodeInteger$1(buf, pos, state, segment, 1); // sourcesIndex
6220
- pos = encodeInteger$1(buf, pos, state, segment, 2); // sourceLine
6221
- pos = encodeInteger$1(buf, pos, state, segment, 3); // sourceColumn
6145
+ pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
6146
+ pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
6147
+ pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
6222
6148
  if (segment.length === 4)
6223
6149
  continue;
6224
- pos = encodeInteger$1(buf, pos, state, segment, 4); // namesIndex
6150
+ pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
6225
6151
  }
6226
6152
  }
6227
- return out + td$1.decode(buf.subarray(0, pos));
6153
+ return out + td.decode(buf.subarray(0, pos));
6228
6154
  }
6229
- function encodeInteger$1(buf, pos, state, segment, j) {
6155
+ function encodeInteger(buf, pos, state, segment, j) {
6230
6156
  const next = segment[j];
6231
6157
  let num = next - state[j];
6232
6158
  state[j] = next;
@@ -6430,7 +6356,7 @@ let SourceMap$2 = class SourceMap {
6430
6356
  this.sources = properties.sources;
6431
6357
  this.sourcesContent = properties.sourcesContent;
6432
6358
  this.names = properties.names;
6433
- this.mappings = encode$2(properties.mappings);
6359
+ this.mappings = encode$1(properties.mappings);
6434
6360
  }
6435
6361
 
6436
6362
  toString() {
@@ -9665,6 +9591,90 @@ function commonjs(options = {}) {
9665
9591
  };
9666
9592
  }
9667
9593
 
9594
+ const comma = ','.charCodeAt(0);
9595
+ const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
9596
+ const intToChar = new Uint8Array(64); // 64 possible chars.
9597
+ const charToInt = new Uint8Array(128); // z is 122 in ASCII
9598
+ for (let i = 0; i < chars$1.length; i++) {
9599
+ const c = chars$1.charCodeAt(i);
9600
+ intToChar[i] = c;
9601
+ charToInt[c] = i;
9602
+ }
9603
+ function decode(mappings) {
9604
+ const state = new Int32Array(5);
9605
+ const decoded = [];
9606
+ let index = 0;
9607
+ do {
9608
+ const semi = indexOf(mappings, index);
9609
+ const line = [];
9610
+ let sorted = true;
9611
+ let lastCol = 0;
9612
+ state[0] = 0;
9613
+ for (let i = index; i < semi; i++) {
9614
+ let seg;
9615
+ i = decodeInteger(mappings, i, state, 0); // genColumn
9616
+ const col = state[0];
9617
+ if (col < lastCol)
9618
+ sorted = false;
9619
+ lastCol = col;
9620
+ if (hasMoreVlq(mappings, i, semi)) {
9621
+ i = decodeInteger(mappings, i, state, 1); // sourcesIndex
9622
+ i = decodeInteger(mappings, i, state, 2); // sourceLine
9623
+ i = decodeInteger(mappings, i, state, 3); // sourceColumn
9624
+ if (hasMoreVlq(mappings, i, semi)) {
9625
+ i = decodeInteger(mappings, i, state, 4); // namesIndex
9626
+ seg = [col, state[1], state[2], state[3], state[4]];
9627
+ }
9628
+ else {
9629
+ seg = [col, state[1], state[2], state[3]];
9630
+ }
9631
+ }
9632
+ else {
9633
+ seg = [col];
9634
+ }
9635
+ line.push(seg);
9636
+ }
9637
+ if (!sorted)
9638
+ sort(line);
9639
+ decoded.push(line);
9640
+ index = semi + 1;
9641
+ } while (index <= mappings.length);
9642
+ return decoded;
9643
+ }
9644
+ function indexOf(mappings, index) {
9645
+ const idx = mappings.indexOf(';', index);
9646
+ return idx === -1 ? mappings.length : idx;
9647
+ }
9648
+ function decodeInteger(mappings, pos, state, j) {
9649
+ let value = 0;
9650
+ let shift = 0;
9651
+ let integer = 0;
9652
+ do {
9653
+ const c = mappings.charCodeAt(pos++);
9654
+ integer = charToInt[c];
9655
+ value |= (integer & 31) << shift;
9656
+ shift += 5;
9657
+ } while (integer & 32);
9658
+ const shouldNegate = value & 1;
9659
+ value >>>= 1;
9660
+ if (shouldNegate) {
9661
+ value = -0x80000000 | -value;
9662
+ }
9663
+ state[j] += value;
9664
+ return pos;
9665
+ }
9666
+ function hasMoreVlq(mappings, i, length) {
9667
+ if (i >= length)
9668
+ return false;
9669
+ return mappings.charCodeAt(i) !== comma;
9670
+ }
9671
+ function sort(line) {
9672
+ line.sort(sortComparator$1);
9673
+ }
9674
+ function sortComparator$1(a, b) {
9675
+ return a[0] - b[0];
9676
+ }
9677
+
9668
9678
  // Matches the scheme of a URL, eg "http://"
9669
9679
  const schemeRegex = /^[\w+.-]+:\/\//;
9670
9680
  /**
@@ -10183,94 +10193,6 @@ class SetArray {
10183
10193
  };
10184
10194
  })();
10185
10195
 
10186
- const comma = ','.charCodeAt(0);
10187
- const semicolon = ';'.charCodeAt(0);
10188
- const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
10189
- const intToChar = new Uint8Array(64); // 64 possible chars.
10190
- const charToInt = new Uint8Array(128); // z is 122 in ASCII
10191
- for (let i = 0; i < chars$1.length; i++) {
10192
- const c = chars$1.charCodeAt(i);
10193
- intToChar[i] = c;
10194
- charToInt[c] = i;
10195
- }
10196
- // Provide a fallback for older environments.
10197
- const td = typeof TextDecoder !== 'undefined'
10198
- ? /* #__PURE__ */ new TextDecoder()
10199
- : typeof Buffer !== 'undefined'
10200
- ? {
10201
- decode(buf) {
10202
- const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
10203
- return out.toString();
10204
- },
10205
- }
10206
- : {
10207
- decode(buf) {
10208
- let out = '';
10209
- for (let i = 0; i < buf.length; i++) {
10210
- out += String.fromCharCode(buf[i]);
10211
- }
10212
- return out;
10213
- },
10214
- };
10215
- function encode$1(decoded) {
10216
- const state = new Int32Array(5);
10217
- const bufLength = 1024 * 16;
10218
- const subLength = bufLength - 36;
10219
- const buf = new Uint8Array(bufLength);
10220
- const sub = buf.subarray(0, subLength);
10221
- let pos = 0;
10222
- let out = '';
10223
- for (let i = 0; i < decoded.length; i++) {
10224
- const line = decoded[i];
10225
- if (i > 0) {
10226
- if (pos === bufLength) {
10227
- out += td.decode(buf);
10228
- pos = 0;
10229
- }
10230
- buf[pos++] = semicolon;
10231
- }
10232
- if (line.length === 0)
10233
- continue;
10234
- state[0] = 0;
10235
- for (let j = 0; j < line.length; j++) {
10236
- const segment = line[j];
10237
- // We can push up to 5 ints, each int can take at most 7 chars, and we
10238
- // may push a comma.
10239
- if (pos > subLength) {
10240
- out += td.decode(sub);
10241
- buf.copyWithin(0, subLength, pos);
10242
- pos -= subLength;
10243
- }
10244
- if (j > 0)
10245
- buf[pos++] = comma;
10246
- pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
10247
- if (segment.length === 1)
10248
- continue;
10249
- pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
10250
- pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
10251
- pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
10252
- if (segment.length === 4)
10253
- continue;
10254
- pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
10255
- }
10256
- }
10257
- return out + td.decode(buf.subarray(0, pos));
10258
- }
10259
- function encodeInteger(buf, pos, state, segment, j) {
10260
- const next = segment[j];
10261
- let num = next - state[j];
10262
- state[j] = next;
10263
- num = num < 0 ? (-num << 1) | 1 : num << 1;
10264
- do {
10265
- let clamped = num & 0b011111;
10266
- num >>>= 5;
10267
- if (num > 0)
10268
- clamped |= 0b100000;
10269
- buf[pos++] = intToChar[clamped];
10270
- } while (num > 0);
10271
- return pos;
10272
- }
10273
-
10274
10196
  const COLUMN = 0;
10275
10197
  const SOURCES_INDEX = 1;
10276
10198
  const SOURCE_LINE = 2;
@@ -11629,7 +11551,6 @@ if (typeof process === 'undefined' || process.type === 'renderer' || process.bro
11629
11551
  var srcExports$1 = src$2.exports;
11630
11552
  var debug$g = /*@__PURE__*/getDefaultExportFromCjs(srcExports$1);
11631
11553
 
11632
- // eslint-disable-next-line @typescript-eslint/consistent-type-imports
11633
11554
  let pnp;
11634
11555
  if (process.versions.pnp) {
11635
11556
  try {
@@ -12737,7 +12658,7 @@ function transformStableResult(s, id, config) {
12737
12658
  return {
12738
12659
  code: s.toString(),
12739
12660
  map: config.command === 'build' && config.build.sourcemap
12740
- ? s.generateMap({ hires: true, source: id })
12661
+ ? s.generateMap({ hires: 'boundary', source: id })
12741
12662
  : null,
12742
12663
  };
12743
12664
  }
@@ -12842,6 +12763,23 @@ const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
12842
12763
  function escapeRegex(str) {
12843
12764
  return str.replace(escapeRegexRE, '\\$&');
12844
12765
  }
12766
+ function getPackageManagerCommand(type = 'install') {
12767
+ const packageManager = process.env.npm_config_user_agent?.split(' ')[0].split('/')[0] || 'npm';
12768
+ switch (type) {
12769
+ case 'install':
12770
+ return packageManager === 'npm' ? 'npm install' : `${packageManager} add`;
12771
+ case 'uninstall':
12772
+ return packageManager === 'npm'
12773
+ ? 'npm uninstall'
12774
+ : `${packageManager} remove`;
12775
+ case 'update':
12776
+ return packageManager === 'yarn'
12777
+ ? 'yarn upgrade'
12778
+ : `${packageManager} update`;
12779
+ default:
12780
+ throw new TypeError(`Unknown command type: ${type}`);
12781
+ }
12782
+ }
12845
12783
 
12846
12784
  /* eslint no-console: 0 */
12847
12785
  const LogLevels = {
@@ -12864,6 +12802,11 @@ function createLogger(level = 'info', options = {}) {
12864
12802
  if (options.customLogger) {
12865
12803
  return options.customLogger;
12866
12804
  }
12805
+ const timeFormatter = new Intl.DateTimeFormat(undefined, {
12806
+ hour: 'numeric',
12807
+ minute: 'numeric',
12808
+ second: 'numeric',
12809
+ });
12867
12810
  const loggedErrors = new WeakSet();
12868
12811
  const { prefix = '[vite]', allowClearScreen = true } = options;
12869
12812
  const thresh = LogLevels[level];
@@ -12879,7 +12822,7 @@ function createLogger(level = 'info', options = {}) {
12879
12822
  : type === 'warn'
12880
12823
  ? colors$1.yellow(colors$1.bold(prefix))
12881
12824
  : colors$1.red(colors$1.bold(prefix));
12882
- return `${colors$1.dim(new Date().toLocaleTimeString())} ${tag} ${msg}`;
12825
+ return `${colors$1.dim(timeFormatter.format(new Date()))} ${tag} ${msg}`;
12883
12826
  }
12884
12827
  else {
12885
12828
  return msg;
@@ -12965,6 +12908,13 @@ const COMPRESSIBLE_ASSETS_RE = /\.(?:html|json|svg|txt|xml|xhtml)$/;
12965
12908
  function buildReporterPlugin(config) {
12966
12909
  const compress = promisify$4(gzip);
12967
12910
  const chunkLimit = config.build.chunkSizeWarningLimit;
12911
+ const numberFormatter = new Intl.NumberFormat('en', {
12912
+ maximumFractionDigits: 2,
12913
+ minimumFractionDigits: 2,
12914
+ });
12915
+ const displaySize = (bytes) => {
12916
+ return `${numberFormatter.format(bytes / 1000)} kB`;
12917
+ };
12968
12918
  const tty = process.stdout.isTTY && !process.env.CI;
12969
12919
  const shouldLogInfo = LogLevels[config.logLevel || 'info'] >= LogLevels.info;
12970
12920
  let hasTransformed = false;
@@ -13048,11 +12998,7 @@ function buildReporterPlugin(config) {
13048
12998
  // dynamic import here.
13049
12999
  const detectedIneffectiveDynamicImport = module.dynamicImporters.some((id) => !isInNodeModules(id) && chunk.moduleIds.includes(id));
13050
13000
  if (detectedIneffectiveDynamicImport) {
13051
- this.warn(`\n(!) ${module.id} is dynamically imported by ${module.dynamicImporters
13052
- .map((m) => m)
13053
- .join(', ')} but also statically imported by ${module.importers
13054
- .map((m) => m)
13055
- .join(', ')}, dynamic import will not move module into another chunk.\n`);
13001
+ this.warn(`\n(!) ${module.id} is dynamically imported by ${module.dynamicImporters.join(', ')} but also statically imported by ${module.importers.join(', ')}, dynamic import will not move module into another chunk.\n`);
13056
13002
  }
13057
13003
  }
13058
13004
  }
@@ -13201,12 +13147,6 @@ function throttle(fn) {
13201
13147
  }, 100);
13202
13148
  };
13203
13149
  }
13204
- function displaySize(bytes) {
13205
- return `${(bytes / 1000).toLocaleString('en', {
13206
- maximumFractionDigits: 2,
13207
- minimumFractionDigits: 2,
13208
- })} kB`;
13209
- }
13210
13150
  function displayTime(time) {
13211
13151
  // display: {X}ms
13212
13152
  if (time < 1000) {
@@ -13876,6 +13816,7 @@ async function transformWithEsbuild(code, filename, options, inMap) {
13876
13816
  }
13877
13817
  }
13878
13818
  let tsconfigRaw = options?.tsconfigRaw;
13819
+ const fallbackSupported = {};
13879
13820
  // if options provide tsconfigRaw in string, it takes highest precedence
13880
13821
  if (typeof tsconfigRaw !== 'string') {
13881
13822
  // these fields would affect the compilation result
@@ -13922,6 +13863,14 @@ async function transformWithEsbuild(code, filename, options, inMap) {
13922
13863
  if (compilerOptions.experimentalDecorators === undefined) {
13923
13864
  compilerOptions.experimentalDecorators = true;
13924
13865
  }
13866
+ // Compat with esbuild 0.17 where static properties are transpiled to
13867
+ // static blocks when `useDefineForClassFields` is false. Its support
13868
+ // is not great yet, so temporarily disable it for now.
13869
+ // TODO: Remove this in Vite 5, don't pass hardcoded `esnext` target
13870
+ // to `transformWithEsbuild` in the esbuild plugin.
13871
+ if (compilerOptions.useDefineForClassFields !== true) {
13872
+ fallbackSupported['class-static-blocks'] = false;
13873
+ }
13925
13874
  // esbuild uses tsconfig fields when both the normal options and tsconfig was set
13926
13875
  // but we want to prioritize the normal options
13927
13876
  if (options) {
@@ -13942,6 +13891,10 @@ async function transformWithEsbuild(code, filename, options, inMap) {
13942
13891
  ...options,
13943
13892
  loader,
13944
13893
  tsconfigRaw,
13894
+ supported: {
13895
+ ...fallbackSupported,
13896
+ ...options?.supported,
13897
+ },
13945
13898
  };
13946
13899
  // Some projects in the ecosystem are calling this function with an ESBuildOptions
13947
13900
  // object and esbuild throws an error for extra fields
@@ -15087,7 +15040,7 @@ class Chunk {
15087
15040
  }
15088
15041
  }
15089
15042
 
15090
- function getBtoa () {
15043
+ function getBtoa() {
15091
15044
  if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
15092
15045
  return (str) => window.btoa(unescape(encodeURIComponent(str)));
15093
15046
  } else if (typeof Buffer === 'function') {
@@ -15200,6 +15153,8 @@ function getLocator(source) {
15200
15153
  };
15201
15154
  }
15202
15155
 
15156
+ const wordRegex = /\w/;
15157
+
15203
15158
  class Mappings {
15204
15159
  constructor(hires) {
15205
15160
  this.hires = hires;
@@ -15228,10 +15183,29 @@ class Mappings {
15228
15183
  addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
15229
15184
  let originalCharIndex = chunk.start;
15230
15185
  let first = true;
15186
+ // when iterating each char, check if it's in a word boundary
15187
+ let charInHiresBoundary = false;
15231
15188
 
15232
15189
  while (originalCharIndex < chunk.end) {
15233
15190
  if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
15234
- this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
15191
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
15192
+
15193
+ if (this.hires === 'boundary') {
15194
+ // in hires "boundary", group segments per word boundary than per char
15195
+ if (wordRegex.test(original[originalCharIndex])) {
15196
+ // for first char in the boundary found, start the boundary by pushing a segment
15197
+ if (!charInHiresBoundary) {
15198
+ this.rawSegments.push(segment);
15199
+ charInHiresBoundary = true;
15200
+ }
15201
+ } else {
15202
+ // for non-word char, end the boundary by pushing a segment
15203
+ this.rawSegments.push(segment);
15204
+ charInHiresBoundary = false;
15205
+ }
15206
+ } else {
15207
+ this.rawSegments.push(segment);
15208
+ }
15235
15209
  }
15236
15210
 
15237
15211
  if (original[originalCharIndex] === '\n') {
@@ -15404,7 +15378,7 @@ class MagicString {
15404
15378
  sourceIndex,
15405
15379
  chunk.content,
15406
15380
  loc,
15407
- chunk.storeName ? names.indexOf(chunk.original) : -1
15381
+ chunk.storeName ? names.indexOf(chunk.original) : -1,
15408
15382
  );
15409
15383
  } else {
15410
15384
  mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
@@ -15415,11 +15389,13 @@ class MagicString {
15415
15389
 
15416
15390
  return {
15417
15391
  file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
15418
- sources: [options.source ? getRelativePath(options.file || '', options.source) : (options.file || '')],
15392
+ sources: [
15393
+ options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
15394
+ ],
15419
15395
  sourcesContent: options.includeContent ? [this.original] : undefined,
15420
15396
  names,
15421
15397
  mappings: mappings.raw,
15422
- x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined
15398
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
15423
15399
  };
15424
15400
  }
15425
15401
 
@@ -15533,14 +15509,14 @@ class MagicString {
15533
15509
 
15534
15510
  insert() {
15535
15511
  throw new Error(
15536
- 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'
15512
+ 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
15537
15513
  );
15538
15514
  }
15539
15515
 
15540
15516
  insertLeft(index, content) {
15541
15517
  if (!warned.insertLeft) {
15542
15518
  console.warn(
15543
- 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'
15519
+ 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
15544
15520
  ); // eslint-disable-line no-console
15545
15521
  warned.insertLeft = true;
15546
15522
  }
@@ -15551,7 +15527,7 @@ class MagicString {
15551
15527
  insertRight(index, content) {
15552
15528
  if (!warned.insertRight) {
15553
15529
  console.warn(
15554
- 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'
15530
+ 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
15555
15531
  ); // eslint-disable-line no-console
15556
15532
  warned.insertRight = true;
15557
15533
  }
@@ -15610,7 +15586,7 @@ class MagicString {
15610
15586
  if (end > this.original.length) throw new Error('end is out of bounds');
15611
15587
  if (start === end)
15612
15588
  throw new Error(
15613
- 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'
15589
+ 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
15614
15590
  );
15615
15591
 
15616
15592
  this._split(start);
@@ -15619,7 +15595,7 @@ class MagicString {
15619
15595
  if (options === true) {
15620
15596
  if (!warned.storeName) {
15621
15597
  console.warn(
15622
- 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'
15598
+ 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
15623
15599
  ); // eslint-disable-line no-console
15624
15600
  warned.storeName = true;
15625
15601
  }
@@ -15841,7 +15817,7 @@ class MagicString {
15841
15817
  // zero-length edited chunks are a special case (overlapping replacements)
15842
15818
  const loc = getLocator(this.original)(index);
15843
15819
  throw new Error(
15844
- `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`
15820
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
15845
15821
  );
15846
15822
  }
15847
15823
 
@@ -16000,7 +15976,7 @@ class MagicString {
16000
15976
  this.overwrite(
16001
15977
  match.index,
16002
15978
  match.index + match[0].length,
16003
- getReplacement(match, this.original)
15979
+ getReplacement(match, this.original),
16004
15980
  );
16005
15981
  });
16006
15982
  } else {
@@ -16009,7 +15985,7 @@ class MagicString {
16009
15985
  this.overwrite(
16010
15986
  match.index,
16011
15987
  match.index + match[0].length,
16012
- getReplacement(match, this.original)
15988
+ getReplacement(match, this.original),
16013
15989
  );
16014
15990
  }
16015
15991
  return this;
@@ -16055,7 +16031,7 @@ class MagicString {
16055
16031
 
16056
16032
  if (!searchValue.global) {
16057
16033
  throw new TypeError(
16058
- 'MagicString.prototype.replaceAll called with a non-global RegExp argument'
16034
+ 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
16059
16035
  );
16060
16036
  }
16061
16037
 
@@ -16166,7 +16142,9 @@ function assetPlugin(config) {
16166
16142
  if (s) {
16167
16143
  return {
16168
16144
  code: s.toString(),
16169
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null,
16145
+ map: config.build.sourcemap
16146
+ ? s.generateMap({ hires: 'boundary' })
16147
+ : null,
16170
16148
  };
16171
16149
  }
16172
16150
  else {
@@ -28587,7 +28565,10 @@ async function tryOptimizedResolve(depsOptimizer, id, importer, preserveSymlinks
28587
28565
  continue;
28588
28566
  // lazily initialize idPkgDir
28589
28567
  if (idPkgDir == null) {
28590
- idPkgDir = resolvePackageData(id, importer, preserveSymlinks, packageCache)?.dir;
28568
+ const pkgName = getNpmPackageName(id);
28569
+ if (!pkgName)
28570
+ break;
28571
+ idPkgDir = resolvePackageData(pkgName, importer, preserveSymlinks, packageCache)?.dir;
28591
28572
  // if still null, it likely means that this id isn't a dep for importer.
28592
28573
  // break to bail early
28593
28574
  if (idPkgDir == null)
@@ -37694,12 +37675,14 @@ function buildHtmlPlugin(config) {
37694
37675
  processedHtml.set(id, s.toString());
37695
37676
  // inject module preload polyfill only when configured and needed
37696
37677
  const { modulePreload } = config.build;
37697
- if ((modulePreload === true ||
37698
- (typeof modulePreload === 'object' && modulePreload.polyfill)) &&
37678
+ if (modulePreload !== false &&
37679
+ modulePreload.polyfill &&
37699
37680
  (someScriptsAreAsync || someScriptsAreDefer)) {
37700
37681
  js = `import "${modulePreloadPolyfillId}";\n${js}`;
37701
37682
  }
37702
- return js;
37683
+ // Force rollup to keep this module from being shared between other entry points.
37684
+ // If the resulting chunk is empty, it will be removed in generateBundle.
37685
+ return { code: js, moduleSideEffects: 'no-treeshake' };
37703
37686
  }
37704
37687
  },
37705
37688
  async generateBundle(options, bundle) {
@@ -37918,7 +37901,18 @@ function htmlEnvHook(config) {
37918
37901
  for (const key in config.define) {
37919
37902
  if (key.startsWith(`import.meta.env.`)) {
37920
37903
  const val = config.define[key];
37921
- env[key.slice(16)] = typeof val === 'string' ? val : JSON.stringify(val);
37904
+ if (typeof val === 'string') {
37905
+ try {
37906
+ const parsed = JSON.parse(val);
37907
+ env[key.slice(16)] = typeof parsed === 'string' ? parsed : val;
37908
+ }
37909
+ catch {
37910
+ env[key.slice(16)] = val;
37911
+ }
37912
+ }
37913
+ else {
37914
+ env[key.slice(16)] = JSON.stringify(val);
37915
+ }
37922
37916
  }
37923
37917
  }
37924
37918
  return (html, ctx) => {
@@ -38532,7 +38526,7 @@ function cssPostPlugin(config) {
38532
38526
  // resolve public URL from CSS paths, we need to use absolute paths
38533
38527
  return {
38534
38528
  code: s.toString(),
38535
- map: s.generateMap({ hires: true }),
38529
+ map: s.generateMap({ hires: 'boundary' }),
38536
38530
  };
38537
38531
  }
38538
38532
  else {
@@ -38918,8 +38912,8 @@ function createCachedImport(imp) {
38918
38912
  return cached;
38919
38913
  };
38920
38914
  }
38921
- const importPostcssImport = createCachedImport(() => import('./dep-b202fccd.js').then(function (n) { return n.i; }));
38922
- const importPostcssModules = createCachedImport(() => import('./dep-e45589f1.js').then(function (n) { return n.i; }));
38915
+ const importPostcssImport = createCachedImport(() => import('./dep-d502c17d.js').then(function (n) { return n.i; }));
38916
+ const importPostcssModules = createCachedImport(() => import('./dep-def3b363.js').then(function (n) { return n.i; }));
38923
38917
  const importPostcss = createCachedImport(() => import('postcss'));
38924
38918
  /**
38925
38919
  * @experimental
@@ -39224,7 +39218,8 @@ function loadPreprocessor(lang, root) {
39224
39218
  }
39225
39219
  catch (e) {
39226
39220
  if (e.code === 'MODULE_NOT_FOUND') {
39227
- throw new Error(`Preprocessor dependency "${lang}" not found. Did you install it?`);
39221
+ const installCommand = getPackageManagerCommand('install');
39222
+ throw new Error(`Preprocessor dependency "${lang}" not found. Did you install it? Try \`${installCommand} -D ${lang}\`.`);
39228
39223
  }
39229
39224
  else {
39230
39225
  const message = new Error(`Preprocessor dependency "${lang}" failed to load:\n${e.message}`);
@@ -39548,7 +39543,7 @@ async function getSource(source, filename, additionalData, enableSourcemap, sep
39548
39543
  const ms = new MagicString(source);
39549
39544
  ms.appendLeft(0, sep);
39550
39545
  ms.appendLeft(0, additionalData);
39551
- const map = ms.generateMap({ hires: true });
39546
+ const map = ms.generateMap({ hires: 'boundary' });
39552
39547
  map.file = filename;
39553
39548
  map.sources = [filename];
39554
39549
  return {
@@ -39587,6 +39582,10 @@ async function compileLightningCSS(id, src, config, urlReplacer) {
39587
39582
  if (filePath === filename) {
39588
39583
  return src;
39589
39584
  }
39585
+ // This happens with html-proxy (#13776)
39586
+ if (!filePath.endsWith('.css')) {
39587
+ return src;
39588
+ }
39590
39589
  return fs$l.readFileSync(toAbsolute(filePath), 'utf-8');
39591
39590
  },
39592
39591
  async resolve(id, from) {
@@ -40736,7 +40735,9 @@ const { isMatch: isMatch$1, scan } = micromatch$2;
40736
40735
  function getAffectedGlobModules(file, server) {
40737
40736
  const modules = [];
40738
40737
  for (const [id, allGlobs] of server._importGlobMap) {
40739
- if (allGlobs.some((glob) => isMatch$1(file, glob)))
40738
+ // (glob1 || glob2) && !glob3 && !glob4...
40739
+ if (allGlobs.some(({ affirmed, negated }) => (!affirmed.length || affirmed.some((glob) => isMatch$1(file, glob))) &&
40740
+ (!negated.length || negated.every((glob) => isMatch$1(file, glob)))))
40740
40741
  modules.push(...(server.moduleGraph.getModulesByFile(id) || []));
40741
40742
  }
40742
40743
  modules.forEach((i) => {
@@ -40760,7 +40761,14 @@ function importGlobPlugin(config) {
40760
40761
  if (result) {
40761
40762
  if (server) {
40762
40763
  const allGlobs = result.matches.map((i) => i.globsResolved);
40763
- server._importGlobMap.set(id, allGlobs);
40764
+ server._importGlobMap.set(id, allGlobs.map((globs) => {
40765
+ const affirmed = [];
40766
+ const negated = [];
40767
+ for (const glob of globs) {
40768
+ (glob[0] === '!' ? negated : affirmed).push(glob);
40769
+ }
40770
+ return { affirmed, negated };
40771
+ }));
40764
40772
  }
40765
40773
  return transformStableResult(result.s, id, config);
40766
40774
  }
@@ -41115,7 +41123,7 @@ async function toAbsoluteGlob(glob, root, importer, resolveId) {
41115
41123
  return pre + posix$1.join(dir, glob);
41116
41124
  if (glob.startsWith('**'))
41117
41125
  return pre + glob;
41118
- const isSubImportsPattern = glob.startsWith('#') && glob.includes('*');
41126
+ const isSubImportsPattern = glob[0] === '#' && glob.includes('*');
41119
41127
  const resolved = normalizePath$3((await resolveId(glob, importer, {
41120
41128
  custom: { 'vite:import-glob': { isSubImportsPattern } },
41121
41129
  })) || glob);
@@ -41909,7 +41917,9 @@ function importAnalysisPlugin(config) {
41909
41917
  }
41910
41918
  }
41911
41919
  // record as safe modules
41912
- server?.moduleGraph.safeModulesPath.add(fsPathFromUrl(url));
41920
+ // safeModulesPath should not include the base prefix.
41921
+ // See https://github.com/vitejs/vite/issues/9438#issuecomment-1465270409
41922
+ server?.moduleGraph.safeModulesPath.add(fsPathFromUrl(stripBase(url, base)));
41913
41923
  if (url !== specifier) {
41914
41924
  let rewriteDone = false;
41915
41925
  if (depsOptimizer?.isOptimizedDepFile(resolvedId) &&
@@ -42534,11 +42544,12 @@ function webWorkerPlugin(config) {
42534
42544
  // other type will be import worker by esm
42535
42545
  const workerType = query['type'];
42536
42546
  let injectEnv = '';
42547
+ const scriptPath = JSON.stringify(path$o.posix.join(config.base, ENV_PUBLIC_PATH));
42537
42548
  if (workerType === 'classic') {
42538
- injectEnv = `importScripts('${ENV_PUBLIC_PATH}')\n`;
42549
+ injectEnv = `importScripts(${scriptPath})\n`;
42539
42550
  }
42540
42551
  else if (workerType === 'module') {
42541
- injectEnv = `import '${ENV_PUBLIC_PATH}'\n`;
42552
+ injectEnv = `import ${scriptPath}\n`;
42542
42553
  }
42543
42554
  else if (workerType === 'ignore') {
42544
42555
  if (isBuild) {
@@ -42630,7 +42641,9 @@ function webWorkerPlugin(config) {
42630
42641
  const result = () => {
42631
42642
  return (s && {
42632
42643
  code: s.toString(),
42633
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null,
42644
+ map: config.build.sourcemap
42645
+ ? s.generateMap({ hires: 'boundary' })
42646
+ : null,
42634
42647
  });
42635
42648
  };
42636
42649
  if (code.match(workerAssetUrlRE)) {
@@ -43114,7 +43127,7 @@ function assetImportMetaUrlPlugin(config) {
43114
43127
  preferRelative: true,
43115
43128
  }));
43116
43129
  file = await assetResolver(url, id);
43117
- file ?? (file = url.startsWith('/')
43130
+ file ?? (file = url[0] === '/'
43118
43131
  ? slash$1(path$o.join(config.publicDir, url))
43119
43132
  : slash$1(path$o.resolve(path$o.dirname(id), url)));
43120
43133
  }
@@ -43513,8 +43526,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
43513
43526
  preAliasPlugin(config),
43514
43527
  alias$1({ entries: config.resolve.alias }),
43515
43528
  ...prePlugins,
43516
- modulePreload === true ||
43517
- (typeof modulePreload === 'object' && modulePreload.polyfill)
43529
+ modulePreload !== false && modulePreload.polyfill
43518
43530
  ? modulePreloadPolyfillPlugin(config)
43519
43531
  : null,
43520
43532
  resolvePlugin({
@@ -44072,7 +44084,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
44072
44084
  return createIfNull
44073
44085
  ? new MagicString(this.originalCode).generateMap({
44074
44086
  includeContent: true,
44075
- hires: true,
44087
+ hires: 'boundary',
44076
44088
  source: cleanUrl(this.filename),
44077
44089
  })
44078
44090
  : null;
@@ -44410,15 +44422,7 @@ async function prepareEsbuildScanner(config, entries, deps, missing, scanContext
44410
44422
  logLevel: 'silent',
44411
44423
  plugins: [...plugins, plugin],
44412
44424
  tsconfig,
44413
- tsconfigRaw: tsconfig || typeof tsconfigRaw === 'string'
44414
- ? tsconfigRaw
44415
- : {
44416
- ...tsconfigRaw,
44417
- compilerOptions: {
44418
- experimentalDecorators: true,
44419
- ...tsconfigRaw?.compilerOptions,
44420
- },
44421
- },
44425
+ tsconfigRaw: resolveTsconfigRaw(tsconfig, tsconfigRaw),
44422
44426
  ...esbuildOptions,
44423
44427
  });
44424
44428
  }
@@ -44769,6 +44773,21 @@ function shouldExternalizeDep(resolvedId, rawId) {
44769
44773
  function isScannable(id) {
44770
44774
  return JS_TYPES_RE.test(id) || htmlTypesRE.test(id);
44771
44775
  }
44776
+ // esbuild v0.18 only transforms decorators when `experimentalDecorators` is set to `true`.
44777
+ // To preserve compat with the esbuild breaking change, we set `experimentalDecorators` to
44778
+ // `true` by default if it's unset.
44779
+ // TODO: Remove this in Vite 5 and check https://github.com/vitejs/vite/pull/13805#issuecomment-1633612320
44780
+ function resolveTsconfigRaw(tsconfig, tsconfigRaw) {
44781
+ return tsconfig || typeof tsconfigRaw === 'string'
44782
+ ? tsconfigRaw
44783
+ : {
44784
+ ...tsconfigRaw,
44785
+ compilerOptions: {
44786
+ experimentalDecorators: true,
44787
+ ...tsconfigRaw?.compilerOptions,
44788
+ },
44789
+ };
44790
+ }
44772
44791
 
44773
44792
  function createOptimizeDepsIncludeResolver(config, ssr) {
44774
44793
  const resolve = config.createResolver({
@@ -45348,7 +45367,7 @@ async function createDepsOptimizer(config, server) {
45348
45367
  // Await for the scan+optimize step running in the background
45349
45368
  // It normally should be over by the time crawling of user code ended
45350
45369
  await depsOptimizer.scanProcessing;
45351
- if (!isBuild && optimizationResult) {
45370
+ if (!isBuild && optimizationResult && !config.optimizeDeps.noDiscovery) {
45352
45371
  const result = await optimizationResult.result;
45353
45372
  optimizationResult = undefined;
45354
45373
  currentlyProcessing = false;
@@ -45846,7 +45865,7 @@ async function prepareEsbuildOptimizerRun(resolvedConfig, depsInfo, ssr, process
45846
45865
  const flatIdDeps = {};
45847
45866
  const idToExports = {};
45848
45867
  const optimizeDeps = getDepOptimizationConfig(config, ssr);
45849
- const { plugins: pluginsFromConfig = [], ...esbuildOptions } = optimizeDeps?.esbuildOptions ?? {};
45868
+ const { plugins: pluginsFromConfig = [], tsconfig, tsconfigRaw, ...esbuildOptions } = optimizeDeps?.esbuildOptions ?? {};
45850
45869
  await Promise.all(Object.keys(depsInfo).map(async (id) => {
45851
45870
  const src = depsInfo[id].src;
45852
45871
  const exportsData = await (depsInfo[id].exportsData ??
@@ -45922,6 +45941,8 @@ async function prepareEsbuildOptimizerRun(resolvedConfig, depsInfo, ssr, process
45922
45941
  metafile: true,
45923
45942
  plugins,
45924
45943
  charset: 'utf8',
45944
+ tsconfig,
45945
+ tsconfigRaw: resolveTsconfigRaw(tsconfig, tsconfigRaw),
45925
45946
  ...esbuildOptions,
45926
45947
  supported: {
45927
45948
  'dynamic-import': true,
@@ -46456,10 +46477,7 @@ function preload(baseModule, deps, importerUrl) {
46456
46477
  function buildImportAnalysisPlugin(config) {
46457
46478
  const ssr = !!config.build.ssr;
46458
46479
  const isWorker = config.isWorker;
46459
- const insertPreload = !(ssr ||
46460
- !!config.build.lib ||
46461
- isWorker ||
46462
- config.build.modulePreload === false);
46480
+ const insertPreload = !(ssr || !!config.build.lib || isWorker);
46463
46481
  const resolveModulePreloadDependencies = config.build.modulePreload && config.build.modulePreload.resolveDependencies;
46464
46482
  const renderBuiltUrl = config.experimental.renderBuiltUrl;
46465
46483
  const customModulePreloadPaths = !!(resolveModulePreloadDependencies || renderBuiltUrl);
@@ -46641,7 +46659,9 @@ function buildImportAnalysisPlugin(config) {
46641
46659
  if (s) {
46642
46660
  return {
46643
46661
  code: s.toString(),
46644
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null,
46662
+ map: config.build.sourcemap
46663
+ ? s.generateMap({ hires: 'boundary' })
46664
+ : null,
46645
46665
  };
46646
46666
  }
46647
46667
  },
@@ -46658,7 +46678,7 @@ function buildImportAnalysisPlugin(config) {
46658
46678
  }
46659
46679
  return {
46660
46680
  code: s.toString(),
46661
- map: s.generateMap({ hires: true }),
46681
+ map: s.generateMap({ hires: 'boundary' }),
46662
46682
  };
46663
46683
  }
46664
46684
  else {
@@ -46668,10 +46688,7 @@ function buildImportAnalysisPlugin(config) {
46668
46688
  return null;
46669
46689
  },
46670
46690
  generateBundle({ format }, bundle) {
46671
- if (format !== 'es' ||
46672
- ssr ||
46673
- isWorker ||
46674
- config.build.modulePreload === false) {
46691
+ if (format !== 'es' || ssr || isWorker) {
46675
46692
  return;
46676
46693
  }
46677
46694
  for (const file in bundle) {
@@ -46759,12 +46776,18 @@ function buildImportAnalysisPlugin(config) {
46759
46776
  const depsArray = deps.size > 1 ||
46760
46777
  // main chunk is removed
46761
46778
  (hasRemovedPureCssChunk && deps.size > 0)
46762
- ? [...deps]
46779
+ ? modulePreload === false
46780
+ ? // CSS deps use the same mechanism as module preloads, so even if disabled,
46781
+ // we still need to pass these deps to the preload helper in dynamic imports.
46782
+ [...deps].filter((d) => d.endsWith('.css'))
46783
+ : [...deps]
46763
46784
  : [];
46764
46785
  let renderedDeps;
46765
46786
  if (normalizedFile && customModulePreloadPaths) {
46766
46787
  const { modulePreload } = config.build;
46767
- const resolveDependencies = modulePreload && modulePreload.resolveDependencies;
46788
+ const resolveDependencies = modulePreload
46789
+ ? modulePreload.resolveDependencies
46790
+ : undefined;
46768
46791
  let resolvedDeps;
46769
46792
  if (resolveDependencies) {
46770
46793
  // We can't let the user remove css deps as these aren't really preloads, they are just using
@@ -46820,7 +46843,7 @@ function buildImportAnalysisPlugin(config) {
46820
46843
  if (config.build.sourcemap && chunk.map) {
46821
46844
  const nextMap = s.generateMap({
46822
46845
  source: chunk.fileName,
46823
- hires: true,
46846
+ hires: 'boundary',
46824
46847
  });
46825
46848
  const map = combineSourcemaps(chunk.fileName, [
46826
46849
  nextMap,
@@ -47527,7 +47550,7 @@ function serveStaticMiddleware(dir, server) {
47527
47550
  isInternalRequest(req.url)) {
47528
47551
  return next();
47529
47552
  }
47530
- const url = new URL(req.url.replace(/^\/+/, '/'), 'http://example.com');
47553
+ const url = new URL(req.url.replace(/^\/{2,}/, '/'), 'http://example.com');
47531
47554
  const pathname = decodeURI(url.pathname);
47532
47555
  // apply aliases to static requests as well
47533
47556
  let redirectedPathname;
@@ -47566,7 +47589,7 @@ function serveRawFsMiddleware(server) {
47566
47589
  const serveFromRoot = sirv('/', sirvOptions({ headers: server.config.server.headers }));
47567
47590
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
47568
47591
  return function viteServeRawFsMiddleware(req, res, next) {
47569
- const url = new URL(req.url.replace(/^\/+/, '/'), 'http://example.com');
47592
+ const url = new URL(req.url.replace(/^\/{2,}/, '/'), 'http://example.com');
47570
47593
  // In some cases (e.g. linked monorepos) files outside of root will
47571
47594
  // reference assets that are also out of served root. In such cases
47572
47595
  // the paths are rewritten to `/@fs/` prefixed paths and must be served by
@@ -55427,7 +55450,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
55427
55450
  }
55428
55451
  },
55429
55452
  });
55430
- let map = s.generateMap({ hires: true });
55453
+ let map = s.generateMap({ hires: 'boundary' });
55431
55454
  if (inMap && inMap.mappings && inMap.sources.length > 0) {
55432
55455
  map = combineSourcemaps(url, [
55433
55456
  {
@@ -63891,8 +63914,15 @@ function proxyMiddleware(httpServer, options, config) {
63891
63914
  }
63892
63915
  proxy.on('error', (err, req, originalRes) => {
63893
63916
  // When it is ws proxy, res is net.Socket
63917
+ // originalRes can be falsy if the proxy itself errored
63894
63918
  const res = originalRes;
63895
- if ('req' in res) {
63919
+ if (!res) {
63920
+ config.logger.error(`${colors$1.red(`http proxy error: ${err.message}`)}\n${err.stack}`, {
63921
+ timestamp: true,
63922
+ error: err,
63923
+ });
63924
+ }
63925
+ else if ('req' in res) {
63896
63926
  config.logger.error(`${colors$1.red(`http proxy error at ${originalRes.req.url}:`)}\n${err.stack}`, {
63897
63927
  timestamp: true,
63898
63928
  error: err,
@@ -64434,7 +64464,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
64434
64464
  if (proxyModulePath[0] !== '\0') {
64435
64465
  map = new MagicString(html)
64436
64466
  .snip(contentNode.sourceCodeLocation.startOffset, contentNode.sourceCodeLocation.endOffset)
64437
- .generateMap({ hires: true });
64467
+ .generateMap({ hires: 'boundary' });
64438
64468
  map.sources = [filename];
64439
64469
  map.file = filename;
64440
64470
  }
@@ -1,4 +1,4 @@
1
- import { E as getDefaultExportFromCjs } from './dep-a8e37fae.js';
1
+ import { E as getDefaultExportFromCjs } from './dep-75f53616.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';
@@ -1,4 +1,4 @@
1
- import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-a8e37fae.js';
1
+ import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-75f53616.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
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, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-a8e37fae.js';
5
+ import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-75f53616.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -738,7 +738,7 @@ cli
738
738
  filterDuplicateOptions(options);
739
739
  // output structure is preserved even after bundling so require()
740
740
  // is ok here
741
- const { createServer } = await import('./chunks/dep-a8e37fae.js').then(function (n) { return n.I; });
741
+ const { createServer } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.I; });
742
742
  try {
743
743
  const server = await createServer({
744
744
  root,
@@ -816,7 +816,7 @@ cli
816
816
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
817
817
  .action(async (root, options) => {
818
818
  filterDuplicateOptions(options);
819
- const { build } = await import('./chunks/dep-a8e37fae.js').then(function (n) { return n.H; });
819
+ const { build } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.H; });
820
820
  const buildOptions = cleanOptions(options);
821
821
  try {
822
822
  await build({
@@ -844,7 +844,7 @@ cli
844
844
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
845
845
  .action(async (root, options) => {
846
846
  filterDuplicateOptions(options);
847
- const { optimizeDeps } = await import('./chunks/dep-a8e37fae.js').then(function (n) { return n.G; });
847
+ const { optimizeDeps } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.G; });
848
848
  try {
849
849
  const config = await resolveConfig({
850
850
  root,
@@ -871,7 +871,7 @@ cli
871
871
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
872
872
  .action(async (root, options) => {
873
873
  filterDuplicateOptions(options);
874
- const { preview } = await import('./chunks/dep-a8e37fae.js').then(function (n) { return n.J; });
874
+ const { preview } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.J; });
875
875
  try {
876
876
  const server = await preview({
877
877
  root,
@@ -2,36 +2,36 @@
2
2
 
3
3
  import type { Agent } from 'node:http';
4
4
  import type { BuildOptions as BuildOptions_2 } from 'esbuild';
5
- import { ChunkMetadata } from "../../types/metadata";
5
+ import { ChunkMetadata } from "../../types/metadata.js";
6
6
  import type { ClientRequest } from 'node:http';
7
7
  import type { ClientRequestArgs } from 'node:http';
8
- import { ConnectedPayload } from "../../types/hmrPayload";
9
- import { CustomEventMap } from "../../types/customEvent";
10
- import { CustomPayload } from "../../types/hmrPayload";
8
+ import { ConnectedPayload } from "../../types/hmrPayload.js";
9
+ import { CustomEventMap } from "../../types/customEvent.js";
10
+ import { CustomPayload } from "../../types/hmrPayload.js";
11
11
  import type { CustomPluginOptions } from 'rollup';
12
12
  import type { Duplex } from 'node:stream';
13
13
  import type { DuplexOptions } from 'node:stream';
14
- import { ErrorPayload } from "../../types/hmrPayload";
14
+ import { ErrorPayload } from "../../types/hmrPayload.js";
15
15
  import { TransformOptions as EsbuildTransformOptions } from 'esbuild';
16
16
  import { version as esbuildVersion } from 'esbuild';
17
17
  import { EventEmitter } from 'node:events';
18
18
  import * as events from 'node:events';
19
19
  import type { ExistingRawSourceMap } from 'rollup';
20
20
  import type * as fs from 'node:fs';
21
- import { FullReloadPayload } from "../../types/hmrPayload";
22
- import { GeneralImportGlobOptions } from "../../types/importGlob";
21
+ import { FullReloadPayload } from "../../types/hmrPayload.js";
22
+ import { GeneralImportGlobOptions } from "../../types/importGlob.js";
23
23
  import type { GetManualChunk } from 'rollup';
24
- import { HMRPayload } from "../../types/hmrPayload";
24
+ import { HMRPayload } from "../../types/hmrPayload.js";
25
25
  import * as http from 'node:http';
26
- import { ImportGlobEagerFunction } from "../../types/importGlob";
27
- import { ImportGlobFunction } from "../../types/importGlob";
28
- import { ImportGlobOptions } from "../../types/importGlob";
26
+ import { ImportGlobEagerFunction } from "../../types/importGlob.js";
27
+ import { ImportGlobFunction } from "../../types/importGlob.js";
28
+ import { ImportGlobOptions } from "../../types/importGlob.js";
29
29
  import type { IncomingMessage } from 'node:http';
30
- import { InferCustomEventPayload } from "../../types/customEvent";
30
+ import { InferCustomEventPayload } from "../../types/customEvent.js";
31
31
  import type { InputOption } from 'rollup';
32
32
  import type { InputOptions } from 'rollup';
33
- import { InvalidatePayload } from "../../types/customEvent";
34
- import { KnownAsTypeMap } from "../../types/importGlob";
33
+ import { InvalidatePayload } from "../../types/customEvent.js";
34
+ import { KnownAsTypeMap } from "../../types/importGlob.js";
35
35
  import type { LoadResult } from 'rollup';
36
36
 
37
37
  import type { ModuleFormat } from 'rollup';
@@ -46,7 +46,7 @@ import type { Plugin as Plugin_3 } from 'rollup';
46
46
  import type { PluginContext } from 'rollup';
47
47
  import type { PluginHooks } from 'rollup';
48
48
  import type * as PostCSS from 'postcss';
49
- import { PrunePayload } from "../../types/hmrPayload";
49
+ import { PrunePayload } from "../../types/hmrPayload.js";
50
50
  import type { ResolveIdResult } from 'rollup';
51
51
  import type * as Rollup from 'rollup';
52
52
  import type { RollupError } from 'rollup';
@@ -66,8 +66,8 @@ import type * as stream from 'node:stream';
66
66
  import type { TransformPluginContext } from 'rollup';
67
67
  import type { TransformResult as TransformResult_2 } from 'rollup';
68
68
  import type { TransformResult as TransformResult_3 } from 'esbuild';
69
- import { Update } from "../../types/hmrPayload";
70
- import { UpdatePayload } from "../../types/hmrPayload";
69
+ import { Update } from "../../types/hmrPayload.js";
70
+ import { UpdatePayload } from "../../types/hmrPayload.js";
71
71
  import type * as url from 'node:url';
72
72
  import type { URL as URL_2 } from 'node:url';
73
73
  import type { WatcherOptions } from 'rollup';
@@ -574,6 +574,8 @@ export declare function defineConfig(config: UserConfig): UserConfig;
574
574
 
575
575
  export declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
576
576
 
577
+ export declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
578
+
577
579
  export declare function defineConfig(config: UserConfigExport): UserConfigExport;
578
580
 
579
581
  export declare interface DepOptimizationConfig {
@@ -1783,7 +1785,7 @@ export declare interface ResolvedBuildOptions extends Required<Omit<BuildOptions
1783
1785
  modulePreload: false | ResolvedModulePreloadOptions;
1784
1786
  }
1785
1787
 
1786
- export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
1788
+ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclude' | 'optimizeDeps' | 'worker' | 'build'> & {
1787
1789
  configFile: string | undefined;
1788
1790
  configFileDependencies: string[];
1789
1791
  inlineConfig: InlineConfig;
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-a8e37fae.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-a8e37fae.js';
1
+ import { i as isInNodeModules } from './chunks/dep-75f53616.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-75f53616.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';
@@ -3825,6 +3825,11 @@ function createLogger(level = 'info', options = {}) {
3825
3825
  if (options.customLogger) {
3826
3826
  return options.customLogger;
3827
3827
  }
3828
+ const timeFormatter = new Intl.DateTimeFormat(undefined, {
3829
+ hour: 'numeric',
3830
+ minute: 'numeric',
3831
+ second: 'numeric',
3832
+ });
3828
3833
  const loggedErrors = new WeakSet();
3829
3834
  const { prefix = '[vite]', allowClearScreen = true } = options;
3830
3835
  const thresh = LogLevels[level];
@@ -3840,7 +3845,7 @@ function createLogger(level = 'info', options = {}) {
3840
3845
  : type === 'warn'
3841
3846
  ? colors.yellow(colors.bold(prefix))
3842
3847
  : colors.red(colors.bold(prefix));
3843
- return `${colors.dim(new Date().toLocaleTimeString())} ${tag} ${msg}`;
3848
+ return `${colors.dim(timeFormatter.format(new Date()))} ${tag} ${msg}`;
3844
3849
  }
3845
3850
  else {
3846
3851
  return msg;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.4.6",
3
+ "version": "4.4.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -86,8 +86,8 @@
86
86
  "@rollup/plugin-node-resolve": "15.1.0",
87
87
  "@rollup/plugin-typescript": "^11.1.2",
88
88
  "@rollup/pluginutils": "^5.0.2",
89
- "@types/pnpapi": "^0.0.2",
90
89
  "@types/escape-html": "^1.0.2",
90
+ "@types/pnpapi": "^0.0.2",
91
91
  "acorn": "^8.10.0",
92
92
  "acorn-walk": "^8.2.0",
93
93
  "cac": "^6.7.14",
@@ -110,7 +110,7 @@
110
110
  "json-stable-stringify": "^1.0.2",
111
111
  "launch-editor-middleware": "^2.6.0",
112
112
  "lightningcss": "^1.21.5",
113
- "magic-string": "^0.30.1",
113
+ "magic-string": "^0.30.2",
114
114
  "micromatch": "^4.0.5",
115
115
  "mlly": "^1.4.0",
116
116
  "mrmime": "^1.0.1",
@@ -138,10 +138,10 @@
138
138
  "peerDependencies": {
139
139
  "@types/node": ">= 14",
140
140
  "less": "*",
141
+ "lightningcss": "^1.21.0",
141
142
  "sass": "*",
142
143
  "stylus": "*",
143
144
  "sugarss": "*",
144
- "lightningcss": "^1.21.0",
145
145
  "terser": "^5.4.0"
146
146
  },
147
147
  "peerDependenciesMeta": {