vite 5.0.10 → 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)) {
@@ -27877,13 +27877,6 @@ function parseExpressionAt(input, pos, options) {
27877
27877
  return Parser$1.parseExpressionAt(input, pos, options)
27878
27878
  }
27879
27879
 
27880
- // Acorn is organized as a tokenizer and a recursive-descent parser.
27881
- // The `tokenizer` export provides an interface to the tokenizer.
27882
-
27883
- function tokenizer(input, options) {
27884
- return Parser$1.tokenizer(input, options)
27885
- }
27886
-
27887
27880
  const HASH_RE = /#/g;
27888
27881
  const AMPERSAND_RE = /&/g;
27889
27882
  const EQUAL_RE = /=/g;
@@ -37617,112 +37610,468 @@ var src$1 = rc;
37617
37610
 
37618
37611
  var postcssrc = /*@__PURE__*/getDefaultExportFromCjs(src$1);
37619
37612
 
37620
- 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) {
37621
38005
  const FILL = options?.fillChar ?? " ";
37622
38006
  const FILL_COMMENT = " ";
37623
38007
  let result = "";
37624
38008
  const filter = options?.filter ?? (() => true);
37625
- function fillupTo(index) {
37626
- if (index > result.length)
37627
- result += code.slice(result.length, index).replace(/[^\n]/g, FILL_COMMENT);
37628
- }
37629
38009
  const tokens = [];
37630
- const pasers = tokenizer(code, {
37631
- ecmaVersion: "latest",
37632
- sourceType: "module",
37633
- allowHashBang: true,
37634
- allowAwaitOutsideFunction: true,
37635
- allowImportExportEverywhere: true
37636
- });
37637
- const iter = pasers[Symbol.iterator]();
37638
- let error;
37639
- try {
37640
- while (true) {
37641
- const { done, value: token } = iter.next();
37642
- if (done)
37643
- break;
37644
- tokens.push(token);
37645
- fillupTo(token.start);
37646
- if (token.type.label === "string") {
37647
- const body = code.slice(token.start + 1, token.end - 1);
37648
- if (filter(body)) {
37649
- result += code[token.start] + FILL.repeat(token.end - token.start - 2) + code[token.end - 1];
37650
- continue;
37651
- }
37652
- } else if (token.type.label === "template") {
37653
- const body = code.slice(token.start, token.end);
37654
- if (filter(body)) {
37655
- result += FILL.repeat(token.end - token.start);
37656
- continue;
37657
- }
37658
- } else if (token.type.label === "regexp") {
37659
- const body = code.slice(token.start, token.end);
37660
- if (filter(body)) {
37661
- result += body.replace(/\/(.*)\/(\w?)$/g, (_, $1, $2) => `/${FILL.repeat($1.length)}/${$2}`);
37662
- continue;
37663
- }
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;
37664
38025
  }
37665
- result += code.slice(token.start, token.end);
37666
38026
  }
37667
- fillupTo(code.length);
37668
- } catch (e) {
37669
- 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;
37670
38063
  }
37671
38064
  return {
37672
- error,
37673
38065
  result,
37674
38066
  tokens
37675
38067
  };
37676
38068
  }
37677
38069
 
