vite 4.4.7 → 4.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

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;
@@ -12736,7 +12658,7 @@ function transformStableResult(s, id, config) {
12736
12658
  return {
12737
12659
  code: s.toString(),
12738
12660
  map: config.command === 'build' && config.build.sourcemap
12739
- ? s.generateMap({ hires: true, source: id })
12661
+ ? s.generateMap({ hires: 'boundary', source: id })
12740
12662
  : null,
12741
12663
  };
12742
12664
  }
@@ -12841,6 +12763,23 @@ const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
12841
12763
  function escapeRegex(str) {
12842
12764
  return str.replace(escapeRegexRE, '\\$&');
12843
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
+ }
12844
12783
 
12845
12784
  /* eslint no-console: 0 */
12846
12785
  const LogLevels = {
@@ -12863,6 +12802,11 @@ function createLogger(level = 'info', options = {}) {
12863
12802
  if (options.customLogger) {
12864
12803
  return options.customLogger;
12865
12804
  }
12805
+ const timeFormatter = new Intl.DateTimeFormat(undefined, {
12806
+ hour: 'numeric',
12807
+ minute: 'numeric',
12808
+ second: 'numeric',
12809
+ });
12866
12810
  const loggedErrors = new WeakSet();
12867
12811
  const { prefix = '[vite]', allowClearScreen = true } = options;
12868
12812
  const thresh = LogLevels[level];
@@ -12878,7 +12822,7 @@ function createLogger(level = 'info', options = {}) {
12878
12822
  : type === 'warn'
12879
12823
  ? colors$1.yellow(colors$1.bold(prefix))
12880
12824
  : colors$1.red(colors$1.bold(prefix));
12881
- return `${colors$1.dim(new Date().toLocaleTimeString())} ${tag} ${msg}`;
12825
+ return `${colors$1.dim(timeFormatter.format(new Date()))} ${tag} ${msg}`;
12882
12826
  }
12883
12827
  else {
12884
12828
  return msg;
@@ -12964,6 +12908,13 @@ const COMPRESSIBLE_ASSETS_RE = /\.(?:html|json|svg|txt|xml|xhtml)$/;
12964
12908
  function buildReporterPlugin(config) {
12965
12909
  const compress = promisify$4(gzip);
12966
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
+ };
12967
12918
  const tty = process.stdout.isTTY && !process.env.CI;
12968
12919
  const shouldLogInfo = LogLevels[config.logLevel || 'info'] >= LogLevels.info;
12969
12920
  let hasTransformed = false;
@@ -13033,25 +12984,23 @@ function buildReporterPlugin(config) {
13033
12984
  chunkCount = 0;
13034
12985
  compressedCount = 0;
13035
12986
  },
13036
- renderChunk(code, chunk) {
13037
- for (const id of chunk.moduleIds) {
13038
- const module = this.getModuleInfo(id);
13039
- if (!module)
13040
- continue;
13041
- // When a dynamic importer shares a chunk with the imported module,
13042
- // warn that the dynamic imported module will not be moved to another chunk (#12850).
13043
- if (module.importers.length && module.dynamicImporters.length) {
13044
- // Filter out the intersection of dynamic importers and sibling modules in
13045
- // the same chunk. The intersecting dynamic importers' dynamic import is not
13046
- // expected to work. Note we're only detecting the direct ineffective
13047
- // dynamic import here.
13048
- const detectedIneffectiveDynamicImport = module.dynamicImporters.some((id) => !isInNodeModules(id) && chunk.moduleIds.includes(id));
13049
- if (detectedIneffectiveDynamicImport) {
13050
- this.warn(`\n(!) ${module.id} is dynamically imported by ${module.dynamicImporters
13051
- .map((m) => m)
13052
- .join(', ')} but also statically imported by ${module.importers
13053
- .map((m) => m)
13054
- .join(', ')}, dynamic import will not move module into another chunk.\n`);
12987
+ renderChunk(code, chunk, options) {
12988
+ if (!options.inlineDynamicImports) {
12989
+ for (const id of chunk.moduleIds) {
12990
+ const module = this.getModuleInfo(id);
12991
+ if (!module)
12992
+ continue;
12993
+ // When a dynamic importer shares a chunk with the imported module,
12994
+ // warn that the dynamic imported module will not be moved to another chunk (#12850).
12995
+ if (module.importers.length && module.dynamicImporters.length) {
12996
+ // Filter out the intersection of dynamic importers and sibling modules in
12997
+ // the same chunk. The intersecting dynamic importers' dynamic import is not
12998
+ // expected to work. Note we're only detecting the direct ineffective
12999
+ // dynamic import here.
13000
+ const detectedIneffectiveDynamicImport = module.dynamicImporters.some((id) => !isInNodeModules(id) && chunk.moduleIds.includes(id));
13001
+ if (detectedIneffectiveDynamicImport) {
13002
+ 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`);
13003
+ }
13055
13004
  }
13056
13005
  }
13057
13006
  }
@@ -13200,12 +13149,6 @@ function throttle(fn) {
13200
13149
  }, 100);
13201
13150
  };
13202
13151
  }
13203
- function displaySize(bytes) {
13204
- return `${(bytes / 1000).toLocaleString('en', {
13205
- maximumFractionDigits: 2,
13206
- minimumFractionDigits: 2,
13207
- })} kB`;
13208
- }
13209
13152
  function displayTime(time) {
13210
13153
  // display: {X}ms
13211
13154
  if (time < 1000) {
@@ -13875,6 +13818,7 @@ async function transformWithEsbuild(code, filename, options, inMap) {
13875
13818
  }
13876
13819
  }
13877
13820
  let tsconfigRaw = options?.tsconfigRaw;
13821
+ const fallbackSupported = {};
13878
13822
  // if options provide tsconfigRaw in string, it takes highest precedence
13879
13823
  if (typeof tsconfigRaw !== 'string') {
13880
13824
  // these fields would affect the compilation result
@@ -13921,6 +13865,14 @@ async function transformWithEsbuild(code, filename, options, inMap) {
13921
13865
  if (compilerOptions.experimentalDecorators === undefined) {
13922
13866
  compilerOptions.experimentalDecorators = true;
13923
13867
  }
13868
+ // Compat with esbuild 0.17 where static properties are transpiled to
13869
+ // static blocks when `useDefineForClassFields` is false. Its support
13870
+ // is not great yet, so temporarily disable it for now.
13871
+ // TODO: Remove this in Vite 5, don't pass hardcoded `esnext` target
13872
+ // to `transformWithEsbuild` in the esbuild plugin.
13873
+ if (compilerOptions.useDefineForClassFields !== true) {
13874
+ fallbackSupported['class-static-blocks'] = false;
13875
+ }
13924
13876
  // esbuild uses tsconfig fields when both the normal options and tsconfig was set
13925
13877
  // but we want to prioritize the normal options
13926
13878
  if (options) {
@@ -13941,6 +13893,10 @@ async function transformWithEsbuild(code, filename, options, inMap) {
13941
13893
  ...options,
13942
13894
  loader,
13943
13895
  tsconfigRaw,
13896
+ supported: {
13897
+ ...fallbackSupported,
13898
+ ...options?.supported,
13899
+ },
13944
13900
  };
13945
13901
  // Some projects in the ecosystem are calling this function with an ESBuildOptions
13946
13902
  // object and esbuild throws an error for extra fields
@@ -15086,7 +15042,7 @@ class Chunk {
15086
15042
  }
15087
15043
  }
15088
15044
 
15089
- function getBtoa () {
15045
+ function getBtoa() {
15090
15046
  if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
15091
15047
  return (str) => window.btoa(unescape(encodeURIComponent(str)));
15092
15048
  } else if (typeof Buffer === 'function') {
@@ -15199,6 +15155,8 @@ function getLocator(source) {
15199
15155
  };
15200
15156
  }
15201
15157
 
15158
+ const wordRegex = /\w/;
15159
+
15202
15160
  class Mappings {
15203
15161
  constructor(hires) {
15204
15162
  this.hires = hires;
@@ -15227,10 +15185,29 @@ class Mappings {
15227
15185
  addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
15228
15186
  let originalCharIndex = chunk.start;
15229
15187
  let first = true;
15188
+ // when iterating each char, check if it's in a word boundary
15189
+ let charInHiresBoundary = false;
15230
15190
 
15231
15191
  while (originalCharIndex < chunk.end) {
15232
15192
  if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
15233
- this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
15193
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
15194
+
15195
+ if (this.hires === 'boundary') {
15196
+ // in hires "boundary", group segments per word boundary than per char
15197
+ if (wordRegex.test(original[originalCharIndex])) {
15198
+ // for first char in the boundary found, start the boundary by pushing a segment
15199
+ if (!charInHiresBoundary) {
15200
+ this.rawSegments.push(segment);
15201
+ charInHiresBoundary = true;
15202
+ }
15203
+ } else {
15204
+ // for non-word char, end the boundary by pushing a segment
15205
+ this.rawSegments.push(segment);
15206
+ charInHiresBoundary = false;
15207
+ }
15208
+ } else {
15209
+ this.rawSegments.push(segment);
15210
+ }
15234
15211
  }
15235
15212
 
15236
15213
  if (original[originalCharIndex] === '\n') {
@@ -15403,7 +15380,7 @@ class MagicString {
15403
15380
  sourceIndex,
15404
15381
  chunk.content,
15405
15382
  loc,
15406
- chunk.storeName ? names.indexOf(chunk.original) : -1
15383
+ chunk.storeName ? names.indexOf(chunk.original) : -1,
15407
15384
  );
15408
15385
  } else {
15409
15386
  mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
@@ -15414,11 +15391,13 @@ class MagicString {
15414
15391
 
15415
15392
  return {
15416
15393
  file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
15417
- sources: [options.source ? getRelativePath(options.file || '', options.source) : (options.file || '')],
15394
+ sources: [
15395
+ options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
15396
+ ],
15418
15397
  sourcesContent: options.includeContent ? [this.original] : undefined,
15419
15398
  names,
15420
15399
  mappings: mappings.raw,
15421
- x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined
15400
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
15422
15401
  };
15423
15402
  }
15424
15403
 
@@ -15532,14 +15511,14 @@ class MagicString {
15532
15511
 
15533
15512
  insert() {
15534
15513
  throw new Error(
15535
- 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'
15514
+ 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
15536
15515
  );
15537
15516
  }
15538
15517
 
15539
15518
  insertLeft(index, content) {
15540
15519
  if (!warned.insertLeft) {
15541
15520
  console.warn(
15542
- 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'
15521
+ 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
15543
15522
  ); // eslint-disable-line no-console
15544
15523
  warned.insertLeft = true;
15545
15524
  }
@@ -15550,7 +15529,7 @@ class MagicString {
15550
15529
  insertRight(index, content) {
15551
15530
  if (!warned.insertRight) {
15552
15531
  console.warn(
15553
- 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'
15532
+ 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
15554
15533
  ); // eslint-disable-line no-console
15555
15534
  warned.insertRight = true;
15556
15535
  }
@@ -15609,7 +15588,7 @@ class MagicString {
15609
15588
  if (end > this.original.length) throw new Error('end is out of bounds');
15610
15589
  if (start === end)
15611
15590
  throw new Error(
15612
- 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'
15591
+ 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
15613
15592
  );
15614
15593
 
15615
15594
  this._split(start);
@@ -15618,7 +15597,7 @@ class MagicString {
15618
15597
  if (options === true) {
15619
15598
  if (!warned.storeName) {
15620
15599
  console.warn(
15621
- 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'
15600
+ 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
15622
15601
  ); // eslint-disable-line no-console
15623
15602
  warned.storeName = true;
15624
15603
  }
@@ -15840,7 +15819,7 @@ class MagicString {
15840
15819
  // zero-length edited chunks are a special case (overlapping replacements)
15841
15820
  const loc = getLocator(this.original)(index);
15842
15821
  throw new Error(
15843
- `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`
15822
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
15844
15823
  );
15845
15824
  }
15846
15825
 
@@ -15999,7 +15978,7 @@ class MagicString {
15999
15978
  this.overwrite(
16000
15979
  match.index,
16001
15980
  match.index + match[0].length,
16002
- getReplacement(match, this.original)
15981
+ getReplacement(match, this.original),
16003
15982
  );
16004
15983
  });
16005
15984
  } else {
@@ -16008,7 +15987,7 @@ class MagicString {
16008
15987
  this.overwrite(
16009
15988
  match.index,
16010
15989
  match.index + match[0].length,
16011
- getReplacement(match, this.original)
15990
+ getReplacement(match, this.original),
16012
15991
  );
16013
15992
  }
16014
15993
  return this;
@@ -16054,7 +16033,7 @@ class MagicString {
16054
16033
 
16055
16034
  if (!searchValue.global) {
16056
16035
  throw new TypeError(
16057
- 'MagicString.prototype.replaceAll called with a non-global RegExp argument'
16036
+ 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
16058
16037
  );
16059
16038
  }
16060
16039
 
@@ -16165,7 +16144,9 @@ function assetPlugin(config) {
16165
16144
  if (s) {
16166
16145
  return {
16167
16146
  code: s.toString(),
16168
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null,
16147
+ map: config.build.sourcemap
16148
+ ? s.generateMap({ hires: 'boundary' })
16149
+ : null,
16169
16150
  };
16170
16151
  }
16171
16152
  else {
@@ -21321,6 +21302,8 @@ var settings = {};
21321
21302
  if (this.stats) {
21322
21303
  this.objectMode = true;
21323
21304
  }
21305
+ // Remove the cast to the array in the next major (#404).
21306
+ this.ignore = [].concat(this.ignore);
21324
21307
  }
21325
21308
  _getValue(option, value) {
21326
21309
  return option === undefined ? value : option;
@@ -27452,7 +27435,7 @@ function encodeQueryItem(key, value) {
27452
27435
  return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
27453
27436
  }
27454
27437
  function stringifyQuery(query) {
27455
- return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).join("&");
27438
+ return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
27456
27439
  }
27457
27440
 
27458
27441
  new Set(builtinModules);
@@ -36648,47 +36631,77 @@ var src$1 = rc;
36648
36631
 
36649
36632
  var postcssrc = /*@__PURE__*/getDefaultExportFromCjs(src$1);
36650
36633
 
36651
- function stripLiteralAcorn(code) {
36652
- const FILL = " ";
36634
+ function _stripLiteralAcorn(code, options) {
36635
+ const FILL = options?.fillChar ?? " ";
36636
+ const FILL_COMMENT = " ";
36653
36637
  let result = "";
36654
- function fulfill(index) {
36638
+ const filter = options?.filter ?? (() => true);
36639
+ function fillupTo(index) {
36655
36640
  if (index > result.length)
36656
- result += code.slice(result.length, index).replace(/[^\n]/g, FILL);
36641
+ result += code.slice(result.length, index).replace(/[^\n]/g, FILL_COMMENT);
36657
36642
  }
36658
- const tokens = tokenizer(code, {
36643
+ const tokens = [];
36644
+ const pasers = tokenizer(code, {
36659
36645
  ecmaVersion: "latest",
36660
36646
  sourceType: "module",
36661
36647
  allowHashBang: true,
36662
36648
  allowAwaitOutsideFunction: true,
36663
36649
  allowImportExportEverywhere: true
36664
36650
  });
36665
- const inter = tokens[Symbol.iterator]();
36666
- while (true) {
36667
- const { done, value: token } = inter.next();
36668
- if (done)
36669
- break;
36670
- fulfill(token.start);
36671
- if (token.type.label === "string")
36672
- result += code[token.start] + FILL.repeat(token.end - token.start - 2) + code[token.end - 1];
36673
- else if (token.type.label === "template")
36674
- result += FILL.repeat(token.end - token.start);
36675
- else
36651
+ const iter = pasers[Symbol.iterator]();
36652
+ let error;
36653
+ try {
36654
+ while (true) {
36655
+ const { done, value: token } = iter.next();
36656
+ if (done)
36657
+ break;
36658
+ tokens.push(token);
36659
+ fillupTo(token.start);
36660
+ if (token.type.label === "string") {
36661
+ const body = code.slice(token.start + 1, token.end - 1);
36662
+ if (filter(body)) {
36663
+ result += code[token.start] + FILL.repeat(token.end - token.start - 2) + code[token.end - 1];
36664
+ continue;
36665
+ }
36666
+ } else if (token.type.label === "template") {
36667
+ const body = code.slice(token.start, token.end);
36668
+ if (filter(body)) {
36669
+ result += FILL.repeat(token.end - token.start);
36670
+ continue;
36671
+ }
36672
+ } else if (token.type.label === "regexp") {
36673
+ const body = code.slice(token.start, token.end);
36674
+ if (filter(body)) {
36675
+ result += body.replace(/\/(.*)\/(\w?)$/g, (_, $1, $2) => `/${FILL.repeat($1.length)}/${$2}`);
36676
+ continue;
36677
+ }
36678
+ }
36676
36679
  result += code.slice(token.start, token.end);
36680
+ }
36681
+ fillupTo(code.length);
36682
+ } catch (e) {
36683
+ error = e;
36677
36684
  }
36678
- fulfill(code.length);
36679
- return result;
36685
+ return {
36686
+ error,
36687
+ result,
36688
+ tokens
36689
+ };
36680
36690
  }
36681
36691
 
36682
36692
  const multilineCommentsRE = /\/\*([^*\/])*?\*\//gms;
36683
36693
  const singlelineCommentsRE = /(?:^|\n|\r)\s*\/\/.*(?:\r|\n|$)/gm;
36684
- const templateLiteralRE = /\$\{(\s*(?:(?!\$\{).|\n|\r)*?\s*)\}/g;
36694
+ const templateLiteralRE = /\$\{(\s*(?:|{.*}|(?!\$\{).|\n|\r)*?\s*)\}/g;
36685
36695
  const quotesRE = [
36686
36696
  /(["'`])((?:\\\1|(?!\1)|.|\r)*?)\1/gm,
36687
36697
  /([`])((?:\\\1|(?!\1)|.|\n|\r)*?)\1/gm
36688
36698
  // multi-line strings (i.e. template literals only)
36689
36699
  ];
36690
- function stripLiteralRegex(code) {
36691
- code = code.replace(multilineCommentsRE, (s) => " ".repeat(s.length)).replace(singlelineCommentsRE, (s) => " ".repeat(s.length));
36700
+ function stripLiteralRegex(code, options) {
36701
+ const FILL_COMMENT = " ";
36702
+ const FILL = options?.fillChar ?? " ";
36703
+ const filter = options?.filter ?? (() => true);
36704
+ code = code.replace(multilineCommentsRE, (s) => filter(s) ? FILL_COMMENT.repeat(s.length) : s).replace(singlelineCommentsRE, (s) => filter(s) ? FILL_COMMENT.repeat(s.length) : s);
36692
36705
  let expanded = code;
36693
36706
  for (let i = 0; i < 16; i++) {
36694
36707
  const before = expanded;
@@ -36698,19 +36711,32 @@ function stripLiteralRegex(code) {
36698
36711
  }
36699
36712
  quotesRE.forEach((re) => {
36700
36713
  expanded = expanded.replace(re, (s, quote, body, index) => {
36701
- code = code.slice(0, index + 1) + " ".repeat(s.length - 2) + code.slice(index + s.length - 1);
36702
- return quote + " ".repeat(s.length - 2) + quote;
36714
+ if (!filter(s.slice(1, -1)))
36715
+ return s;
36716
+ code = code.slice(0, index + 1) + FILL.repeat(s.length - 2) + code.slice(index + s.length - 1);
36717
+ return quote + FILL.repeat(s.length - 2) + quote;
36703
36718
  });
36704
36719
  });
36705
36720
  return code;
36706
36721
  }
36707
36722
 
36708
- function stripLiteral(code) {
36709
- try {
36710
- return stripLiteralAcorn(code);
36711
- } catch (e) {
36712
- return stripLiteralRegex(code);
36723
+ function stripLiteral(code, options) {
36724
+ return stripLiteralDetailed(code, options).result;
36725
+ }
36726
+ function stripLiteralDetailed(code, options) {
36727
+ const acorn = _stripLiteralAcorn(code, options);
36728
+ if (!acorn.error) {
36729
+ return {
36730
+ mode: "acorn",
36731
+ result: acorn.result,
36732
+ acorn
36733
+ };
36713
36734
  }
36735
+ return {
36736
+ mode: "regex",
36737
+ result: stripLiteralRegex(acorn.result + code.slice(acorn.result.length), options),
36738
+ acorn
36739
+ };
36714
36740
  }
36715
36741
 
36716
36742
  var main$1 = {exports: {}};
@@ -37696,12 +37722,14 @@ function buildHtmlPlugin(config) {
37696
37722
  processedHtml.set(id, s.toString());
37697
37723
  // inject module preload polyfill only when configured and needed
37698
37724
  const { modulePreload } = config.build;
37699
- if ((modulePreload === true ||
37700
- (typeof modulePreload === 'object' && modulePreload.polyfill)) &&
37725
+ if (modulePreload !== false &&
37726
+ modulePreload.polyfill &&
37701
37727
  (someScriptsAreAsync || someScriptsAreDefer)) {
37702
37728
  js = `import "${modulePreloadPolyfillId}";\n${js}`;
37703
37729
  }
37704
- return js;
37730
+ // Force rollup to keep this module from being shared between other entry points.
37731
+ // If the resulting chunk is empty, it will be removed in generateBundle.
37732
+ return { code: js, moduleSideEffects: 'no-treeshake' };
37705
37733
  }
37706
37734
  },
37707
37735
  async generateBundle(options, bundle) {
@@ -38545,7 +38573,7 @@ function cssPostPlugin(config) {
38545
38573
  // resolve public URL from CSS paths, we need to use absolute paths
38546
38574
  return {
38547
38575
  code: s.toString(),
38548
- map: s.generateMap({ hires: true }),
38576
+ map: s.generateMap({ hires: 'boundary' }),
38549
38577
  };
38550
38578
  }
38551
38579
  else {
@@ -38931,8 +38959,8 @@ function createCachedImport(imp) {
38931
38959
  return cached;
38932
38960
  };
38933
38961
  }
38934
- const importPostcssImport = createCachedImport(() => import('./dep-ebfb454b.js').then(function (n) { return n.i; }));
38935
- const importPostcssModules = createCachedImport(() => import('./dep-bcdce950.js').then(function (n) { return n.i; }));
38962
+ const importPostcssImport = createCachedImport(() => import('./dep-e0331088.js').then(function (n) { return n.i; }));
38963
+ const importPostcssModules = createCachedImport(() => import('./dep-73522cdf.js').then(function (n) { return n.i; }));
38936
38964
  const importPostcss = createCachedImport(() => import('postcss'));
38937
38965
  /**
38938
38966
  * @experimental
@@ -39237,7 +39265,8 @@ function loadPreprocessor(lang, root) {
39237
39265
  }
39238
39266
  catch (e) {
39239
39267
  if (e.code === 'MODULE_NOT_FOUND') {
39240
- throw new Error(`Preprocessor dependency "${lang}" not found. Did you install it?`);
39268
+ const installCommand = getPackageManagerCommand('install');
39269
+ throw new Error(`Preprocessor dependency "${lang}" not found. Did you install it? Try \`${installCommand} -D ${lang}\`.`);
39241
39270
  }
39242
39271
  else {
39243
39272
  const message = new Error(`Preprocessor dependency "${lang}" failed to load:\n${e.message}`);
@@ -39561,7 +39590,7 @@ async function getSource(source, filename, additionalData, enableSourcemap, sep
39561
39590
  const ms = new MagicString(source);
39562
39591
  ms.appendLeft(0, sep);
39563
39592
  ms.appendLeft(0, additionalData);
39564
- const map = ms.generateMap({ hires: true });
39593
+ const map = ms.generateMap({ hires: 'boundary' });
39565
39594
  map.file = filename;
39566
39595
  map.sources = [filename];
39567
39596
  return {
@@ -40753,7 +40782,9 @@ const { isMatch: isMatch$1, scan } = micromatch$2;
40753
40782
  function getAffectedGlobModules(file, server) {
40754
40783
  const modules = [];
40755
40784
  for (const [id, allGlobs] of server._importGlobMap) {
40756
- if (allGlobs.some((glob) => isMatch$1(file, glob)))
40785
+ // (glob1 || glob2) && !glob3 && !glob4...
40786
+ if (allGlobs.some(({ affirmed, negated }) => (!affirmed.length || affirmed.some((glob) => isMatch$1(file, glob))) &&
40787
+ (!negated.length || negated.every((glob) => isMatch$1(file, glob)))))
40757
40788
  modules.push(...(server.moduleGraph.getModulesByFile(id) || []));
40758
40789
  }
40759
40790
  modules.forEach((i) => {
@@ -40777,7 +40808,14 @@ function importGlobPlugin(config) {
40777
40808
  if (result) {
40778
40809
  if (server) {
40779
40810
  const allGlobs = result.matches.map((i) => i.globsResolved);
40780
- server._importGlobMap.set(id, allGlobs);
40811
+ server._importGlobMap.set(id, allGlobs.map((globs) => {
40812
+ const affirmed = [];
40813
+ const negated = [];
40814
+ for (const glob of globs) {
40815
+ (glob[0] === '!' ? negated : affirmed).push(glob);
40816
+ }
40817
+ return { affirmed, negated };
40818
+ }));
40781
40819
  }
40782
40820
  return transformStableResult(result.s, id, config);
40783
40821
  }
@@ -41132,7 +41170,7 @@ async function toAbsoluteGlob(glob, root, importer, resolveId) {
41132
41170
  return pre + posix$1.join(dir, glob);
41133
41171
  if (glob.startsWith('**'))
41134
41172
  return pre + glob;
41135
- const isSubImportsPattern = glob.startsWith('#') && glob.includes('*');
41173
+ const isSubImportsPattern = glob[0] === '#' && glob.includes('*');
41136
41174
  const resolved = normalizePath$3((await resolveId(glob, importer, {
41137
41175
  custom: { 'vite:import-glob': { isSubImportsPattern } },
41138
41176
  })) || glob);
@@ -41926,7 +41964,9 @@ function importAnalysisPlugin(config) {
41926
41964
  }
41927
41965
  }
41928
41966
  // record as safe modules
41929
- server?.moduleGraph.safeModulesPath.add(fsPathFromUrl(url));
41967
+ // safeModulesPath should not include the base prefix.
41968
+ // See https://github.com/vitejs/vite/issues/9438#issuecomment-1465270409
41969
+ server?.moduleGraph.safeModulesPath.add(fsPathFromUrl(stripBase(url, base)));
41930
41970
  if (url !== specifier) {
41931
41971
  let rewriteDone = false;
41932
41972
  if (depsOptimizer?.isOptimizedDepFile(resolvedId) &&
@@ -42648,7 +42688,9 @@ function webWorkerPlugin(config) {
42648
42688
  const result = () => {
42649
42689
  return (s && {
42650
42690
  code: s.toString(),
42651
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null,
42691
+ map: config.build.sourcemap
42692
+ ? s.generateMap({ hires: 'boundary' })
42693
+ : null,
42652
42694
  });
42653
42695
  };
42654
42696
  if (code.match(workerAssetUrlRE)) {
@@ -42917,7 +42959,6 @@ function definePlugin(config) {
42917
42959
  };
42918
42960
  }
42919
42961
 
42920
- const ignoreFlagRE = /\/\*\s*@vite-ignore\s*\*\//;
42921
42962
  function err(e, pos) {
42922
42963
  const error = new Error(e);
42923
42964
  error.pos = pos;
@@ -42954,7 +42995,7 @@ function getWorkerType(raw, clean, i) {
42954
42995
  const workerOptString = raw
42955
42996
  .substring(commaIndex + 1, endIndex)
42956
42997
  .replace(/\}[\s\S]*,/g, '}'); // strip trailing comma for parsing
42957
- const hasViteIgnore = ignoreFlagRE.test(workerOptString);
42998
+ const hasViteIgnore = hasViteIgnoreRE.test(workerOptString);
42958
42999
  if (hasViteIgnore) {
42959
43000
  return 'ignore';
42960
43001
  }
@@ -43132,7 +43173,7 @@ function assetImportMetaUrlPlugin(config) {
43132
43173
  preferRelative: true,
43133
43174
  }));
43134
43175
  file = await assetResolver(url, id);
43135
- file ?? (file = url.startsWith('/')
43176
+ file ?? (file = url[0] === '/'
43136
43177
  ? slash$1(path$o.join(config.publicDir, url))
43137
43178
  : slash$1(path$o.resolve(path$o.dirname(id), url)));
43138
43179
  }
@@ -43473,6 +43514,9 @@ function dynamicImportVarsPlugin(config) {
43473
43514
  if (dynamicIndex === -1 || source[start] !== '`') {
43474
43515
  continue;
43475
43516
  }
43517
+ if (hasViteIgnoreRE.test(source.slice(expStart, expEnd))) {
43518
+ continue;
43519
+ }
43476
43520
  s || (s = new MagicString(source));
43477
43521
  let result;
43478
43522
  try {
@@ -43531,8 +43575,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
43531
43575
  preAliasPlugin(config),
43532
43576
  alias$1({ entries: config.resolve.alias }),
43533
43577
  ...prePlugins,
43534
- modulePreload === true ||
43535
- (typeof modulePreload === 'object' && modulePreload.polyfill)
43578
+ modulePreload !== false && modulePreload.polyfill
43536
43579
  ? modulePreloadPolyfillPlugin(config)
43537
43580
  : null,
43538
43581
  resolvePlugin({
@@ -44090,7 +44133,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
44090
44133
  return createIfNull
44091
44134
  ? new MagicString(this.originalCode).generateMap({
44092
44135
  includeContent: true,
44093
- hires: true,
44136
+ hires: 'boundary',
44094
44137
  source: cleanUrl(this.filename),
44095
44138
  })
44096
44139
  : null;
@@ -44428,15 +44471,7 @@ async function prepareEsbuildScanner(config, entries, deps, missing, scanContext
44428
44471
  logLevel: 'silent',
44429
44472
  plugins: [...plugins, plugin],
44430
44473
  tsconfig,
44431
- tsconfigRaw: tsconfig || typeof tsconfigRaw === 'string'
44432
- ? tsconfigRaw
44433
- : {
44434
- ...tsconfigRaw,
44435
- compilerOptions: {
44436
- experimentalDecorators: true,
44437
- ...tsconfigRaw?.compilerOptions,
44438
- },
44439
- },
44474
+ tsconfigRaw: resolveTsconfigRaw(tsconfig, tsconfigRaw),
44440
44475
  ...esbuildOptions,
44441
44476
  });
44442
44477
  }
@@ -44787,6 +44822,21 @@ function shouldExternalizeDep(resolvedId, rawId) {
44787
44822
  function isScannable(id) {
44788
44823
  return JS_TYPES_RE.test(id) || htmlTypesRE.test(id);
44789
44824
  }
44825
+ // esbuild v0.18 only transforms decorators when `experimentalDecorators` is set to `true`.
44826
+ // To preserve compat with the esbuild breaking change, we set `experimentalDecorators` to
44827
+ // `true` by default if it's unset.
44828
+ // TODO: Remove this in Vite 5 and check https://github.com/vitejs/vite/pull/13805#issuecomment-1633612320
44829
+ function resolveTsconfigRaw(tsconfig, tsconfigRaw) {
44830
+ return tsconfig || typeof tsconfigRaw === 'string'
44831
+ ? tsconfigRaw
44832
+ : {
44833
+ ...tsconfigRaw,
44834
+ compilerOptions: {
44835
+ experimentalDecorators: true,
44836
+ ...tsconfigRaw?.compilerOptions,
44837
+ },
44838
+ };
44839
+ }
44790
44840
 
44791
44841
  function createOptimizeDepsIncludeResolver(config, ssr) {
44792
44842
  const resolve = config.createResolver({
@@ -45366,7 +45416,7 @@ async function createDepsOptimizer(config, server) {
45366
45416
  // Await for the scan+optimize step running in the background
45367
45417
  // It normally should be over by the time crawling of user code ended
45368
45418
  await depsOptimizer.scanProcessing;
45369
- if (!isBuild && optimizationResult) {
45419
+ if (!isBuild && optimizationResult && !config.optimizeDeps.noDiscovery) {
45370
45420
  const result = await optimizationResult.result;
45371
45421
  optimizationResult = undefined;
45372
45422
  currentlyProcessing = false;
@@ -45864,7 +45914,7 @@ async function prepareEsbuildOptimizerRun(resolvedConfig, depsInfo, ssr, process
45864
45914
  const flatIdDeps = {};
45865
45915
  const idToExports = {};
45866
45916
  const optimizeDeps = getDepOptimizationConfig(config, ssr);
45867
- const { plugins: pluginsFromConfig = [], ...esbuildOptions } = optimizeDeps?.esbuildOptions ?? {};
45917
+ const { plugins: pluginsFromConfig = [], tsconfig, tsconfigRaw, ...esbuildOptions } = optimizeDeps?.esbuildOptions ?? {};
45868
45918
  await Promise.all(Object.keys(depsInfo).map(async (id) => {
45869
45919
  const src = depsInfo[id].src;
45870
45920
  const exportsData = await (depsInfo[id].exportsData ??
@@ -45940,6 +45990,8 @@ async function prepareEsbuildOptimizerRun(resolvedConfig, depsInfo, ssr, process
45940
45990
  metafile: true,
45941
45991
  plugins,
45942
45992
  charset: 'utf8',
45993
+ tsconfig,
45994
+ tsconfigRaw: resolveTsconfigRaw(tsconfig, tsconfigRaw),
45943
45995
  ...esbuildOptions,
45944
45996
  supported: {
45945
45997
  'dynamic-import': true,
@@ -46474,10 +46526,7 @@ function preload(baseModule, deps, importerUrl) {
46474
46526
  function buildImportAnalysisPlugin(config) {
46475
46527
  const ssr = !!config.build.ssr;
46476
46528
  const isWorker = config.isWorker;
46477
- const insertPreload = !(ssr ||
46478
- !!config.build.lib ||
46479
- isWorker ||
46480
- config.build.modulePreload === false);
46529
+ const insertPreload = !(ssr || !!config.build.lib || isWorker);
46481
46530
  const resolveModulePreloadDependencies = config.build.modulePreload && config.build.modulePreload.resolveDependencies;
46482
46531
  const renderBuiltUrl = config.experimental.renderBuiltUrl;
46483
46532
  const customModulePreloadPaths = !!(resolveModulePreloadDependencies || renderBuiltUrl);
@@ -46498,7 +46547,7 @@ function buildImportAnalysisPlugin(config) {
46498
46547
  ? // If `experimental.renderBuiltUrl` or `build.modulePreload.resolveDependencies` are used
46499
46548
  // the dependencies are already resolved. To avoid the need for `new URL(dep, import.meta.url)`
46500
46549
  // a helper `__vitePreloadRelativeDep` is used to resolve from relative paths which can be minimized.
46501
- `function(dep, importerUrl) { return dep.startsWith('.') ? new URL(dep, importerUrl).href : dep }`
46550
+ `function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }`
46502
46551
  : optimizeModulePreloadRelativePaths
46503
46552
  ? // If there isn't custom resolvers affecting the deps list, deps in the list are relative
46504
46553
  // to the current chunk and are resolved to absolute URL by the __vitePreload helper itself.
@@ -46659,7 +46708,9 @@ function buildImportAnalysisPlugin(config) {
46659
46708
  if (s) {
46660
46709
  return {
46661
46710
  code: s.toString(),
46662
- map: config.build.sourcemap ? s.generateMap({ hires: true }) : null,
46711
+ map: config.build.sourcemap
46712
+ ? s.generateMap({ hires: 'boundary' })
46713
+ : null,
46663
46714
  };
46664
46715
  }
46665
46716
  },
@@ -46676,7 +46727,7 @@ function buildImportAnalysisPlugin(config) {
46676
46727
  }
46677
46728
  return {
46678
46729
  code: s.toString(),
46679
- map: s.generateMap({ hires: true }),
46730
+ map: s.generateMap({ hires: 'boundary' }),
46680
46731
  };
46681
46732
  }
46682
46733
  else {
@@ -46686,10 +46737,7 @@ function buildImportAnalysisPlugin(config) {
46686
46737
  return null;
46687
46738
  },
46688
46739
  generateBundle({ format }, bundle) {
46689
- if (format !== 'es' ||
46690
- ssr ||
46691
- isWorker ||
46692
- config.build.modulePreload === false) {
46740
+ if (format !== 'es' || ssr || isWorker) {
46693
46741
  return;
46694
46742
  }
46695
46743
  for (const file in bundle) {
@@ -46777,12 +46825,18 @@ function buildImportAnalysisPlugin(config) {
46777
46825
  const depsArray = deps.size > 1 ||
46778
46826
  // main chunk is removed
46779
46827
  (hasRemovedPureCssChunk && deps.size > 0)
46780
- ? [...deps]
46828
+ ? modulePreload === false
46829
+ ? // CSS deps use the same mechanism as module preloads, so even if disabled,
46830
+ // we still need to pass these deps to the preload helper in dynamic imports.
46831
+ [...deps].filter((d) => d.endsWith('.css'))
46832
+ : [...deps]
46781
46833
  : [];
46782
46834
  let renderedDeps;
46783
46835
  if (normalizedFile && customModulePreloadPaths) {
46784
46836
  const { modulePreload } = config.build;
46785
- const resolveDependencies = modulePreload && modulePreload.resolveDependencies;
46837
+ const resolveDependencies = modulePreload
46838
+ ? modulePreload.resolveDependencies
46839
+ : undefined;
46786
46840
  let resolvedDeps;
46787
46841
  if (resolveDependencies) {
46788
46842
  // We can't let the user remove css deps as these aren't really preloads, they are just using
@@ -46838,7 +46892,7 @@ function buildImportAnalysisPlugin(config) {
46838
46892
  if (config.build.sourcemap && chunk.map) {
46839
46893
  const nextMap = s.generateMap({
46840
46894
  source: chunk.fileName,
46841
- hires: true,
46895
+ hires: 'boundary',
46842
46896
  });
46843
46897
  const map = combineSourcemaps(chunk.fileName, [
46844
46898
  nextMap,
@@ -47545,7 +47599,7 @@ function serveStaticMiddleware(dir, server) {
47545
47599
  isInternalRequest(req.url)) {
47546
47600
  return next();
47547
47601
  }
47548
- const url = new URL(req.url.replace(/^\/+/, '/'), 'http://example.com');
47602
+ const url = new URL(req.url.replace(/^\/{2,}/, '/'), 'http://example.com');
47549
47603
  const pathname = decodeURI(url.pathname);
47550
47604
  // apply aliases to static requests as well
47551
47605
  let redirectedPathname;
@@ -47584,7 +47638,7 @@ function serveRawFsMiddleware(server) {
47584
47638
  const serveFromRoot = sirv('/', sirvOptions({ headers: server.config.server.headers }));
47585
47639
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
47586
47640
  return function viteServeRawFsMiddleware(req, res, next) {
47587
- const url = new URL(req.url.replace(/^\/+/, '/'), 'http://example.com');
47641
+ const url = new URL(req.url.replace(/^\/{2,}/, '/'), 'http://example.com');
47588
47642
  // In some cases (e.g. linked monorepos) files outside of root will
47589
47643
  // reference assets that are also out of served root. In such cases
47590
47644
  // the paths are rewritten to `/@fs/` prefixed paths and must be served by
@@ -55445,7 +55499,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
55445
55499
  }
55446
55500
  },
55447
55501
  });
55448
- let map = s.generateMap({ hires: true });
55502
+ let map = s.generateMap({ hires: 'boundary' });
55449
55503
  if (inMap && inMap.mappings && inMap.sources.length > 0) {
55450
55504
  map = combineSourcemaps(url, [
55451
55505
  {
@@ -64459,7 +64513,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
64459
64513
  if (proxyModulePath[0] !== '\0') {
64460
64514
  map = new MagicString(html)
64461
64515
  .snip(contentNode.sourceCodeLocation.startOffset, contentNode.sourceCodeLocation.endOffset)
64462
- .generateMap({ hires: true });
64516
+ .generateMap({ hires: 'boundary' });
64463
64517
  map.sources = [filename];
64464
64518
  map.file = filename;
64465
64519
  }