vite 5.0.9 → 5.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
@@ -2186,6 +2186,35 @@ Repository: git+https://github.com/isaacs/isexe.git
2186
2186
 
2187
2187
  ---------------------------------------
2188
2188
 
2189
+ ## js-tokens
2190
+ License: MIT
2191
+ By: Simon Lydell
2192
+ Repository: lydell/js-tokens
2193
+
2194
+ > The MIT License (MIT)
2195
+ >
2196
+ > Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
2197
+ >
2198
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
2199
+ > of this software and associated documentation files (the "Software"), to deal
2200
+ > in the Software without restriction, including without limitation the rights
2201
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2202
+ > copies of the Software, and to permit persons to whom the Software is
2203
+ > furnished to do so, subject to the following conditions:
2204
+ >
2205
+ > The above copyright notice and this permission notice shall be included in
2206
+ > all copies or substantial portions of the Software.
2207
+ >
2208
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2209
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2210
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2211
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2212
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2213
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2214
+ > THE SOFTWARE.
2215
+
2216
+ ---------------------------------------
2217
+
2189
2218
  ## json-stable-stringify
2190
2219
  License: MIT
2191
2220
  By: James Halliday
@@ -12552,10 +12552,10 @@ function processSrcSetSync(srcs, replacer) {
12552
12552
  descriptor,
12553
12553
  })));
12554
12554
  }
12555
- const cleanSrcSetRE = /(?:url|image|gradient|cross-fade)\([^)]*\)|"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'/g;
12555
+ const cleanSrcSetRE = /(?:url|image|gradient|cross-fade)\([^)]*\)|"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|data:\w+\/[\w.+\-]+;base64,[\w+/=]+/g;
12556
12556
  function splitSrcSet(srcs) {
12557
12557
  const parts = [];
12558
- // There could be a ',' inside of url(data:...), linear-gradient(...) or "data:..."
12558
+ // There could be a ',' inside of url(data:...), linear-gradient(...), "data:..." or data:...
12559
12559
  const cleanedSrcs = srcs.replace(cleanSrcSetRE, blankReplacer);
12560
12560
  let startIndex = 0;
12561
12561
  let splitIndex;
@@ -12742,8 +12742,8 @@ function arraify(target) {
12742
12742
  return Array.isArray(target) ? target : [target];
12743
12743
  }
12744
12744
  // Taken from https://stackoverflow.com/a/36328890
12745
- const multilineCommentsRE$1 = /\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g;
12746
- const singlelineCommentsRE$1 = /\/\/.*/g;
12745
+ const multilineCommentsRE = /\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g;
12746
+ const singlelineCommentsRE = /\/\/.*/g;
12747
12747
  const requestQuerySplitRE = /\?(?!.*[/|}])/;
12748
12748
  const requestQueryMaybeEscapedSplitRE = /\\?\?(?!.*[/|}])/;