37678
- const multilineCommentsRE = /\/\*([^*\/])*?\*\//gms;
37679
- const singlelineCommentsRE = /(?:^|\n|\r)\s*\/\/.*(?:\r|\n|$)/gm;
37680
- const templateLiteralRE$1 = /\$\{(\s*(?:|{.*}|(?!\$\{).|\n|\r)*?\s*)\}/g;
37681
- const quotesRE = [
37682
- /(["'`])((?:\\\1|(?!\1)|.|\r)*?)\1/gm,
37683
- /([`])((?:\\\1|(?!\1)|.|\n|\r)*?)\1/gm
37684
- // multi-line strings (i.e. template literals only)
37685
- ];
37686
- function stripLiteralRegex(code, options) {
37687
- const FILL_COMMENT = " ";
37688
- const FILL = options?.fillChar ?? " ";
37689
- const filter = options?.filter ?? (() => true);
37690
- code = code.replace(multilineCommentsRE, (s) => filter(s) ? FILL_COMMENT.repeat(s.length) : s).replace(singlelineCommentsRE, (s) => filter(s) ? FILL_COMMENT.repeat(s.length) : s);
37691
- let expanded = code;
37692
- for (let i = 0; i < 16; i++) {
37693
- const before = expanded;
37694
- expanded = expanded.replace(templateLiteralRE$1, "` $1`");
37695
- if (expanded === before)
37696
- break;
37697
- }
37698
- quotesRE.forEach((re) => {
37699
- expanded = expanded.replace(re, (s, quote, body, index) => {
37700
- if (!filter(s.slice(1, -1)))
37701
- return s;
37702
- code = code.slice(0, index + 1) + FILL.repeat(s.length - 2) + code.slice(index + s.length - 1);
37703
- return quote + FILL.repeat(s.length - 2) + quote;
37704
- });
37705
- });
37706
- return code;
37707
- }
37708
-
37709
38070
  function stripLiteral(code, options) {
37710
38071
  return stripLiteralDetailed(code, options).result;
37711
38072
  }
37712
38073
  function stripLiteralDetailed(code, options) {
37713
- const acorn = _stripLiteralAcorn(code, options);
37714
- if (!acorn.error) {
37715
- return {
37716
- mode: "acorn",
37717
- result: acorn.result,
37718
- acorn
37719
- };
37720
- }
37721
- return {
37722
- mode: "regex",
37723
- result: stripLiteralRegex(acorn.result + code.slice(acorn.result.length), options),
37724
- acorn
37725
- };
38074
+ return stripLiteralJsTokens(code, options);
37726
38075
  }
37727
38076
 
37728
38077
  var main$1 = {exports: {}};
@@ -38529,13 +38878,12 @@ function buildHtmlPlugin(config) {
38529
38878
  // Determines true start position for the node, either the < character
38530
38879
  // position, or the newline at the end of the previous line's node.
38531
38880
  const nodeStartWithLeadingWhitespace = (node) => {
38532
- if (node.sourceCodeLocation.startOffset === 0)
38533
- return node.sourceCodeLocation.startOffset;
38881
+ const startOffset = node.sourceCodeLocation.startOffset;
38882
+ if (startOffset === 0)
38883
+ return 0;
38534
38884
  // Gets the offset for the start of the line including the
38535
38885
  // newline trailing the previous node
38536
- const lineStartOffset = node.sourceCodeLocation.startOffset -
38537
- node.sourceCodeLocation.startCol;
38538
- const line = s.slice(Math.max(0, lineStartOffset), node.sourceCodeLocation.startOffset);
38886
+ const lineStartOffset = startOffset - node.sourceCodeLocation.startCol;
38539
38887
  // <previous-line-node></previous-line-node>
38540
38888
  // <target-node></target-node>
38541
38889
  //
@@ -38547,9 +38895,16 @@ function buildHtmlPlugin(config) {
38547
38895
  //
38548
38896
  // However, if there is content between our target node start and the
38549
38897
  // previous newline, we cannot strip it out without risking content deletion.
38550
- return line.trim()
38551
- ? node.sourceCodeLocation.startOffset
38552
- : 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;
38553
38908
  };
38554
38909
  // pre-transform
38555
38910
  html = await applyHtmlTransforms(html, preHooks, {
@@ -40078,8 +40433,8 @@ function createCachedImport(imp) {
40078
40433
  return cached;
40079
40434
  };
40080
40435
  }
40081
- const importPostcssImport = createCachedImport(() => import('./dep-TyoTMUQy.js').then(function (n) { return n.i; }));
40082
- const importPostcssModules = createCachedImport(() => import('./dep-mc9zj7Ue.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; }));
40083
40438
  const importPostcss = createCachedImport(() => import('postcss'));
40084
40439
  /**
40085
40440
  * @experimental
@@ -59111,7 +59466,7 @@ function isBareRelative(url) {
59111
59466
  return wordCharRE.test(url[0]) && !url.includes(':');
59112
59467
  }
59113
59468
  const isSrcSet = (attr) => attr.name === 'srcset' && attr.prefix === undefined;
59114
- const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, server) => {
59469
+ const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, server, isClassicScriptLink) => {
59115
59470
  // prefix with base (dev only, base is never relative)
59116
59471
  const replacer = (url) => {
59117
59472
  if (server?.moduleGraph) {
@@ -59135,7 +59490,7 @@ const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, s
59135
59490
  htmlPath === '/index.html')) {
59136
59491
  url = path$o.posix.join(config.base, url);
59137
59492
  }
59138
- if (server && shouldPreTransform(url, config)) {
59493
+ if (server && !isClassicScriptLink && shouldPreTransform(url, config)) {
59139
59494
  let preTransformUrl;
59140
59495
  if (url[0] === '/' && url[1] !== '/') {
59141
59496
  preTransformUrl = url;
@@ -59213,7 +59568,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
59213
59568
  if (node.nodeName === 'script') {
59214
59569
  const { src, sourceCodeLocation, isModule } = getScriptInfo(node);
59215
59570
  if (src) {
59216
- const processedUrl = processNodeUrl(src.value, isSrcSet(src), config, htmlPath, originalUrl, server);
59571
+ const processedUrl = processNodeUrl(src.value, isSrcSet(src), config, htmlPath, originalUrl, server, !isModule);
59217
59572
  if (processedUrl !== src.value) {
59218
59573
  overwriteAttrValue(s, sourceCodeLocation, processedUrl);
59219
59574
  }
@@ -64244,8 +64599,8 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
64244
64599
  function extractImportPaths(code) {
64245
64600
  // empty singleline & multiline comments to avoid matching comments
64246
64601
  code = code
64247
- .replace(multilineCommentsRE$1, '/* */')
64248
- .replace(singlelineCommentsRE$1, '');
64602
+ .replace(multilineCommentsRE, '/* */')
64603
+ .replace(singlelineCommentsRE, '');
64249
64604
  let js = '';
64250
64605
  let m;
64251
64606
  importsRE.lastIndex = 0;
@@ -66337,13 +66692,21 @@ function buildImportAnalysisPlugin(config) {
66337
66692
  const fileDepsCode = `[${fileDeps
66338
66693
  .map((fileDep) => fileDep.runtime ? fileDep.url : JSON.stringify(fileDep.url))
66339
66694
  .join(',')}]`;
66340
- s.append(`\
66695
+ const mapDepsCode = `\
66341
66696
  function __vite__mapDeps(indexes) {
66342
66697
  if (!__vite__mapDeps.viteFileDeps) {
66343
66698
  __vite__mapDeps.viteFileDeps = ${fileDepsCode}
66344
66699
  }
66345
66700
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
66346
- }`);
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
+ }
66347
66710
  // there may still be markers due to inlined dynamic imports, remove
66348
66711
  // all the markers regardless
66349
66712
  let markerStartPos = indexOfMatchInSlice(code, preloadMarkerWithQuote);
@@ -1,4 +1,4 @@
1
- import { y as getDefaultExportFromCjs } from './dep-R0I0XnyH.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-R0I0XnyH.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-R0I0XnyH.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-R0I0XnyH.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-R0I0XnyH.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-R0I0XnyH.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-R0I0XnyH.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-R0I0XnyH.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-R0I0XnyH.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.10",
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",