vite 5.4.0-beta.1 → 5.4.1

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

Potentially problematic release.


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

@@ -10781,17 +10781,34 @@ const glob$1 = Object.assign(glob_, {
10781
10781
  });
10782
10782
  glob$1.glob = glob$1;
10783
10783
 
10784
- const comma$1 = ','.charCodeAt(0);
10785
- const semicolon$1 = ';'.charCodeAt(0);
10786
- const chars$2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
10787
- const intToChar$1 = new Uint8Array(64); // 64 possible chars.
10788
- const charToInt$1 = new Uint8Array(128); // z is 122 in ASCII
10789
- for (let i = 0; i < chars$2.length; i++) {
10790
- const c = chars$2.charCodeAt(i);
10791
- intToChar$1[i] = c;
10792
- charToInt$1[c] = i;
10793
- }
10794
- function encodeInteger$1(builder, num, relative) {
10784
+ const comma = ','.charCodeAt(0);
10785
+ const semicolon = ';'.charCodeAt(0);
10786
+ const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
10787
+ const intToChar = new Uint8Array(64); // 64 possible chars.
10788
+ const charToInt = new Uint8Array(128); // z is 122 in ASCII
10789
+ for (let i = 0; i < chars$1.length; i++) {
10790
+ const c = chars$1.charCodeAt(i);
10791
+ intToChar[i] = c;
10792
+ charToInt[c] = i;
10793
+ }
10794
+ function decodeInteger(reader, relative) {
10795
+ let value = 0;
10796
+ let shift = 0;
10797
+ let integer = 0;
10798
+ do {
10799
+ const c = reader.next();
10800
+ integer = charToInt[c];
10801
+ value |= (integer & 31) << shift;
10802
+ shift += 5;
10803
+ } while (integer & 32);
10804
+ const shouldNegate = value & 1;
10805
+ value >>>= 1;
10806
+ if (shouldNegate) {
10807
+ value = -0x80000000 | -value;
10808
+ }
10809
+ return relative + value;
10810
+ }
10811
+ function encodeInteger(builder, num, relative) {
10795
10812
  let delta = num - relative;
10796
10813
  delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
10797
10814
  do {
@@ -10799,14 +10816,19 @@ function encodeInteger$1(builder, num, relative) {
10799
10816
  delta >>>= 5;
10800
10817
  if (delta > 0)
10801
10818
  clamped |= 0b100000;
10802
- builder.write(intToChar$1[clamped]);
10819
+ builder.write(intToChar[clamped]);
10803
10820
  } while (delta > 0);
10804
10821
  return num;
10805
10822
  }
10823
+ function hasMoreVlq(reader, max) {
10824
+ if (reader.pos >= max)
10825
+ return false;
10826
+ return reader.peek() !== comma;
10827
+ }
10806
10828
 
10807
10829
  const bufLength = 1024 * 16;
10808
10830
  // Provide a fallback for older environments.
10809
- const td$1 = typeof TextDecoder !== 'undefined'
10831
+ const td = typeof TextDecoder !== 'undefined'
10810
10832
  ? /* #__PURE__ */ new TextDecoder()
10811
10833
  : typeof Buffer !== 'undefined'
10812
10834
  ? {
@@ -10834,16 +10856,86 @@ class StringWriter {
10834
10856
  const { buffer } = this;
10835
10857
  buffer[this.pos++] = v;
10836
10858
  if (this.pos === bufLength) {
10837
- this.out += td$1.decode(buffer);
10859
+ this.out += td.decode(buffer);
10838
10860
  this.pos = 0;
10839
10861
  }
10840
10862
  }
10841
10863
  flush() {
10842
10864
  const { buffer, out, pos } = this;
10843
- return pos > 0 ? out + td$1.decode(buffer.subarray(0, pos)) : out;
10865
+ return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
10866
+ }
10867
+ }
10868
+ class StringReader {
10869
+ constructor(buffer) {
10870
+ this.pos = 0;
10871
+ this.buffer = buffer;
10872
+ }
10873
+ next() {
10874
+ return this.buffer.charCodeAt(this.pos++);
10875
+ }
10876
+ peek() {
10877
+ return this.buffer.charCodeAt(this.pos);
10878
+ }
10879
+ indexOf(char) {
10880
+ const { buffer, pos } = this;
10881
+ const idx = buffer.indexOf(char, pos);
10882
+ return idx === -1 ? buffer.length : idx;
10844
10883
  }
10845
10884
  }
10846
- function encode$2(decoded) {
10885
+
10886
+ function decode(mappings) {
10887
+ const { length } = mappings;
10888
+ const reader = new StringReader(mappings);
10889
+ const decoded = [];
10890
+ let genColumn = 0;
10891
+ let sourcesIndex = 0;
10892
+ let sourceLine = 0;
10893
+ let sourceColumn = 0;
10894
+ let namesIndex = 0;
10895
+ do {
10896
+ const semi = reader.indexOf(';');
10897
+ const line = [];
10898
+ let sorted = true;
10899
+ let lastCol = 0;
10900
+ genColumn = 0;
10901
+ while (reader.pos < semi) {
10902
+ let seg;
10903
+ genColumn = decodeInteger(reader, genColumn);
10904
+ if (genColumn < lastCol)
10905
+ sorted = false;
10906
+ lastCol = genColumn;
10907
+ if (hasMoreVlq(reader, semi)) {
10908
+ sourcesIndex = decodeInteger(reader, sourcesIndex);
10909
+ sourceLine = decodeInteger(reader, sourceLine);
10910
+ sourceColumn = decodeInteger(reader, sourceColumn);
10911
+ if (hasMoreVlq(reader, semi)) {
10912
+ namesIndex = decodeInteger(reader, namesIndex);
10913
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
10914
+ }
10915
+ else {
10916
+ seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
10917
+ }
10918
+ }
10919
+ else {
10920
+ seg = [genColumn];
10921
+ }
10922
+ line.push(seg);
10923
+ reader.pos++;
10924
+ }
10925
+ if (!sorted)
10926
+ sort(line);
10927
+ decoded.push(line);
10928
+ reader.pos = semi + 1;
10929
+ } while (reader.pos <= length);
10930
+ return decoded;
10931
+ }
10932
+ function sort(line) {
10933
+ line.sort(sortComparator$1);
10934
+ }
10935
+ function sortComparator$1(a, b) {
10936
+ return a[0] - b[0];
10937
+ }
10938
+ function encode$1(decoded) {
10847
10939
  const writer = new StringWriter();
10848
10940
  let sourcesIndex = 0;
10849
10941
  let sourceLine = 0;
@@ -10852,23 +10944,23 @@ function encode$2(decoded) {
10852
10944
  for (let i = 0; i < decoded.length; i++) {
10853
10945
  const line = decoded[i];
10854
10946
  if (i > 0)
10855
- writer.write(semicolon$1);
10947
+ writer.write(semicolon);
10856
10948
  if (line.length === 0)
10857
10949
  continue;
10858
10950
  let genColumn = 0;
10859
10951
  for (let j = 0; j < line.length; j++) {
10860
10952
  const segment = line[j];
10861
10953
  if (j > 0)
10862
- writer.write(comma$1);
10863
- genColumn = encodeInteger$1(writer, segment[0], genColumn);
10954
+ writer.write(comma);
10955
+ genColumn = encodeInteger(writer, segment[0], genColumn);
10864
10956
  if (segment.length === 1)
10865
10957
  continue;
10866
- sourcesIndex = encodeInteger$1(writer, segment[1], sourcesIndex);
10867
- sourceLine = encodeInteger$1(writer, segment[2], sourceLine);
10868
- sourceColumn = encodeInteger$1(writer, segment[3], sourceColumn);
10958
+ sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
10959
+ sourceLine = encodeInteger(writer, segment[2], sourceLine);
10960
+ sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
10869
10961
  if (segment.length === 4)
10870
10962
  continue;
10871
- namesIndex = encodeInteger$1(writer, segment[4], namesIndex);
10963
+ namesIndex = encodeInteger(writer, segment[4], namesIndex);
10872
10964
  }
10873
10965
  }
10874
10966
  return writer.flush();
@@ -11088,7 +11180,7 @@ let SourceMap$1 = class SourceMap {
11088
11180
  this.sources = properties.sources;
11089
11181
  this.sourcesContent = properties.sourcesContent;
11090
11182
  this.names = properties.names;
11091
- this.mappings = encode$2(properties.mappings);
11183
+ this.mappings = encode$1(properties.mappings);
11092
11184
  if (typeof properties.x_google_ignoreList !== 'undefined') {
11093
11185
  this.x_google_ignoreList = properties.x_google_ignoreList;
11094
11186
  }
@@ -14448,168 +14540,6 @@ function commonjs(options = {}) {
14448
14540
  };
14449
14541
  }
14450
14542
 
14451
- const comma = ','.charCodeAt(0);
14452
- const semicolon = ';'.charCodeAt(0);
14453
- const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
14454
- const intToChar = new Uint8Array(64); // 64 possible chars.
14455
- const charToInt = new Uint8Array(128); // z is 122 in ASCII
14456
- for (let i = 0; i < chars$1.length; i++) {
14457
- const c = chars$1.charCodeAt(i);
14458
- intToChar[i] = c;
14459
- charToInt[c] = i;
14460
- }
14461
- // Provide a fallback for older environments.
14462
- const td = typeof TextDecoder !== 'undefined'
14463
- ? /* #__PURE__ */ new TextDecoder()
14464
- : typeof Buffer !== 'undefined'
14465
- ? {
14466
- decode(buf) {
14467
- const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
14468
- return out.toString();
14469
- },
14470
- }
14471
- : {
14472
- decode(buf) {
14473
- let out = '';
14474
- for (let i = 0; i < buf.length; i++) {
14475
- out += String.fromCharCode(buf[i]);
14476
- }
14477
- return out;
14478
- },
14479
- };
14480
- function decode(mappings) {
14481
- const state = new Int32Array(5);
14482
- const decoded = [];
14483
- let index = 0;
14484
- do {
14485
- const semi = indexOf(mappings, index);
14486
- const line = [];
14487
- let sorted = true;
14488
- let lastCol = 0;
14489
- state[0] = 0;
14490
- for (let i = index; i < semi; i++) {
14491
- let seg;
14492
- i = decodeInteger(mappings, i, state, 0); // genColumn
14493
- const col = state[0];
14494
- if (col < lastCol)
14495
- sorted = false;
14496
- lastCol = col;
14497
- if (hasMoreVlq(mappings, i, semi)) {
14498
- i = decodeInteger(mappings, i, state, 1); // sourcesIndex
14499
- i = decodeInteger(mappings, i, state, 2); // sourceLine
14500
- i = decodeInteger(mappings, i, state, 3); // sourceColumn
14501
- if (hasMoreVlq(mappings, i, semi)) {
14502
- i = decodeInteger(mappings, i, state, 4); // namesIndex
14503
- seg = [col, state[1], state[2], state[3], state[4]];
14504
- }
14505
- else {
14506
- seg = [col, state[1], state[2], state[3]];
14507
- }
14508
- }
14509
- else {
14510
- seg = [col];
14511
- }
14512
- line.push(seg);
14513
- }
14514
- if (!sorted)
14515
- sort(line);
14516
- decoded.push(line);
14517
- index = semi + 1;
14518
- } while (index <= mappings.length);
14519
- return decoded;
14520
- }
14521
- function indexOf(mappings, index) {
14522
- const idx = mappings.indexOf(';', index);
14523
- return idx === -1 ? mappings.length : idx;
14524
- }
14525
- function decodeInteger(mappings, pos, state, j) {
14526
- let value = 0;
14527
- let shift = 0;
14528
- let integer = 0;
14529
- do {
14530
- const c = mappings.charCodeAt(pos++);
14531
- integer = charToInt[c];
14532
- value |= (integer & 31) << shift;
14533
- shift += 5;
14534
- } while (integer & 32);
14535
- const shouldNegate = value & 1;
14536
- value >>>= 1;
14537
- if (shouldNegate) {
14538
- value = -0x80000000 | -value;
14539
- }
14540
- state[j] += value;
14541
- return pos;
14542
- }
14543
- function hasMoreVlq(mappings, i, length) {
14544
- if (i >= length)
14545
- return false;
14546
- return mappings.charCodeAt(i) !== comma;
14547
- }
14548
- function sort(line) {
14549
- line.sort(sortComparator$1);
14550
- }
14551
- function sortComparator$1(a, b) {
14552
- return a[0] - b[0];
14553
- }
14554
- function encode$1(decoded) {
14555
- const state = new Int32Array(5);
14556
- const bufLength = 1024 * 16;
14557
- const subLength = bufLength - 36;
14558
- const buf = new Uint8Array(bufLength);
14559
- const sub = buf.subarray(0, subLength);
14560
- let pos = 0;
14561
- let out = '';
14562
- for (let i = 0; i < decoded.length; i++) {
14563
- const line = decoded[i];
14564
- if (i > 0) {
14565
- if (pos === bufLength) {
14566
- out += td.decode(buf);
14567
- pos = 0;
14568
- }
14569
- buf[pos++] = semicolon;
14570
- }
14571
- if (line.length === 0)
14572
- continue;
14573
- state[0] = 0;
14574
- for (let j = 0; j < line.length; j++) {
14575
- const segment = line[j];
14576
- // We can push up to 5 ints, each int can take at most 7 chars, and we
14577
- // may push a comma.
14578
- if (pos > subLength) {
14579
- out += td.decode(sub);
14580
- buf.copyWithin(0, subLength, pos);
14581
- pos -= subLength;
14582
- }
14583
- if (j > 0)
14584
- buf[pos++] = comma;
14585
- pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
14586
- if (segment.length === 1)
14587
- continue;
14588
- pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
14589
- pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
14590
- pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
14591
- if (segment.length === 4)
14592
- continue;
14593
- pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
14594
- }
14595
- }
14596
- return out + td.decode(buf.subarray(0, pos));
14597
- }
14598
- function encodeInteger(buf, pos, state, segment, j) {
14599
- const next = segment[j];
14600
- let num = next - state[j];
14601
- state[j] = next;
14602
- num = num < 0 ? (-num << 1) | 1 : num << 1;
14603
- do {
14604
- let clamped = num & 0b011111;
14605
- num >>>= 5;
14606
- if (num > 0)
14607
- clamped |= 0b100000;
14608
- buf[pos++] = intToChar[clamped];
14609
- } while (num > 0);
14610
- return pos;
14611
- }
14612
-
14613
14543
  // Matches the scheme of a URL, eg "http://"
14614
14544
  const schemeRegex = /^[\w+.-]+:\/\//;
14615
14545
  /**
@@ -16732,11 +16662,6 @@ function watchPackageDataPlugin(packageCache) {
16732
16662
  if (id.endsWith("/package.json")) {
16733
16663
  invalidatePackageData(packageCache, path$n.normalize(id));
16734
16664
  }
16735
- },
16736
- handleHotUpdate({ file }) {
16737
- if (file.endsWith("/package.json")) {
16738
- invalidatePackageData(packageCache, path$n.normalize(file));
16739
- }
16740
16665
  }
16741
16666
  };
16742
16667
  }
@@ -27143,7 +27068,6 @@ class Collection extends NodeBase {
27143
27068
  }
27144
27069
  }
27145
27070
  }
27146
- Collection.maxFlowStringSingleLineLength = 60;
27147
27071
 
27148
27072
  /**
27149
27073
  * Stringifies a comment.
@@ -27175,6 +27099,8 @@ const FOLD_QUOTED = 'quoted';
27175
27099
  function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
27176
27100
  if (!lineWidth || lineWidth < 0)
27177
27101
  return text;
27102
+ if (lineWidth < minContentWidth)
27103
+ minContentWidth = 0;
27178
27104
  const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
27179
27105
  if (text.length <= endStep)
27180
27106
  return text;
@@ -29747,11 +29673,11 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
29747
29673
  let comment = '';
29748
29674
  let commentSep = '';
29749
29675
  let hasNewline = false;
29750
- let hasNewlineAfterProp = false;
29751
29676
  let reqSpace = false;
29752
29677
  let tab = null;
29753
29678
  let anchor = null;
29754
29679
  let tag = null;
29680
+ let newlineAfterProp = null;
29755
29681
  let comma = null;
29756
29682
  let found = null;
29757
29683
  let start = null;
@@ -29805,7 +29731,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
29805
29731
  atNewline = true;
29806
29732
  hasNewline = true;
29807
29733
  if (anchor || tag)
29808
- hasNewlineAfterProp = true;
29734
+ newlineAfterProp = token;
29809
29735
  hasSpace = true;
29810
29736
  break;
29811
29737
  case 'anchor':
@@ -29879,9 +29805,9 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
29879
29805
  spaceBefore,
29880
29806
  comment,
29881
29807
  hasNewline,
29882
- hasNewlineAfterProp,
29883
29808
  anchor,
29884
29809
  tag,
29810
+ newlineAfterProp,
29885
29811
  end,
29886
29812
  start: start ?? end
29887
29813
  };
@@ -29983,7 +29909,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
29983
29909
  }
29984
29910
  continue;
29985
29911
  }
29986
- if (keyProps.hasNewlineAfterProp || containsNewline(key)) {
29912
+ if (keyProps.newlineAfterProp || containsNewline(key)) {
29987
29913
  onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
29988
29914
  }
29989
29915
  }
@@ -30337,10 +30263,23 @@ function resolveCollection(CN, ctx, token, onError, tagName, tag) {
30337
30263
  coll.tag = tagName;
30338
30264
  return coll;
30339
30265
  }
30340
- function composeCollection(CN, ctx, token, tagToken, onError) {
30266
+ function composeCollection(CN, ctx, token, props, onError) {
30267
+ const tagToken = props.tag;
30341
30268
  const tagName = !tagToken
30342
30269
  ? null
30343
30270
  : ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg));
30271
+ if (token.type === 'block-seq') {
30272
+ const { anchor, newlineAfterProp: nl } = props;
30273
+ const lastProp = anchor && tagToken
30274
+ ? anchor.offset > tagToken.offset
30275
+ ? anchor
30276
+ : tagToken
30277
+ : (anchor ?? tagToken);
30278
+ if (lastProp && (!nl || nl.offset < lastProp.offset)) {
30279
+ const message = 'Missing newline after block sequence props';
30280
+ onError(lastProp, 'MISSING_CHAR', message);
30281
+ }
30282
+ }
30344
30283
  const expType = token.type === 'block-map'
30345
30284
  ? 'map'
30346
30285
  : token.type === 'block-seq'
@@ -30354,8 +30293,7 @@ function composeCollection(CN, ctx, token, tagToken, onError) {
30354
30293
  !tagName ||
30355
30294
  tagName === '!' ||
30356
30295
  (tagName === YAMLMap.tagName && expType === 'map') ||
30357
- (tagName === YAMLSeq.tagName && expType === 'seq') ||
30358
- !expType) {
30296
+ (tagName === YAMLSeq.tagName && expType === 'seq')) {
30359
30297
  return resolveCollection(CN, ctx, token, onError, tagName);
30360
30298
  }
30361
30299
  let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
@@ -30923,7 +30861,7 @@ function composeNode(ctx, token, props, onError) {
30923
30861
  case 'block-map':
30924
30862
  case 'block-seq':
30925
30863
  case 'flow-collection':
30926
- node = composeCollection(CN, ctx, token, tag, onError);
30864
+ node = composeCollection(CN, ctx, token, props, onError);
30927
30865
  if (anchor)
30928
30866
  node.anchor = anchor.source.substring(1);
30929
30867
  break;
@@ -31995,15 +31933,11 @@ class Lexer {
31995
31933
  if (!this.atEnd && !this.hasChars(4))
31996
31934
  return this.setNext('line-start');
31997
31935
  const s = this.peek(3);
31998
- if (s === '---' && isEmpty(this.charAt(3))) {
31936
+ if ((s === '---' || s === '...') && isEmpty(this.charAt(3))) {
31999
31937
  yield* this.pushCount(3);
32000
31938
  this.indentValue = 0;
32001
31939
  this.indentNext = 0;
32002
- return 'doc';
32003
- }
32004
- else if (s === '...' && isEmpty(this.charAt(3))) {
32005
- yield* this.pushCount(3);
32006
- return 'stream';
31940
+ return s === '---' ? 'doc' : 'stream';
32007
31941
  }
32008
31942
  }
32009
31943
  this.indentValue = yield* this.pushSpaces(false);
@@ -35215,7 +35149,7 @@ function buildHtmlPlugin(config) {
35215
35149
  async transform(html, id) {
35216
35150
  if (id.endsWith(".html")) {
35217
35151
  id = normalizePath$3(id);
35218
- const relativeUrlPath = path$n.posix.relative(config.root, id);
35152
+ const relativeUrlPath = normalizePath$3(path$n.relative(config.root, id));
35219
35153
  const publicPath = `/${relativeUrlPath}`;
35220
35154
  const publicBase = getBaseInHTML(relativeUrlPath, config);
35221
35155
  const publicToRelative = (filename, importer) => publicBase + filename;
@@ -35549,7 +35483,9 @@ ${js}`;
35549
35483
  return tags;
35550
35484
  };
35551
35485
  for (const [normalizedId, html] of processedHtml) {
35552
- const relativeUrlPath = path$n.posix.relative(config.root, normalizedId);
35486
+ const relativeUrlPath = normalizePath$3(
35487
+ path$n.relative(config.root, normalizedId)
35488
+ );
35553
35489
  const assetsBase = getBaseInHTML(relativeUrlPath, config);
35554
35490
  const toOutputFilePath = (filename, type) => {
35555
35491
  if (isExternalUrl(filename)) {
@@ -36346,7 +36282,9 @@ function cssPostPlugin(config) {
36346
36282
  const relative = config.base === "./" || config.base === "";
36347
36283
  const cssAssetDirname = encodedPublicUrls || relative ? slash$1(getCssAssetDirname(cssAssetName)) : void 0;
36348
36284
  const toRelative = (filename) => {
36349
- const relativePath = path$n.posix.relative(cssAssetDirname, filename);
36285
+ const relativePath = normalizePath$3(
36286
+ path$n.relative(cssAssetDirname, filename)
36287
+ );
36350
36288
  return relativePath[0] === "." ? relativePath : "./" + relativePath;
36351
36289
  };
36352
36290
  chunkCSS2 = chunkCSS2.replace(assetUrlRE, (_, fileHash, postfix = "") => {
@@ -36364,9 +36302,8 @@ function cssPostPlugin(config) {
36364
36302
  );
36365
36303
  });
36366
36304
  if (encodedPublicUrls) {
36367
- const relativePathToPublicFromCSS = path$n.posix.relative(
36368
- cssAssetDirname,
36369
- ""
36305
+ const relativePathToPublicFromCSS = normalizePath$3(
36306
+ path$n.relative(cssAssetDirname, "")
36370
36307
  );
36371
36308
  chunkCSS2 = chunkCSS2.replace(publicAssetUrlRE, (_, hash) => {
36372
36309
  const publicUrl = publicAssetUrlMap.get(hash).slice(1);
@@ -36988,8 +36925,8 @@ function createCachedImport(imp) {
36988
36925
  return cached;
36989
36926
  };
36990
36927
  }
36991
- const importPostcssImport = createCachedImport(() => import('./dep-y7MNyJvV.js').then(function (n) { return n.i; }));
36992
- const importPostcssModules = createCachedImport(() => import('./dep-Du4V_m3I.js').then(function (n) { return n.i; }));
36928
+ const importPostcssImport = createCachedImport(() => import('./dep-SDtFYyy1.js').then(function (n) { return n.i; }));
36929
+ const importPostcssModules = createCachedImport(() => import('./dep-BkYu-SNl.js').then(function (n) { return n.i; }));
36993
36930
  const importPostcss = createCachedImport(() => import('postcss'));
36994
36931
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
36995
36932
  let alwaysFakeWorkerWorkerControllerCache;
@@ -37984,7 +37921,7 @@ async function compileLightningCSS(id, src, config, urlReplacer) {
37984
37921
  }
37985
37922
  deps.add(dep.url);
37986
37923
  if (urlReplacer) {
37987
- const replaceUrl = await urlReplacer(dep.url, id);
37924
+ const replaceUrl = await urlReplacer(dep.url, dep.loc.filePath);
37988
37925
  css = css.replace(dep.placeholder, () => replaceUrl);
37989
37926
  } else {
37990
37927
  css = css.replace(dep.placeholder, () => dep.url);
@@ -45409,8 +45346,8 @@ function launchEditor (file, specifiedEditor, onErrorCallback) {
45409
45346
  // and
45410
45347
  // https://github.com/facebook/create-react-app/pull/5431)
45411
45348
 
45412
- // Allows alphanumeric characters, periods, dashes, slashes, and underscores.
45413
- const WINDOWS_CMD_SAFE_FILE_NAME_PATTERN = /^([A-Za-z]:[/\\])?[\p{L}0-9/.\-_\\]+$/u;
45349
+ // Allows alphanumeric characters, periods, dashes, slashes, underscores, plus and space.
45350
+ const WINDOWS_CMD_SAFE_FILE_NAME_PATTERN = /^([A-Za-z]:[/\\])?[\p{L}0-9/.\-\\_+ ]+$/u;
45414
45351
  if (
45415
45352
  process.platform === 'win32' &&
45416
45353
  !WINDOWS_CMD_SAFE_FILE_NAME_PATTERN.test(fileName.trim())
@@ -47232,8 +47169,7 @@ function throwFileNotFoundInOptimizedDep(id) {
47232
47169
  const nonJsRe = /\.json(?:$|\?)/;
47233
47170
  const isNonJsRequest = (request) => nonJsRe.test(request);
47234
47171
  const importMetaEnvMarker = "__vite_import_meta_env__";
47235
- const bareImportMetaEnvRe = new RegExp(`${importMetaEnvMarker}(?!\\.)\\b`);
47236
- const importMetaEnvKeyRe = new RegExp(`${importMetaEnvMarker}\\..+?\\b`, "g");
47172
+ const importMetaEnvKeyReCache = /* @__PURE__ */ new Map();
47237
47173
  function definePlugin(config) {
47238
47174
  const isBuild = config.command === "build";
47239
47175
  const isBuildLib = isBuild && config.build.lib;
@@ -47289,8 +47225,6 @@ function definePlugin(config) {
47289
47225
  SSR: ssr + "",
47290
47226
  ...userDefineEnv
47291
47227
  });
47292
- const banner = `const ${importMetaEnvMarker} = ${importMetaEnvVal};
47293
- `;
47294
47228
  const patternKeys = Object.keys(userDefine);
47295
47229
  if (replaceProcessEnv && Object.keys(processEnv).length) {
47296
47230
  patternKeys.push("process.env");
@@ -47299,7 +47233,7 @@ function definePlugin(config) {
47299
47233
  patternKeys.push("import.meta.env", "import.meta.hot");
47300
47234
  }
47301
47235
  const pattern = patternKeys.length ? new RegExp(patternKeys.map(escapeRegex).join("|")) : null;
47302
- return [define, pattern, banner];
47236
+ return [define, pattern, importMetaEnvVal];
47303
47237
  }
47304
47238
  const defaultPattern = generatePattern(false);
47305
47239
  const ssrPattern = generatePattern(true);
@@ -47316,21 +47250,35 @@ function definePlugin(config) {
47316
47250
  ) {
47317
47251
  return;
47318
47252
  }
47319
- const [define, pattern, banner] = ssr ? ssrPattern : defaultPattern;
47253
+ let [define, pattern, importMetaEnvVal] = ssr ? ssrPattern : defaultPattern;
47320
47254
  if (!pattern) return;
47321
47255
  pattern.lastIndex = 0;
47322
47256
  if (!pattern.test(code)) return;
47257
+ const hasDefineImportMetaEnv = "import.meta.env" in define;
47258
+ let marker = importMetaEnvMarker;
47259
+ if (hasDefineImportMetaEnv && code.includes(marker)) {
47260
+ let i = 1;
47261
+ do {
47262
+ marker = importMetaEnvMarker + i++;
47263
+ } while (code.includes(marker));
47264
+ if (marker !== importMetaEnvMarker) {
47265
+ define = { ...define, "import.meta.env": marker };
47266
+ }
47267
+ }
47323
47268
  const result = await replaceDefine(code, id, define, config);
47324
- result.code = result.code.replaceAll(
47325
- importMetaEnvKeyRe,
47326
- (m) => "undefined".padEnd(m.length)
47327
- );
47328
- if (bareImportMetaEnvRe.test(result.code)) {
47329
- result.code = banner + result.code;
47330
- if (result.map) {
47331
- const map = JSON.parse(result.map);
47332
- map.mappings = ";" + map.mappings;
47333
- result.map = map;
47269
+ if (hasDefineImportMetaEnv) {
47270
+ result.code = result.code.replaceAll(
47271
+ getImportMetaEnvKeyRe(marker),
47272
+ (m) => "undefined".padEnd(m.length)
47273
+ );
47274
+ if (result.code.includes(marker)) {
47275
+ result.code = `const ${marker} = ${importMetaEnvVal};
47276
+ ` + result.code;
47277
+ if (result.map) {
47278
+ const map = JSON.parse(result.map);
47279
+ map.mappings = ";" + map.mappings;
47280
+ result.map = map;
47281
+ }
47334
47282
  }
47335
47283
  }
47336
47284
  return result;
@@ -47386,6 +47334,14 @@ function handleDefineValue(value) {
47386
47334
  if (typeof value === "string") return value;
47387
47335
  return JSON.stringify(value);
47388
47336
  }
47337
+ function getImportMetaEnvKeyRe(marker) {
47338
+ let re = importMetaEnvKeyReCache.get(marker);
47339
+ if (!re) {
47340
+ re = new RegExp(`${marker}\\..+?\\b`, "g");
47341
+ importMetaEnvKeyReCache.set(marker, re);
47342
+ }
47343
+ return re;
47344
+ }
47389
47345
 
47390
47346
  const normalizedClientEntry = normalizePath$3(CLIENT_ENTRY);
47391
47347
  const normalizedEnvEntry = normalizePath$3(ENV_ENTRY);
@@ -47710,7 +47666,7 @@ function webWorkerPlugin(config) {
47710
47666
  }
47711
47667
  if (injectEnv) {
47712
47668
  const s = new MagicString(raw);
47713
- s.prepend(injectEnv);
47669
+ s.prepend(injectEnv + ";\n");
47714
47670
  return {
47715
47671
  code: s.toString(),
47716
47672
  map: s.generateMap({ hires: "boundary" })
@@ -47729,7 +47685,7 @@ function webWorkerPlugin(config) {
47729
47685
  }`;
47730
47686
  let urlCode;
47731
47687
  if (isBuild) {
47732
- if (isWorker && this.getModuleInfo(cleanUrl(id))?.isEntry) {
47688
+ if (isWorker && config.bundleChain.at(-1) === cleanUrl(id)) {
47733
47689
  urlCode = "self.location.href";
47734
47690
  } else if (inlineRE.test(id)) {
47735
47691
  const chunk = await bundleWorkerEntry(config, id);
@@ -48058,7 +48014,7 @@ function workerImportMetaUrlPlugin(config) {
48058
48014
  file = await workerResolver(url, id);
48059
48015
  file ??= url[0] === "/" ? slash$1(path$n.join(config.publicDir, url)) : slash$1(path$n.resolve(path$n.dirname(id), url));
48060
48016
  }
48061
- if (isBuild && config.isWorker && this.getModuleInfo(cleanUrl(file))?.isEntry) {
48017
+ if (isBuild && config.isWorker && config.bundleChain.at(-1) === cleanUrl(file)) {
48062
48018
  s.update(expStart, expEnd, "self.location.href");
48063
48019
  } else {
48064
48020
  let builtUrl;
@@ -52342,42 +52298,49 @@ Contents of line ${line}: ${code.split("\n")[line - 1]}`
52342
52298
  Object.defineProperty(${ssrModuleExportsKey}, "${name}", { enumerable: true, configurable: true, get(){ return ${local} }});`
52343
52299
  );
52344
52300
  }
52301
+ const imports = [];
52302
+ const exports = [];
52345
52303
  for (const node of ast.body) {
52346
52304
  if (node.type === "ImportDeclaration") {
52347
- const importId = defineImport(hoistIndex, node.source.value, {
52348
- importedNames: node.specifiers.map((s2) => {
52349
- if (s2.type === "ImportSpecifier")
52350
- return s2.imported.type === "Identifier" ? s2.imported.name : (
52351
- // @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet
52352
- s2.imported.value
52353
- );
52354
- else if (s2.type === "ImportDefaultSpecifier") return "default";
52355
- }).filter(isDefined)
52356
- });
52357
- s.remove(node.start, node.end);
52358
- for (const spec of node.specifiers) {
52359
- if (spec.type === "ImportSpecifier") {
52360
- if (spec.imported.type === "Identifier") {
52361
- idToImportMap.set(
52362
- spec.local.name,
52363
- `${importId}.${spec.imported.name}`
52364
- );
52365
- } else {
52366
- idToImportMap.set(
52367
- spec.local.name,
52368
- `${importId}[${// @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet
52369
- JSON.stringify(spec.imported.value)}]`
52370
- );
52371
- }
52372
- } else if (spec.type === "ImportDefaultSpecifier") {
52373
- idToImportMap.set(spec.local.name, `${importId}.default`);
52305
+ imports.push(node);
52306
+ } else if (node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportAllDeclaration") {
52307
+ exports.push(node);
52308
+ }
52309
+ }
52310
+ for (const node of imports) {
52311
+ const importId = defineImport(hoistIndex, node.source.value, {
52312
+ importedNames: node.specifiers.map((s2) => {
52313
+ if (s2.type === "ImportSpecifier")
52314
+ return s2.imported.type === "Identifier" ? s2.imported.name : (
52315
+ // @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet
52316
+ s2.imported.value
52317
+ );
52318
+ else if (s2.type === "ImportDefaultSpecifier") return "default";
52319
+ }).filter(isDefined)
52320
+ });
52321
+ s.remove(node.start, node.end);
52322
+ for (const spec of node.specifiers) {
52323
+ if (spec.type === "ImportSpecifier") {
52324
+ if (spec.imported.type === "Identifier") {
52325
+ idToImportMap.set(
52326
+ spec.local.name,
52327
+ `${importId}.${spec.imported.name}`
52328
+ );
52374
52329
  } else {
52375
- idToImportMap.set(spec.local.name, importId);
52330
+ idToImportMap.set(
52331
+ spec.local.name,
52332
+ `${importId}[${// @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet
52333
+ JSON.stringify(spec.imported.value)}]`
52334
+ );
52376
52335
  }
52336
+ } else if (spec.type === "ImportDefaultSpecifier") {
52337
+ idToImportMap.set(spec.local.name, `${importId}.default`);
52338
+ } else {
52339
+ idToImportMap.set(spec.local.name, importId);
52377
52340
  }
52378
52341
  }
52379
52342
  }
52380
- for (const node of ast.body) {
52343
+ for (const node of exports) {
52381
52344
  if (node.type === "ExportNamedDeclaration") {
52382
52345
  if (node.declaration) {
52383
52346
  if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
@@ -52771,13 +52734,13 @@ function ssrFixStacktrace(e, moduleGraph) {
52771
52734
  const pendingModules = /* @__PURE__ */ new Map();
52772
52735
  const pendingModuleDependencyGraph = /* @__PURE__ */ new Map();
52773
52736
  const importErrors = /* @__PURE__ */ new WeakMap();
52774
- async function ssrLoadModule(url, server, context = { global }, fixStacktrace) {
52737
+ async function ssrLoadModule(url, server, fixStacktrace) {
52775
52738
  url = unwrapId$1(url);
52776
52739
  const pending = pendingModules.get(url);
52777
52740
  if (pending) {
52778
52741
  return pending;
52779
52742
  }
52780
- const modulePromise = instantiateModule(url, server, context, fixStacktrace);
52743
+ const modulePromise = instantiateModule(url, server, fixStacktrace);
52781
52744
  pendingModules.set(url, modulePromise);
52782
52745
  modulePromise.catch(() => {
52783
52746
  }).finally(() => {
@@ -52785,7 +52748,7 @@ async function ssrLoadModule(url, server, context = { global }, fixStacktrace) {
52785
52748
  });
52786
52749
  return modulePromise;
52787
52750
  }
52788
- async function instantiateModule(url, server, context = { global }, fixStacktrace) {
52751
+ async function instantiateModule(url, server, fixStacktrace) {
52789
52752
  const { moduleGraph } = server;
52790
52753
  const mod = await moduleGraph.ensureEntryFromUrl(url, true);
52791
52754
  if (mod.ssrError) {
@@ -52849,7 +52812,7 @@ async function instantiateModule(url, server, context = { global }, fixStacktrac
52849
52812
  return depSsrModule;
52850
52813
  }
52851
52814
  }
52852
- return ssrLoadModule(dep, server, context, fixStacktrace);
52815
+ return ssrLoadModule(dep, server, fixStacktrace);
52853
52816
  } catch (err) {
52854
52817
  importErrors.set(err, { importee: dep });
52855
52818
  throw err;
@@ -52884,7 +52847,6 @@ async function instantiateModule(url, server, context = { global }, fixStacktrac
52884
52847
  }
52885
52848
  try {
52886
52849
  const initModule = new AsyncFunction(
52887
- `global`,
52888
52850
  ssrModuleExportsKey,
52889
52851
  ssrImportMetaKey,
52890
52852
  ssrImportKey,
@@ -52894,7 +52856,6 @@ async function instantiateModule(url, server, context = { global }, fixStacktrac
52894
52856
  //# sourceURL=${mod.id}${sourceMapSuffix}`
52895
52857
  );
52896
52858
  await initModule(
52897
- context.global,
52898
52859
  ssrModule,
52899
52860
  ssrImportMeta,
52900
52861
  ssrImport,
@@ -54281,10 +54242,10 @@ function resolveEmptyOutDir(emptyOutDir, root, outDirs, logger) {
54281
54242
  for (const outDir of outDirs) {
54282
54243
  if (!normalizePath$3(outDir).startsWith(withTrailingSlash(root))) {
54283
54244
  logger?.warn(
54284
- picocolorsExports.yellow(
54245
+ colors$1.yellow(
54285
54246
  `
54286
- ${picocolorsExports.bold(`(!)`)} outDir ${picocolorsExports.white(
54287
- picocolorsExports.dim(outDir)
54247
+ ${colors$1.bold(`(!)`)} outDir ${colors$1.white(
54248
+ colors$1.dim(outDir)
54288
54249
  )} is not inside project root and will not be emptied.
54289
54250
  Use --emptyOutDir to override.
54290
54251
  `
@@ -62779,7 +62740,7 @@ async function _createServer(inlineConfig = {}, options) {
62779
62740
  return devHtmlTransformFn(server, url, html, originalUrl);
62780
62741
  },
62781
62742
  async ssrLoadModule(url, opts) {
62782
- return ssrLoadModule(url, server, void 0, opts?.fixStacktrace);
62743
+ return ssrLoadModule(url, server, opts?.fixStacktrace);
62783
62744
  },
62784
62745
  async ssrFetchModule(url, importer) {
62785
62746
  return ssrFetchModule(server, url, importer);
@@ -64518,17 +64479,15 @@ function buildImportAnalysisPlugin(config) {
64518
64479
  const ssr = !!config.build.ssr;
64519
64480
  const isWorker = config.isWorker;
64520
64481
  const insertPreload = !(ssr || !!config.build.lib || isWorker);
64521
- const resolveModulePreloadDependencies = config.build.modulePreload && config.build.modulePreload.resolveDependencies;
64522
64482
  const renderBuiltUrl = config.experimental.renderBuiltUrl;
64523
- const customModulePreloadPaths = !!(resolveModulePreloadDependencies || renderBuiltUrl);
64524
64483
  const isRelativeBase = config.base === "./" || config.base === "";
64525
- const optimizeModulePreloadRelativePaths = isRelativeBase && !customModulePreloadPaths;
64484
+ const optimizeModulePreloadRelativePaths = isRelativeBase && !renderBuiltUrl;
64526
64485
  const { modulePreload } = config.build;
64527
64486
  const scriptRel2 = modulePreload && modulePreload.polyfill ? `'modulepreload'` : `(${detectScriptRel.toString()})()`;
64528
- const assetsURL2 = customModulePreloadPaths ? (
64529
- // If `experimental.renderBuiltUrl` or `build.modulePreload.resolveDependencies` are used
64530
- // the dependencies are already resolved. To avoid the need for `new URL(dep, import.meta.url)`
64531
- // a helper `__vitePreloadRelativeDep` is used to resolve from relative paths which can be minimized.
64487
+ const assetsURL2 = renderBuiltUrl ? (
64488
+ // If `experimental.renderBuiltUrl` is used, the dependencies are already resolved.
64489
+ // To avoid the need for `new URL(dep, import.meta.url)`, a helper `__vitePreloadRelativeDep` is
64490
+ // used to resolve from relative paths which can be minimized.
64532
64491
  `function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }`
64533
64492
  ) : optimizeModulePreloadRelativePaths ? (
64534
64493
  // If there isn't custom resolvers affecting the deps list, deps in the list are relative
@@ -64626,7 +64585,7 @@ function buildImportAnalysisPlugin(config) {
64626
64585
  }
64627
64586
  str().appendRight(
64628
64587
  expEnd,
64629
- `,${isModernFlag}?${preloadMarker}:void 0${optimizeModulePreloadRelativePaths || customModulePreloadPaths ? ",import.meta.url" : ""})`
64588
+ `,${isModernFlag}?${preloadMarker}:void 0${optimizeModulePreloadRelativePaths || renderBuiltUrl ? ",import.meta.url" : ""})`
64630
64589
  );
64631
64590
  }
64632
64591
  }
@@ -64807,34 +64766,30 @@ function buildImportAnalysisPlugin(config) {
64807
64766
  markerStartPos2 = indexOfMatchInSlice(code, preloadMarkerRE);
64808
64767
  }
64809
64768
  if (markerStartPos2 > 0) {
64810
- const depsArray = deps.size > 1 || // main chunk is removed
64769
+ let depsArray = deps.size > 1 || // main chunk is removed
64811
64770
  hasRemovedPureCssChunk && deps.size > 0 ? modulePreload === false ? (
64812
64771
  // CSS deps use the same mechanism as module preloads, so even if disabled,
64813
64772
  // we still need to pass these deps to the preload helper in dynamic imports.
64814
64773
  [...deps].filter((d) => d.endsWith(".css"))
64815
64774
  ) : [...deps] : [];
64816
- let renderedDeps;
64817
- if (normalizedFile && customModulePreloadPaths) {
64818
- const { modulePreload: modulePreload2 } = config.build;
64819
- const resolveDependencies = modulePreload2 ? modulePreload2.resolveDependencies : void 0;
64820
- let resolvedDeps;
64821
- if (resolveDependencies) {
64822
- const cssDeps = [];
64823
- const otherDeps = [];
64824
- for (const dep of depsArray) {
64825
- (dep.endsWith(".css") ? cssDeps : otherDeps).push(dep);
64826
- }
64827
- resolvedDeps = [
64828
- ...resolveDependencies(normalizedFile, otherDeps, {
64829
- hostId: file,
64830
- hostType: "js"
64831
- }),
64832
- ...cssDeps
64833
- ];
64834
- } else {
64835
- resolvedDeps = depsArray;
64775
+ const resolveDependencies = modulePreload ? modulePreload.resolveDependencies : void 0;
64776
+ if (resolveDependencies && normalizedFile) {
64777
+ const cssDeps = [];
64778
+ const otherDeps = [];
64779
+ for (const dep of depsArray) {
64780
+ (dep.endsWith(".css") ? cssDeps : otherDeps).push(dep);
64836
64781
  }
64837
- renderedDeps = resolvedDeps.map((dep) => {
64782
+ depsArray = [
64783
+ ...resolveDependencies(normalizedFile, otherDeps, {
64784
+ hostId: file,
64785
+ hostType: "js"
64786
+ }),
64787
+ ...cssDeps
64788
+ ];
64789
+ }
64790
+ let renderedDeps;
64791
+ if (renderBuiltUrl) {
64792
+ renderedDeps = depsArray.map((dep) => {
64838
64793
  const replacement = toOutputFilePathInJS(
64839
64794
  dep,
64840
64795
  "asset",