12749
12749
  function parseRequest(id) {
@@ -12776,7 +12776,7 @@ const requireResolveFromRootWithFallback = (root, id) => {
12776
12776
  return _require$2.resolve(id, { paths: [root, _dirname] });
12777
12777
  };
12778
12778
  function emptyCssComments(raw) {
12779
- return raw.replace(multilineCommentsRE$1, (s) => ' '.repeat(s.length));
12779
+ return raw.replace(multilineCommentsRE, (s) => ' '.repeat(s.length));
12780
12780
  }
12781
12781
  function backwardCompatibleWorkerPlugins(plugins) {
12782
12782
  if (Array.isArray(plugins)) {
@@ -16739,13 +16739,15 @@ async function urlToBuiltUrl(url, importer, config, pluginContext, shouldInline)
16739
16739
  // skip public check since we just did it above
16740
16740
  true, shouldInline);
16741
16741
  }
16742
+ const nestedQuotesRE = /"[^"']*'[^"]*"|'[^'"]*"[^']*'/;
16742
16743
  // Inspired by https://github.com/iconify/iconify/blob/main/packages/utils/src/svg/url.ts
16743
16744
  function svgToDataURL(content) {
16744
16745
  const stringContent = content.toString();
16745
16746
  // If the SVG contains some text or HTML, any transformation is unsafe, and given that double quotes would then
16746
16747
  // need to be escaped, the gain to use a data URI would be ridiculous if not negative
16747
16748
  if (stringContent.includes('<text') ||
16748
- stringContent.includes('<foreignObject')) {
16749
+ stringContent.includes('<foreignObject') ||
16750
+ nestedQuotesRE.test(stringContent)) {
16749
16751
  return `data:image/svg+xml;base64,${content.toString('base64')}`;
16750
16752
  }
16751
16753
  else {
@@ -27875,13 +27877,6 @@ function parseExpressionAt(input, pos, options) {
27875
27877
  return Parser$1.parseExpressionAt(input, pos, options)
27876
27878
  }
27877
27879
 
27878
- // Acorn is organized as a tokenizer and a recursive-descent parser.
27879
- // The `tokenizer` export provides an interface to the tokenizer.
27880
-
27881
- function tokenizer(input, options) {
27882
- return Parser$1.tokenizer(input, options)
27883
- }
27884
-
27885
27880
  const HASH_RE = /#/g;
27886
27881
  const AMPERSAND_RE = /&/g;
27887
27882
  const EQUAL_RE = /=/g;
@@ -37615,112 +37610,468 @@ var src$1 = rc;
37615
37610
 
37616
37611
  var postcssrc = /*@__PURE__*/getDefaultExportFromCjs(src$1);
37617
37612
 
37618
- function _stripLiteralAcorn(code, options) {
37613
+ // Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
37614
+ // License: MIT.
37615
+ var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
37616
+ RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\\]).|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
37617
+ Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
37618
+ Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
37619
+ StringLiteral = /(['"])(?:(?!\1)[^\\\n\r]|\\(?:\r\n|[^]))*(\1)?/y;
37620
+ NumericLiteral = /(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|0n|[1-9](?:_?\d)*n|(?:(?:0(?!\d)|0\d*[89]\d*|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?|0[0-7]+/y;
37621
+ Template = /[`}](?:[^`\\$]|\\[^]|\$(?!\{))*(`|\$\{)?/y;
37622
+ WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/yu;
37623
+ LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
37624
+ MultiLineComment = /\/\*(?:[^*]|\*(?!\/))*(\*\/)?/y;
37625
+ SingleLineComment = /\/\/.*/y;
37626
+ JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
37627
+ JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/yu;
37628
+ JSXString = /(['"])(?:(?!\1)[^])*(\1)?/y;
37629
+ JSXText = /[^<>{}]+/y;
37630
+ TokensPrecedingExpression = /^(?:[\/+-]|\.{3}|\?(?:InterpolationIn(?:JSX|Template)|NoLineTerminatorHere|NonExpressionParenEnd|UnaryIncDec))?$|[{}([,;<>=*%&|^!~?:]$/;
37631
+ TokensNotPrecedingObjectLiteral = /^(?:=>|[;\]){}]|else|\?(?:NoLineTerminatorHere|NonExpressionParenEnd))?$/;
37632
+ KeywordsWithExpressionAfter = /^(?:await|case|default|delete|do|else|instanceof|new|return|throw|typeof|void|yield)$/;
37633
+ KeywordsWithNoLineTerminatorAfter = /^(?:return|throw|yield)$/;
37634
+ Newline = RegExp(LineTerminatorSequence.source);
37635
+ var jsTokens_1 = function*(input, {jsx = false} = {}) {
37636
+ var braces, firstCodePoint, isExpression, lastIndex, lastSignificantToken, length, match, mode, nextLastIndex, nextLastSignificantToken, parenNesting, postfixIncDec, punctuator, stack;
37637
+ ({length} = input);
37638
+ lastIndex = 0;
37639
+ lastSignificantToken = "";
37640
+ stack = [
37641
+ {tag: "JS"}
37642
+ ];
37643
+ braces = [];
37644
+ parenNesting = 0;
37645
+ postfixIncDec = false;
37646
+ while (lastIndex < length) {
37647
+ mode = stack[stack.length - 1];
37648
+ switch (mode.tag) {
37649
+ case "JS":
37650
+ case "JSNonExpressionParen":
37651
+ case "InterpolationInTemplate":
37652
+ case "InterpolationInJSX":
37653
+ if (input[lastIndex] === "/" && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
37654
+ RegularExpressionLiteral.lastIndex = lastIndex;
37655
+ if (match = RegularExpressionLiteral.exec(input)) {
37656
+ lastIndex = RegularExpressionLiteral.lastIndex;
37657
+ lastSignificantToken = match[0];
37658
+ postfixIncDec = true;
37659
+ yield ({
37660
+ type: "RegularExpressionLiteral",
37661
+ value: match[0],
37662
+ closed: match[1] !== void 0 && match[1] !== "\\"
37663
+ });
37664
+ continue;
37665
+ }
37666
+ }
37667
+ Punctuator.lastIndex = lastIndex;
37668
+ if (match = Punctuator.exec(input)) {
37669
+ punctuator = match[0];
37670
+ nextLastIndex = Punctuator.lastIndex;
37671
+ nextLastSignificantToken = punctuator;
37672
+ switch (punctuator) {
37673
+ case "(":
37674
+ if (lastSignificantToken === "?NonExpressionParenKeyword") {
37675
+ stack.push({
37676
+ tag: "JSNonExpressionParen",
37677
+ nesting: parenNesting
37678
+ });
37679
+ }
37680
+ parenNesting++;
37681
+ postfixIncDec = false;
37682
+ break;
37683
+ case ")":
37684
+ parenNesting--;
37685
+ postfixIncDec = true;
37686
+ if (mode.tag === "JSNonExpressionParen" && parenNesting === mode.nesting) {
37687
+ stack.pop();
37688
+ nextLastSignificantToken = "?NonExpressionParenEnd";
37689
+ postfixIncDec = false;
37690
+ }
37691
+ break;
37692
+ case "{":
37693
+ Punctuator.lastIndex = 0;
37694
+ isExpression = !TokensNotPrecedingObjectLiteral.test(lastSignificantToken) && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken));
37695
+ braces.push(isExpression);
37696
+ postfixIncDec = false;
37697
+ break;
37698
+ case "}":
37699
+ switch (mode.tag) {
37700
+ case "InterpolationInTemplate":
37701
+ if (braces.length === mode.nesting) {
37702
+ Template.lastIndex = lastIndex;
37703
+ match = Template.exec(input);
37704
+ lastIndex = Template.lastIndex;
37705
+ lastSignificantToken = match[0];
37706
+ if (match[1] === "${") {
37707
+ lastSignificantToken = "?InterpolationInTemplate";
37708
+ postfixIncDec = false;
37709
+ yield ({
37710
+ type: "TemplateMiddle",
37711
+ value: match[0]
37712
+ });
37713
+ } else {
37714
+ stack.pop();
37715
+ postfixIncDec = true;
37716
+ yield ({
37717
+ type: "TemplateTail",
37718
+ value: match[0],
37719
+ closed: match[1] === "`"
37720
+ });
37721
+ }
37722
+ continue;
37723
+ }
37724
+ break;
37725
+ case "InterpolationInJSX":
37726
+ if (braces.length === mode.nesting) {
37727
+ stack.pop();
37728
+ lastIndex += 1;
37729
+ lastSignificantToken = "}";
37730
+ yield ({
37731
+ type: "JSXPunctuator",
37732
+ value: "}"
37733
+ });
37734
+ continue;
37735
+ }
37736
+ }
37737
+ postfixIncDec = braces.pop();
37738
+ nextLastSignificantToken = postfixIncDec ? "?ExpressionBraceEnd" : "}";
37739
+ break;
37740
+ case "]":
37741
+ postfixIncDec = true;
37742
+ break;
37743
+ case "++":
37744
+ case "--":
37745
+ nextLastSignificantToken = postfixIncDec ? "?PostfixIncDec" : "?UnaryIncDec";
37746
+ break;
37747
+ case "<":
37748
+ if (jsx && (TokensPrecedingExpression.test(lastSignificantToken) || KeywordsWithExpressionAfter.test(lastSignificantToken))) {
37749
+ stack.push({tag: "JSXTag"});
37750
+ lastIndex += 1;
37751
+ lastSignificantToken = "<";
37752
+ yield ({
37753
+ type: "JSXPunctuator",
37754
+ value: punctuator
37755
+ });
37756
+ continue;
37757
+ }
37758
+ postfixIncDec = false;
37759
+ break;
37760
+ default:
37761
+ postfixIncDec = false;
37762
+ }
37763
+ lastIndex = nextLastIndex;
37764
+ lastSignificantToken = nextLastSignificantToken;
37765
+ yield ({
37766
+ type: "Punctuator",
37767
+ value: punctuator
37768
+ });
37769
+ continue;
37770
+ }
37771
+ Identifier.lastIndex = lastIndex;
37772
+ if (match = Identifier.exec(input)) {
37773
+ lastIndex = Identifier.lastIndex;
37774
+ nextLastSignificantToken = match[0];
37775
+ switch (match[0]) {
37776
+ case "for":
37777
+ case "if":
37778
+ case "while":
37779
+ case "with":
37780
+ if (lastSignificantToken !== "." && lastSignificantToken !== "?.") {
37781
+ nextLastSignificantToken = "?NonExpressionParenKeyword";
37782
+ }
37783
+ }
37784
+ lastSignificantToken = nextLastSignificantToken;
37785
+ postfixIncDec = !KeywordsWithExpressionAfter.test(match[0]);
37786
+ yield ({
37787
+ type: match[1] === "#" ? "PrivateIdentifier" : "IdentifierName",
37788
+ value: match[0]
37789
+ });
37790
+ continue;
37791
+ }
37792
+ StringLiteral.lastIndex = lastIndex;
37793
+ if (match = StringLiteral.exec(input)) {
37794
+ lastIndex = StringLiteral.lastIndex;
37795
+ lastSignificantToken = match[0];
37796
+ postfixIncDec = true;
37797
+ yield ({
37798
+ type: "StringLiteral",
37799
+ value: match[0],
37800
+ closed: match[2] !== void 0
37801
+ });
37802
+ continue;
37803
+ }
37804
+ NumericLiteral.lastIndex = lastIndex;
37805
+ if (match = NumericLiteral.exec(input)) {
37806
+ lastIndex = NumericLiteral.lastIndex;
37807
+ lastSignificantToken = match[0];
37808
+ postfixIncDec = true;
37809
+ yield ({
37810
+ type: "NumericLiteral",
37811
+ value: match[0]
37812
+ });
37813
+ continue;
37814
+ }
37815
+ Template.lastIndex = lastIndex;
37816
+ if (match = Template.exec(input)) {
37817
+ lastIndex = Template.lastIndex;
37818
+ lastSignificantToken = match[0];
37819
+ if (match[1] === "${") {
37820
+ lastSignificantToken = "?InterpolationInTemplate";
37821
+ stack.push({
37822
+ tag: "InterpolationInTemplate",
37823
+ nesting: braces.length
37824
+ });
37825
+ postfixIncDec = false;
37826
+ yield ({
37827
+ type: "TemplateHead",
37828
+ value: match[0]
37829
+ });
37830
+ } else {
37831
+ postfixIncDec = true;
37832
+ yield ({
37833
+ type: "NoSubstitutionTemplate",
37834
+ value: match[0],
37835
+ closed: match[1] === "`"
37836
+ });
37837
+ }
37838
+ continue;
37839
+ }
37840
+ break;
37841
+ case "JSXTag":
37842
+ case "JSXTagEnd":
37843
+ JSXPunctuator.lastIndex = lastIndex;
37844
+ if (match = JSXPunctuator.exec(input)) {
37845
+ lastIndex = JSXPunctuator.lastIndex;
37846
+ nextLastSignificantToken = match[0];
37847
+ switch (match[0]) {
37848
+ case "<":
37849
+ stack.push({tag: "JSXTag"});
37850
+ break;
37851
+ case ">":
37852
+ stack.pop();
37853
+ if (lastSignificantToken === "/" || mode.tag === "JSXTagEnd") {
37854
+ nextLastSignificantToken = "?JSX";
37855
+ postfixIncDec = true;
37856
+ } else {
37857
+ stack.push({tag: "JSXChildren"});
37858
+ }
37859
+ break;
37860
+ case "{":
37861
+ stack.push({
37862
+ tag: "InterpolationInJSX",
37863
+ nesting: braces.length
37864
+ });
37865
+ nextLastSignificantToken = "?InterpolationInJSX";
37866
+ postfixIncDec = false;
37867
+ break;
37868
+ case "/":
37869
+ if (lastSignificantToken === "<") {
37870
+ stack.pop();
37871
+ if (stack[stack.length - 1].tag === "JSXChildren") {
37872
+ stack.pop();
37873
+ }
37874
+ stack.push({tag: "JSXTagEnd"});
37875
+ }
37876
+ }
37877
+ lastSignificantToken = nextLastSignificantToken;
37878
+ yield ({
37879
+ type: "JSXPunctuator",
37880
+ value: match[0]
37881
+ });
37882
+ continue;
37883
+ }
37884
+ JSXIdentifier.lastIndex = lastIndex;
37885
+ if (match = JSXIdentifier.exec(input)) {
37886
+ lastIndex = JSXIdentifier.lastIndex;
37887
+ lastSignificantToken = match[0];
37888
+ yield ({
37889
+ type: "JSXIdentifier",
37890
+ value: match[0]
37891
+ });
37892
+ continue;
37893
+ }
37894
+ JSXString.lastIndex = lastIndex;
37895
+ if (match = JSXString.exec(input)) {
37896
+ lastIndex = JSXString.lastIndex;
37897
+ lastSignificantToken = match[0];
37898
+ yield ({
37899
+ type: "JSXString",
37900
+ value: match[0],
37901
+ closed: match[2] !== void 0
37902
+ });
37903
+ continue;
37904
+ }
37905
+ break;
37906
+ case "JSXChildren":
37907
+ JSXText.lastIndex = lastIndex;
37908
+ if (match = JSXText.exec(input)) {
37909
+ lastIndex = JSXText.lastIndex;
37910
+ lastSignificantToken = match[0];
37911
+ yield ({
37912
+ type: "JSXText",
37913
+ value: match[0]
37914
+ });
37915
+ continue;
37916
+ }
37917
+ switch (input[lastIndex]) {
37918
+ case "<":
37919
+ stack.push({tag: "JSXTag"});
37920
+ lastIndex++;
37921
+ lastSignificantToken = "<";
37922
+ yield ({
37923
+ type: "JSXPunctuator",
37924
+ value: "<"
37925
+ });
37926
+ continue;
37927
+ case "{":
37928
+ stack.push({
37929
+ tag: "InterpolationInJSX",
37930
+ nesting: braces.length
37931
+ });
37932
+ lastIndex++;
37933
+ lastSignificantToken = "?InterpolationInJSX";
37934
+ postfixIncDec = false;
37935
+ yield ({
37936
+ type: "JSXPunctuator",
37937
+ value: "{"
37938
+ });
37939
+ continue;
37940
+ }
37941
+ }
37942
+ WhiteSpace.lastIndex = lastIndex;
37943
+ if (match = WhiteSpace.exec(input)) {
37944
+ lastIndex = WhiteSpace.lastIndex;
37945
+ yield ({
37946
+ type: "WhiteSpace",
37947
+ value: match[0]
37948
+ });
37949
+ continue;
37950
+ }
37951
+ LineTerminatorSequence.lastIndex = lastIndex;
37952
+ if (match = LineTerminatorSequence.exec(input)) {
37953
+ lastIndex = LineTerminatorSequence.lastIndex;
37954
+ postfixIncDec = false;
37955
+ if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
37956
+ lastSignificantToken = "?NoLineTerminatorHere";
37957
+ }
37958
+ yield ({
37959
+ type: "LineTerminatorSequence",
37960
+ value: match[0]
37961
+ });
37962
+ continue;
37963
+ }
37964
+ MultiLineComment.lastIndex = lastIndex;
37965
+ if (match = MultiLineComment.exec(input)) {
37966
+ lastIndex = MultiLineComment.lastIndex;
37967
+ if (Newline.test(match[0])) {
37968
+ postfixIncDec = false;
37969
+ if (KeywordsWithNoLineTerminatorAfter.test(lastSignificantToken)) {
37970
+ lastSignificantToken = "?NoLineTerminatorHere";
37971
+ }
37972
+ }
37973
+ yield ({
37974
+ type: "MultiLineComment",
37975
+ value: match[0],
37976
+ closed: match[1] !== void 0
37977
+ });
37978
+ continue;
37979
+ }
37980
+ SingleLineComment.lastIndex = lastIndex;
37981
+ if (match = SingleLineComment.exec(input)) {
37982
+ lastIndex = SingleLineComment.lastIndex;
37983
+ postfixIncDec = false;
37984
+ yield ({
37985
+ type: "SingleLineComment",
37986
+ value: match[0]
37987
+ });
37988
+ continue;
37989
+ }
37990
+ firstCodePoint = String.fromCodePoint(input.codePointAt(lastIndex));
37991
+ lastIndex += firstCodePoint.length;
37992
+ lastSignificantToken = firstCodePoint;
37993
+ postfixIncDec = false;
37994
+ yield ({
37995
+ type: mode.tag.startsWith("JSX") ? "JSXInvalid" : "Invalid",
37996
+ value: firstCodePoint
37997
+ });
37998
+ }
37999
+ return void 0;
38000
+ };
38001
+
38002
+ var jsTokens = /*@__PURE__*/getDefaultExportFromCjs(jsTokens_1);
38003
+
38004
+ function stripLiteralJsTokens(code, options) {
37619
38005
  const FILL = options?.fillChar ?? " ";
37620
38006
  const FILL_COMMENT = " ";
37621
38007
  let result = "";
37622
38008
  const filter = options?.filter ?? (() => true);
37623
- function fillupTo(index) {
37624
- if (index > result.length)
37625
- result += code.slice(result.length, index).replace(/[^\n]/g, FILL_COMMENT);
37626
- }
37627
38009
  const tokens = [];
37628
- const pasers = tokenizer(code, {
37629
- ecmaVersion: "latest",
37630
- sourceType: "module",
37631
- allowHashBang: true,
37632
- allowAwaitOutsideFunction: true,
37633
- allowImportExportEverywhere: true
37634
- });
37635
- const iter = pasers[Symbol.iterator]();
37636
- let error;
37637
- try {
37638
- while (true) {
37639
- const { done, value: token } = iter.next();
37640
- if (done)
37641
- break;
37642
- tokens.push(token);
37643
- fillupTo(token.start);
37644
- if (token.type.label === "string") {
37645
- const body = code.slice(token.start + 1, token.end - 1);
37646
- if (filter(body)) {
37647
- result += code[token.start] + FILL.repeat(token.end - token.start - 2) + code[token.end - 1];
37648
- continue;
37649
- }
37650
- } else if (token.type.label === "template") {
37651
- const body = code.slice(token.start, token.end);
37652
- if (filter(body)) {
37653
- result += FILL.repeat(token.end - token.start);
37654
- continue;
37655
- }
37656
- } else if (token.type.label === "regexp") {
37657
- const body = code.slice(token.start, token.end);
37658
- if (filter(body)) {
37659
- result += body.replace(/\/(.*)\/(\w?)$/g, (_, $1, $2) => `/${FILL.repeat($1.length)}/${$2}`);
37660
- continue;
37661
- }
38010
+ for (const token of jsTokens(code, { jsx: false })) {
38011
+ tokens.push(token);
38012
+ if (token.type === "SingleLineComment") {
38013
+ result += FILL_COMMENT.repeat(token.value.length);
38014
+ continue;
38015
+ }
38016
+ if (token.type === "MultiLineComment") {
38017
+ result += token.value.replace(/[^\n]/g, FILL_COMMENT);
38018
+ continue;
38019
+ }
38020
+ if (token.type === "StringLiteral") {
38021
+ const body = token.value.slice(1, -1);
38022
+ if (filter(body)) {
38023
+ result += token.value[0] + FILL.repeat(body.length) + token.value[token.value.length - 1];
38024
+ continue;
37662
38025
  }
37663
- result += code.slice(token.start, token.end);
37664
38026
  }
37665
- fillupTo(code.length);
37666
- } catch (e) {
37667
- error = e;
38027
+ if (token.type === "NoSubstitutionTemplate") {
38028
+ const body = token.value.slice(1, -1);
38029
+ if (filter(body)) {
38030
+ result += `\`${body.replace(/[^\n]/g, FILL)}\``;
38031
+ continue;
38032
+ }
38033
+ }
38034
+ if (token.type === "RegularExpressionLiteral") {
38035
+ const body = token.value;
38036
+ if (filter(body)) {
38037
+ result += body.replace(/\/(.*)\/(\w?)$/g, (_, $1, $2) => `/${FILL.repeat($1.length)}/${$2}`);
38038
+ continue;
38039
+ }
38040
+ }
38041
+ if (token.type === "TemplateHead") {
38042
+ const body = token.value.slice(1, -2);
38043
+ if (filter(body)) {
38044
+ result += `\`${body.replace(/[^\n]/g, FILL)}\${`;
38045
+ continue;
38046
+ }
38047
+ }
38048
+ if (token.type === "TemplateTail") {
38049
+ const body = token.value.slice(0, -2);
38050
+ if (filter(body)) {
38051
+ result += `}${body.replace(/[^\n]/g, FILL)}\``;
38052
+ continue;
38053
+ }
38054
+ }
38055
+ if (token.type === "TemplateMiddle") {
38056
+ const body = token.value.slice(1, -2);
38057
+ if (filter(body)) {
38058
+ result += `}${body.replace(/[^\n]/g, FILL)}\${`;
38059
+ continue;
38060
+ }
38061
+ }
38062
+ result += token.value;
37668
38063
  }
37669
38064
  return {
37670
- error,
37671
38065
  result,
37672
38066
  tokens
37673
38067
  };
37674
38068
  }
37675
38069
 
37676
- const multilineCommentsRE = /\/\*([^*\/])*?\*\//gms;
37677
- const singlelineCommentsRE = /(?:^|\n|\r)\s*\/\/.*(?:\r|\n|$)/gm;
37678
- const templateLiteralRE$1 = /\$\{(\s*(?:|{.*}|(?!\$\{).|\n|\r)*?\s*)\}/g;
37679
- const quotesRE = [
37680
- /(["'`])((?:\\\1|(?!\1)|.|\r)*?)\1/gm,
37681
- /([`])((?:\\\1|(?!\1)|.|\n|\r)*?)\1/gm
37682
- // multi-line strings (i.e. template literals only)
37683
- ];
37684
- function stripLiteralRegex(code, options) {
37685
- const FILL_COMMENT = " ";
37686
- const FILL = options?.fillChar ?? " ";
37687
- const filter = options?.filter ?? (() => true);
37688
- code = code.replace(multilineCommentsRE, (s) => filter(s) ? FILL_COMMENT.repeat(s.length) : s).replace(singlelineCommentsRE, (s) => filter(s) ? FILL_COMMENT.repeat(s.length) : s);
37689
- let expanded = code;
37690
- for (let i = 0; i < 16; i++) {
37691
- const before = expanded;
37692
- expanded = expanded.replace(templateLiteralRE$1, "` $1`");
37693
- if (expanded === before)
37694
- break;
37695
- }
37696
- quotesRE.forEach((re) => {
37697
- expanded = expanded.replace(re, (s, quote, body, index) => {
37698
- if (!filter(s.slice(1, -1)))
37699
- return s;
37700
- code = code.slice(0, index + 1) + FILL.repeat(s.length - 2) + code.slice(index + s.length - 1);
37701
- return quote + FILL.repeat(s.length - 2) + quote;
37702
- });
37703
- });
37704
- return code;
37705
- }
37706
-
37707
38070
  function stripLiteral(code, options) {
37708
38071
  return stripLiteralDetailed(code, options).result;
37709
38072
  }
37710
38073
  function stripLiteralDetailed(code, options) {
37711
- const acorn = _stripLiteralAcorn(code, options);
37712
- if (!acorn.error) {
37713
- return {
37714
- mode: "acorn",
37715
- result: acorn.result,
37716
- acorn
37717
- };
37718
- }
37719
- return {
37720
- mode: "regex",
37721
- result: stripLiteralRegex(acorn.result + code.slice(acorn.result.length), options),
37722
- acorn
37723
- };
38074
+ return stripLiteralJsTokens(code, options);
37724
38075
  }
37725
38076
 
37726
38077
  var main$1 = {exports: {}};
@@ -38527,13 +38878,12 @@ function buildHtmlPlugin(config) {
38527
38878
  // Determines true start position for the node, either the < character
38528
38879
  // position, or the newline at the end of the previous line's node.
38529
38880
  const nodeStartWithLeadingWhitespace = (node) => {
38530
- if (node.sourceCodeLocation.startOffset === 0)
38531
- return node.sourceCodeLocation.startOffset;
38881
+ const startOffset = node.sourceCodeLocation.startOffset;
38882
+ if (startOffset === 0)
38883
+ return 0;
38532
38884
  // Gets the offset for the start of the line including the
38533
38885
  // newline trailing the previous node
38534
- const lineStartOffset = node.sourceCodeLocation.startOffset -
38535
- node.sourceCodeLocation.startCol;
38536
- const line = s.slice(Math.max(0, lineStartOffset), node.sourceCodeLocation.startOffset);
38886
+ const lineStartOffset = startOffset - node.sourceCodeLocation.startCol;
38537
38887
  // <previous-line-node></previous-line-node>
38538
38888
  // <target-node></target-node>
38539
38889
  //
@@ -38545,9 +38895,16 @@ function buildHtmlPlugin(config) {
38545
38895
  //
38546
38896
  // However, if there is content between our target node start and the
38547
38897
  // previous newline, we cannot strip it out without risking content deletion.
38548
- return line.trim()
38549
- ? node.sourceCodeLocation.startOffset
38550
- : lineStartOffset;
38898
+ let isLineEmpty = false;
38899
+ try {
38900
+ const line = s.slice(Math.max(0, lineStartOffset), startOffset);
38901
+ isLineEmpty = !line.trim();
38902
+ }
38903
+ catch {
38904
+ // magic-string may throw if there's some content removed in the sliced string,
38905
+ // which we ignore and assume the line is not empty
38906
+ }
38907
+ return isLineEmpty ? lineStartOffset : startOffset;
38551
38908
  };
38552
38909
  // pre-transform
38553
38910
  html = await applyHtmlTransforms(html, preHooks, {
@@ -40076,8 +40433,8 @@ function createCachedImport(imp) {
40076
40433
  return cached;
40077
40434
  };
40078
40435
  }
40079
- const importPostcssImport = createCachedImport(() => import('./dep-rzQTjkv_.js').then(function (n) { return n.i; }));
40080
- const importPostcssModules = createCachedImport(() => import('./dep-riInLuGl.js').then(function (n) { return n.i; }));
40436
+ const importPostcssImport = createCachedImport(() => import('./dep-ggdMrszO.js').then(function (n) { return n.i; }));
40437
+ const importPostcssModules = createCachedImport(() => import('./dep-oIJQVJc7.js').then(function (n) { return n.i; }));
40081
40438
  const importPostcss = createCachedImport(() => import('postcss'));
40082
40439
  /**
40083
40440
  * @experimental
@@ -59109,7 +59466,7 @@ function isBareRelative(url) {
59109
59466
  return wordCharRE.test(url[0]) && !url.includes(':');
59110
59467
  }
59111
59468
  const isSrcSet = (attr) => attr.name === 'srcset' && attr.prefix === undefined;
59112
- const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, server) => {
59469
+ const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, server, isClassicScriptLink) => {
59113
59470
  // prefix with base (dev only, base is never relative)
59114
59471
  const replacer = (url) => {
59115
59472
  if (server?.moduleGraph) {
@@ -59133,9 +59490,9 @@ const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, s
59133
59490
  htmlPath === '/index.html')) {
59134
59491
  url = path$o.posix.join(config.base, url);
59135
59492
  }
59136
- if (server && shouldPreTransform(url, config)) {
59493
+ if (server && !isClassicScriptLink && shouldPreTransform(url, config)) {
59137
59494
  let preTransformUrl;
59138
- if (url[0] === '/') {
59495
+ if (url[0] === '/' && url[1] !== '/') {
59139
59496
  preTransformUrl = url;
59140
59497
  }
59141
59498
  else if (url[0] === '.' || isBareRelative(url)) {
@@ -59211,7 +59568,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
59211
59568
  if (node.nodeName === 'script') {
59212
59569
  const { src, sourceCodeLocation, isModule } = getScriptInfo(node);
59213
59570
  if (src) {
59214
- const processedUrl = processNodeUrl(src.value, isSrcSet(src), config, htmlPath, originalUrl, server);
59571
+ const processedUrl = processNodeUrl(src.value, isSrcSet(src), config, htmlPath, originalUrl, server, !isModule);
59215
59572
  if (processedUrl !== src.value) {
59216
59573
  overwriteAttrValue(s, sourceCodeLocation, processedUrl);
59217
59574
  }
@@ -64242,8 +64599,8 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
64242
64599
  function extractImportPaths(code) {
64243
64600
  // empty singleline & multiline comments to avoid matching comments
64244
64601
  code = code
64245
- .replace(multilineCommentsRE$1, '/* */')
64246
- .replace(singlelineCommentsRE$1, '');
64602
+ .replace(multilineCommentsRE, '/* */')
64603
+ .replace(singlelineCommentsRE, '');
64247
64604
  let js = '';
64248
64605
  let m;
64249
64606
  importsRE.lastIndex = 0;
@@ -66335,13 +66692,21 @@ function buildImportAnalysisPlugin(config) {
66335
66692
  const fileDepsCode = `[${fileDeps
66336
66693
  .map((fileDep) => fileDep.runtime ? fileDep.url : JSON.stringify(fileDep.url))
66337
66694
  .join(',')}]`;
66338
- s.append(`\
66695
+ const mapDepsCode = `\
66339
66696
  function __vite__mapDeps(indexes) {
66340
66697
  if (!__vite__mapDeps.viteFileDeps) {
66341
66698
  __vite__mapDeps.viteFileDeps = ${fileDepsCode}
66342
66699
  }
66343
66700
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
66344
- }`);
66701
+ }\n`;
66702
+ // inject extra code before sourcemap comment
66703
+ const mapFileCommentMatch = convertSourceMap.mapFileCommentRegex.exec(code);
66704
+ if (mapFileCommentMatch) {
66705
+ s.appendRight(mapFileCommentMatch.index, mapDepsCode);
66706
+ }
66707
+ else {
66708
+ s.append(mapDepsCode);
66709
+ }
66345
66710
  // there may still be markers due to inlined dynamic imports, remove
66346
66711
  // all the markers regardless
66347
66712
  let markerStartPos = indexOfMatchInSlice(code, preloadMarkerWithQuote);
@@ -1,4 +1,4 @@
1
- import { y as getDefaultExportFromCjs } from './dep-Pluk1iaB.js';
1
+ import { y as getDefaultExportFromCjs } from './dep-V3BH7oO1.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-8a-6Quh6.js';
@@ -1,4 +1,4 @@
1
- import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-Pluk1iaB.js';
1
+ import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-V3BH7oO1.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 { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-Pluk1iaB.js';
5
+ import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-V3BH7oO1.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -759,7 +759,7 @@ cli
759
759
  filterDuplicateOptions(options);
760
760
  // output structure is preserved even after bundling so require()
761
761
  // is ok here
762
- const { createServer } = await import('./chunks/dep-Pluk1iaB.js').then(function (n) { return n.A; });
762
+ const { createServer } = await import('./chunks/dep-V3BH7oO1.js').then(function (n) { return n.A; });
763
763
  try {
764
764
  const server = await createServer({
765
765
  root,
@@ -839,7 +839,7 @@ cli
839
839
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
840
840
  .action(async (root, options) => {
841
841
  filterDuplicateOptions(options);
842
- const { build } = await import('./chunks/dep-Pluk1iaB.js').then(function (n) { return n.C; });
842
+ const { build } = await import('./chunks/dep-V3BH7oO1.js').then(function (n) { return n.C; });
843
843
  const buildOptions = cleanOptions(options);
844
844
  try {
845
845
  await build({
@@ -867,7 +867,7 @@ cli
867
867
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
868
868
  .action(async (root, options) => {
869
869
  filterDuplicateOptions(options);
870
- const { optimizeDeps } = await import('./chunks/dep-Pluk1iaB.js').then(function (n) { return n.B; });
870
+ const { optimizeDeps } = await import('./chunks/dep-V3BH7oO1.js').then(function (n) { return n.B; });
871
871
  try {
872
872
  const config = await resolveConfig({
873
873
  root,
@@ -893,7 +893,7 @@ cli
893
893
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
894
894
  .action(async (root, options) => {
895
895
  filterDuplicateOptions(options);
896
- const { preview } = await import('./chunks/dep-Pluk1iaB.js').then(function (n) { return n.D; });
896
+ const { preview } = await import('./chunks/dep-V3BH7oO1.js').then(function (n) { return n.D; });
897
897
  try {
898
898
  const server = await preview({
899
899
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules } from './chunks/dep-Pluk1iaB.js';
3
- export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-Pluk1iaB.js';
2
+ import { i as isInNodeModules } from './chunks/dep-V3BH7oO1.js';
3
+ export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-V3BH7oO1.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  export { VERSION as rollupVersion } from 'rollup';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.0.9",
3
+ "version": "5.0.11",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -121,7 +121,7 @@
121
121
  "sirv": "^2.0.3",
122
122
  "source-map-support": "^0.5.21",
123
123
  "strip-ansi": "^7.1.0",
124
- "strip-literal": "^1.3.0",
124
+ "strip-literal": "^2.0.0",
125
125
  "tsconfck": "^3.0.0",
126
126
  "tslib": "^2.6.2",
127
127
  "types": "link:./types",