vite-node 2.0.0-beta.9 → 2.0.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.
- package/README.md +5 -2
- package/dist/chunk-hmr.cjs +35 -18
- package/dist/chunk-hmr.mjs +35 -18
- package/dist/cli.cjs +23 -11
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +24 -12
- package/dist/client.cjs +78 -35
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +78 -35
- package/dist/constants.cjs +4 -1
- package/dist/constants.mjs +4 -1
- package/dist/hmr.d.ts +1 -1
- package/dist/{index-D1EszD4V.d.ts → index-CCsqCcr7.d.ts} +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/server.cjs +186 -104
- package/dist/server.d.ts +1 -7
- package/dist/server.mjs +189 -107
- package/dist/source-map.cjs +66 -31
- package/dist/source-map.mjs +66 -31
- package/dist/types.d.ts +1 -1
- package/dist/utils.cjs +41 -31
- package/dist/utils.d.ts +1 -1
- package/dist/utils.mjs +41 -31
- package/package.json +3 -3
package/dist/source-map.cjs
CHANGED
|
@@ -572,17 +572,19 @@ const reSourceMap = /^data:application\/json[^,]+base64,/;
|
|
|
572
572
|
let retrieveFileHandlers = [];
|
|
573
573
|
let retrieveMapHandlers = [];
|
|
574
574
|
function globalProcessVersion() {
|
|
575
|
-
if (typeof process === "object" && process !== null)
|
|
575
|
+
if (typeof process === "object" && process !== null) {
|
|
576
576
|
return process.version;
|
|
577
|
-
else
|
|
577
|
+
} else {
|
|
578
578
|
return "";
|
|
579
|
+
}
|
|
579
580
|
}
|
|
580
581
|
function handlerExec(list) {
|
|
581
582
|
return function(arg) {
|
|
582
583
|
for (let i = 0; i < list.length; i++) {
|
|
583
584
|
const ret = list[i](arg);
|
|
584
|
-
if (ret)
|
|
585
|
+
if (ret) {
|
|
585
586
|
return ret;
|
|
587
|
+
}
|
|
586
588
|
}
|
|
587
589
|
return null;
|
|
588
590
|
};
|
|
@@ -595,19 +597,22 @@ retrieveFileHandlers.push((path2) => {
|
|
|
595
597
|
return drive ? "" : "/";
|
|
596
598
|
});
|
|
597
599
|
}
|
|
598
|
-
if (path2 in fileContentsCache)
|
|
600
|
+
if (path2 in fileContentsCache) {
|
|
599
601
|
return fileContentsCache[path2];
|
|
602
|
+
}
|
|
600
603
|
let contents = "";
|
|
601
604
|
try {
|
|
602
|
-
if (fs.existsSync(path2))
|
|
605
|
+
if (fs.existsSync(path2)) {
|
|
603
606
|
contents = fs.readFileSync(path2, "utf8");
|
|
607
|
+
}
|
|
604
608
|
} catch (er) {
|
|
605
609
|
}
|
|
606
610
|
return fileContentsCache[path2] = contents;
|
|
607
611
|
});
|
|
608
612
|
function supportRelativeURL(file, url) {
|
|
609
|
-
if (!file)
|
|
613
|
+
if (!file) {
|
|
610
614
|
return url;
|
|
615
|
+
}
|
|
611
616
|
const dir = path.dirname(file);
|
|
612
617
|
const match = /^\w+:\/\/[^/]*/.exec(dir);
|
|
613
618
|
let protocol = match ? match[0] : "";
|
|
@@ -620,20 +625,25 @@ function supportRelativeURL(file, url) {
|
|
|
620
625
|
}
|
|
621
626
|
function retrieveSourceMapURL(source) {
|
|
622
627
|
const fileData = retrieveFile(source);
|
|
623
|
-
if (!fileData)
|
|
628
|
+
if (!fileData) {
|
|
624
629
|
return null;
|
|
630
|
+
}
|
|
625
631
|
const re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm;
|
|
626
632
|
let lastMatch, match;
|
|
627
|
-
while (match = re.exec(fileData))
|
|
628
|
-
|
|
633
|
+
while (match = re.exec(fileData)) {
|
|
634
|
+
lastMatch = match;
|
|
635
|
+
}
|
|
636
|
+
if (!lastMatch) {
|
|
629
637
|
return null;
|
|
638
|
+
}
|
|
630
639
|
return lastMatch[1];
|
|
631
640
|
}
|
|
632
641
|
let retrieveSourceMap = handlerExec(retrieveMapHandlers);
|
|
633
642
|
retrieveMapHandlers.push((source) => {
|
|
634
643
|
let sourceMappingURL = retrieveSourceMapURL(source);
|
|
635
|
-
if (!sourceMappingURL)
|
|
644
|
+
if (!sourceMappingURL) {
|
|
636
645
|
return null;
|
|
646
|
+
}
|
|
637
647
|
let sourceMapData;
|
|
638
648
|
if (reSourceMap.test(sourceMappingURL)) {
|
|
639
649
|
const rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(",") + 1);
|
|
@@ -643,8 +653,9 @@ retrieveMapHandlers.push((source) => {
|
|
|
643
653
|
sourceMappingURL = supportRelativeURL(source, sourceMappingURL);
|
|
644
654
|
sourceMapData = retrieveFile(sourceMappingURL);
|
|
645
655
|
}
|
|
646
|
-
if (!sourceMapData)
|
|
656
|
+
if (!sourceMapData) {
|
|
647
657
|
return null;
|
|
658
|
+
}
|
|
648
659
|
return {
|
|
649
660
|
url: sourceMappingURL,
|
|
650
661
|
map: sourceMapData
|
|
@@ -652,8 +663,9 @@ retrieveMapHandlers.push((source) => {
|
|
|
652
663
|
});
|
|
653
664
|
function mapSourcePosition(position) {
|
|
654
665
|
var _a;
|
|
655
|
-
if (!position.source)
|
|
666
|
+
if (!position.source) {
|
|
656
667
|
return position;
|
|
668
|
+
}
|
|
657
669
|
let sourceMap = sourceMapCache[position.source];
|
|
658
670
|
if (!sourceMap) {
|
|
659
671
|
const urlAndMap = retrieveSourceMap(position.source);
|
|
@@ -703,8 +715,9 @@ function mapEvalOrigin(origin) {
|
|
|
703
715
|
return `eval at ${match[1]} (${position.source}:${position.line}:${position.column + 1})`;
|
|
704
716
|
}
|
|
705
717
|
match = /^eval at ([^(]+) \((.+)\)$/.exec(origin);
|
|
706
|
-
if (match)
|
|
718
|
+
if (match) {
|
|
707
719
|
return `eval at ${match[1]} (${mapEvalOrigin(match[2])})`;
|
|
720
|
+
}
|
|
708
721
|
return origin;
|
|
709
722
|
}
|
|
710
723
|
function CallSiteToString() {
|
|
@@ -727,8 +740,9 @@ function CallSiteToString() {
|
|
|
727
740
|
if (lineNumber != null) {
|
|
728
741
|
fileLocation += `:${lineNumber}`;
|
|
729
742
|
const columnNumber = this.getColumnNumber();
|
|
730
|
-
if (columnNumber)
|
|
743
|
+
if (columnNumber) {
|
|
731
744
|
fileLocation += `:${columnNumber}`;
|
|
745
|
+
}
|
|
732
746
|
}
|
|
733
747
|
}
|
|
734
748
|
let line = "";
|
|
@@ -738,15 +752,18 @@ function CallSiteToString() {
|
|
|
738
752
|
const isMethodCall = !(this.isToplevel() || isConstructor);
|
|
739
753
|
if (isMethodCall) {
|
|
740
754
|
let typeName = this.getTypeName();
|
|
741
|
-
if (typeName === "[object Object]")
|
|
755
|
+
if (typeName === "[object Object]") {
|
|
742
756
|
typeName = "null";
|
|
757
|
+
}
|
|
743
758
|
const methodName = this.getMethodName();
|
|
744
759
|
if (functionName) {
|
|
745
|
-
if (typeName && functionName.indexOf(typeName) !== 0)
|
|
760
|
+
if (typeName && functionName.indexOf(typeName) !== 0) {
|
|
746
761
|
line += `${typeName}.`;
|
|
762
|
+
}
|
|
747
763
|
line += functionName;
|
|
748
|
-
if (methodName && functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1)
|
|
764
|
+
if (methodName && functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1) {
|
|
749
765
|
line += ` [as ${methodName}]`;
|
|
766
|
+
}
|
|
750
767
|
} else {
|
|
751
768
|
line += `${typeName}.${methodName || "<anonymous>"}`;
|
|
752
769
|
}
|
|
@@ -758,8 +775,9 @@ function CallSiteToString() {
|
|
|
758
775
|
line += fileLocation;
|
|
759
776
|
addSuffix = false;
|
|
760
777
|
}
|
|
761
|
-
if (addSuffix)
|
|
778
|
+
if (addSuffix) {
|
|
762
779
|
line += ` (${fileLocation})`;
|
|
780
|
+
}
|
|
763
781
|
return line;
|
|
764
782
|
}
|
|
765
783
|
function cloneCallSite(frame) {
|
|
@@ -774,8 +792,9 @@ function cloneCallSite(frame) {
|
|
|
774
792
|
return object;
|
|
775
793
|
}
|
|
776
794
|
function wrapCallSite(frame, state) {
|
|
777
|
-
if (state === void 0)
|
|
795
|
+
if (state === void 0) {
|
|
778
796
|
state = { nextPosition: null, curPosition: null };
|
|
797
|
+
}
|
|
779
798
|
if (frame.isNative()) {
|
|
780
799
|
state.curPosition = null;
|
|
781
800
|
return frame;
|
|
@@ -786,8 +805,9 @@ function wrapCallSite(frame, state) {
|
|
|
786
805
|
let column = frame.getColumnNumber() - 1;
|
|
787
806
|
const noHeader = /^v(?:10\.1[6-9]|10\.[2-9]\d|10\.\d{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
|
|
788
807
|
const headerLength = noHeader.test(globalProcessVersion()) ? 0 : 62;
|
|
789
|
-
if (line === 1 && column > headerLength && !frame.isEval())
|
|
808
|
+
if (line === 1 && column > headerLength && !frame.isEval()) {
|
|
790
809
|
column -= headerLength;
|
|
810
|
+
}
|
|
791
811
|
const position = mapSourcePosition({
|
|
792
812
|
name: null,
|
|
793
813
|
source,
|
|
@@ -798,8 +818,9 @@ function wrapCallSite(frame, state) {
|
|
|
798
818
|
frame = cloneCallSite(frame);
|
|
799
819
|
const originalFunctionName = frame.getFunctionName;
|
|
800
820
|
frame.getFunctionName = function() {
|
|
801
|
-
if (state.nextPosition == null)
|
|
821
|
+
if (state.nextPosition == null) {
|
|
802
822
|
return originalFunctionName();
|
|
823
|
+
}
|
|
803
824
|
return state.nextPosition.name || originalFunctionName();
|
|
804
825
|
};
|
|
805
826
|
frame.getFileName = function() {
|
|
@@ -846,13 +867,15 @@ retrieveMapHandlers.slice(0);
|
|
|
846
867
|
const install = function(options) {
|
|
847
868
|
options = options || {};
|
|
848
869
|
if (options.retrieveFile) {
|
|
849
|
-
if (options.overrideRetrieveFile)
|
|
870
|
+
if (options.overrideRetrieveFile) {
|
|
850
871
|
retrieveFileHandlers.length = 0;
|
|
872
|
+
}
|
|
851
873
|
retrieveFileHandlers.unshift(options.retrieveFile);
|
|
852
874
|
}
|
|
853
875
|
if (options.retrieveSourceMap) {
|
|
854
|
-
if (options.overrideRetrieveSourceMap)
|
|
876
|
+
if (options.overrideRetrieveSourceMap) {
|
|
855
877
|
retrieveMapHandlers.length = 0;
|
|
878
|
+
}
|
|
856
879
|
retrieveMapHandlers.unshift(options.retrieveSourceMap);
|
|
857
880
|
}
|
|
858
881
|
if (!errorFormatterInstalled) {
|
|
@@ -865,17 +888,21 @@ let SOURCEMAPPING_URL = "sourceMa";
|
|
|
865
888
|
SOURCEMAPPING_URL += "ppingURL";
|
|
866
889
|
const VITE_NODE_SOURCEMAPPING_SOURCE = "//# sourceMappingSource=vite-node";
|
|
867
890
|
const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
|
|
868
|
-
const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(
|
|
891
|
+
const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(
|
|
892
|
+
`//# ${VITE_NODE_SOURCEMAPPING_URL};base64,(.+)`
|
|
893
|
+
);
|
|
869
894
|
function withInlineSourcemap(result, options) {
|
|
870
895
|
var _a;
|
|
871
896
|
const map = result.map;
|
|
872
897
|
let code = result.code;
|
|
873
|
-
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
|
|
898
|
+
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE)) {
|
|
874
899
|
return result;
|
|
900
|
+
}
|
|
875
901
|
if ("sources" in map) {
|
|
876
902
|
map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
|
|
877
|
-
if (!source)
|
|
903
|
+
if (!source) {
|
|
878
904
|
return source;
|
|
905
|
+
}
|
|
879
906
|
if (pathe.isAbsolute(source)) {
|
|
880
907
|
const actualPath = !source.startsWith(utils.withTrailingSlash(options.root)) && source.startsWith("/") ? pathe.resolve(options.root, source.slice(1)) : source;
|
|
881
908
|
return pathe.relative(pathe.dirname(options.filepath), actualPath);
|
|
@@ -883,12 +910,19 @@ function withInlineSourcemap(result, options) {
|
|
|
883
910
|
return source;
|
|
884
911
|
});
|
|
885
912
|
}
|
|
886
|
-
const OTHER_SOURCE_MAP_REGEXP = new RegExp(
|
|
887
|
-
|
|
913
|
+
const OTHER_SOURCE_MAP_REGEXP = new RegExp(
|
|
914
|
+
`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`,
|
|
915
|
+
"gm"
|
|
916
|
+
);
|
|
917
|
+
while (OTHER_SOURCE_MAP_REGEXP.test(code)) {
|
|
888
918
|
code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
|
|
889
|
-
|
|
919
|
+
}
|
|
920
|
+
if (map.mappings.startsWith(";")) {
|
|
890
921
|
map.mappings = `AAAA,CAAA${map.mappings}`;
|
|
891
|
-
|
|
922
|
+
}
|
|
923
|
+
const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString(
|
|
924
|
+
"base64"
|
|
925
|
+
);
|
|
892
926
|
result.code = `${code.trimEnd()}
|
|
893
927
|
|
|
894
928
|
${VITE_NODE_SOURCEMAPPING_SOURCE}
|
|
@@ -899,8 +933,9 @@ ${VITE_NODE_SOURCEMAPPING_SOURCE}
|
|
|
899
933
|
function extractSourceMap(code) {
|
|
900
934
|
var _a;
|
|
901
935
|
const mapString = (_a = code.match(VITE_NODE_SOURCEMAPPING_REGEXP)) == null ? void 0 : _a[1];
|
|
902
|
-
if (mapString)
|
|
936
|
+
if (mapString) {
|
|
903
937
|
return JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
|
|
938
|
+
}
|
|
904
939
|
return null;
|
|
905
940
|
}
|
|
906
941
|
function installSourcemapsSupport(options) {
|
package/dist/source-map.mjs
CHANGED
|
@@ -570,17 +570,19 @@ const reSourceMap = /^data:application\/json[^,]+base64,/;
|
|
|
570
570
|
let retrieveFileHandlers = [];
|
|
571
571
|
let retrieveMapHandlers = [];
|
|
572
572
|
function globalProcessVersion() {
|
|
573
|
-
if (typeof process === "object" && process !== null)
|
|
573
|
+
if (typeof process === "object" && process !== null) {
|
|
574
574
|
return process.version;
|
|
575
|
-
else
|
|
575
|
+
} else {
|
|
576
576
|
return "";
|
|
577
|
+
}
|
|
577
578
|
}
|
|
578
579
|
function handlerExec(list) {
|
|
579
580
|
return function(arg) {
|
|
580
581
|
for (let i = 0; i < list.length; i++) {
|
|
581
582
|
const ret = list[i](arg);
|
|
582
|
-
if (ret)
|
|
583
|
+
if (ret) {
|
|
583
584
|
return ret;
|
|
585
|
+
}
|
|
584
586
|
}
|
|
585
587
|
return null;
|
|
586
588
|
};
|
|
@@ -593,19 +595,22 @@ retrieveFileHandlers.push((path2) => {
|
|
|
593
595
|
return drive ? "" : "/";
|
|
594
596
|
});
|
|
595
597
|
}
|
|
596
|
-
if (path2 in fileContentsCache)
|
|
598
|
+
if (path2 in fileContentsCache) {
|
|
597
599
|
return fileContentsCache[path2];
|
|
600
|
+
}
|
|
598
601
|
let contents = "";
|
|
599
602
|
try {
|
|
600
|
-
if (fs.existsSync(path2))
|
|
603
|
+
if (fs.existsSync(path2)) {
|
|
601
604
|
contents = fs.readFileSync(path2, "utf8");
|
|
605
|
+
}
|
|
602
606
|
} catch (er) {
|
|
603
607
|
}
|
|
604
608
|
return fileContentsCache[path2] = contents;
|
|
605
609
|
});
|
|
606
610
|
function supportRelativeURL(file, url) {
|
|
607
|
-
if (!file)
|
|
611
|
+
if (!file) {
|
|
608
612
|
return url;
|
|
613
|
+
}
|
|
609
614
|
const dir = path.dirname(file);
|
|
610
615
|
const match = /^\w+:\/\/[^/]*/.exec(dir);
|
|
611
616
|
let protocol = match ? match[0] : "";
|
|
@@ -618,20 +623,25 @@ function supportRelativeURL(file, url) {
|
|
|
618
623
|
}
|
|
619
624
|
function retrieveSourceMapURL(source) {
|
|
620
625
|
const fileData = retrieveFile(source);
|
|
621
|
-
if (!fileData)
|
|
626
|
+
if (!fileData) {
|
|
622
627
|
return null;
|
|
628
|
+
}
|
|
623
629
|
const re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm;
|
|
624
630
|
let lastMatch, match;
|
|
625
|
-
while (match = re.exec(fileData))
|
|
626
|
-
|
|
631
|
+
while (match = re.exec(fileData)) {
|
|
632
|
+
lastMatch = match;
|
|
633
|
+
}
|
|
634
|
+
if (!lastMatch) {
|
|
627
635
|
return null;
|
|
636
|
+
}
|
|
628
637
|
return lastMatch[1];
|
|
629
638
|
}
|
|
630
639
|
let retrieveSourceMap = handlerExec(retrieveMapHandlers);
|
|
631
640
|
retrieveMapHandlers.push((source) => {
|
|
632
641
|
let sourceMappingURL = retrieveSourceMapURL(source);
|
|
633
|
-
if (!sourceMappingURL)
|
|
642
|
+
if (!sourceMappingURL) {
|
|
634
643
|
return null;
|
|
644
|
+
}
|
|
635
645
|
let sourceMapData;
|
|
636
646
|
if (reSourceMap.test(sourceMappingURL)) {
|
|
637
647
|
const rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(",") + 1);
|
|
@@ -641,8 +651,9 @@ retrieveMapHandlers.push((source) => {
|
|
|
641
651
|
sourceMappingURL = supportRelativeURL(source, sourceMappingURL);
|
|
642
652
|
sourceMapData = retrieveFile(sourceMappingURL);
|
|
643
653
|
}
|
|
644
|
-
if (!sourceMapData)
|
|
654
|
+
if (!sourceMapData) {
|
|
645
655
|
return null;
|
|
656
|
+
}
|
|
646
657
|
return {
|
|
647
658
|
url: sourceMappingURL,
|
|
648
659
|
map: sourceMapData
|
|
@@ -650,8 +661,9 @@ retrieveMapHandlers.push((source) => {
|
|
|
650
661
|
});
|
|
651
662
|
function mapSourcePosition(position) {
|
|
652
663
|
var _a;
|
|
653
|
-
if (!position.source)
|
|
664
|
+
if (!position.source) {
|
|
654
665
|
return position;
|
|
666
|
+
}
|
|
655
667
|
let sourceMap = sourceMapCache[position.source];
|
|
656
668
|
if (!sourceMap) {
|
|
657
669
|
const urlAndMap = retrieveSourceMap(position.source);
|
|
@@ -701,8 +713,9 @@ function mapEvalOrigin(origin) {
|
|
|
701
713
|
return `eval at ${match[1]} (${position.source}:${position.line}:${position.column + 1})`;
|
|
702
714
|
}
|
|
703
715
|
match = /^eval at ([^(]+) \((.+)\)$/.exec(origin);
|
|
704
|
-
if (match)
|
|
716
|
+
if (match) {
|
|
705
717
|
return `eval at ${match[1]} (${mapEvalOrigin(match[2])})`;
|
|
718
|
+
}
|
|
706
719
|
return origin;
|
|
707
720
|
}
|
|
708
721
|
function CallSiteToString() {
|
|
@@ -725,8 +738,9 @@ function CallSiteToString() {
|
|
|
725
738
|
if (lineNumber != null) {
|
|
726
739
|
fileLocation += `:${lineNumber}`;
|
|
727
740
|
const columnNumber = this.getColumnNumber();
|
|
728
|
-
if (columnNumber)
|
|
741
|
+
if (columnNumber) {
|
|
729
742
|
fileLocation += `:${columnNumber}`;
|
|
743
|
+
}
|
|
730
744
|
}
|
|
731
745
|
}
|
|
732
746
|
let line = "";
|
|
@@ -736,15 +750,18 @@ function CallSiteToString() {
|
|
|
736
750
|
const isMethodCall = !(this.isToplevel() || isConstructor);
|
|
737
751
|
if (isMethodCall) {
|
|
738
752
|
let typeName = this.getTypeName();
|
|
739
|
-
if (typeName === "[object Object]")
|
|
753
|
+
if (typeName === "[object Object]") {
|
|
740
754
|
typeName = "null";
|
|
755
|
+
}
|
|
741
756
|
const methodName = this.getMethodName();
|
|
742
757
|
if (functionName) {
|
|
743
|
-
if (typeName && functionName.indexOf(typeName) !== 0)
|
|
758
|
+
if (typeName && functionName.indexOf(typeName) !== 0) {
|
|
744
759
|
line += `${typeName}.`;
|
|
760
|
+
}
|
|
745
761
|
line += functionName;
|
|
746
|
-
if (methodName && functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1)
|
|
762
|
+
if (methodName && functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1) {
|
|
747
763
|
line += ` [as ${methodName}]`;
|
|
764
|
+
}
|
|
748
765
|
} else {
|
|
749
766
|
line += `${typeName}.${methodName || "<anonymous>"}`;
|
|
750
767
|
}
|
|
@@ -756,8 +773,9 @@ function CallSiteToString() {
|
|
|
756
773
|
line += fileLocation;
|
|
757
774
|
addSuffix = false;
|
|
758
775
|
}
|
|
759
|
-
if (addSuffix)
|
|
776
|
+
if (addSuffix) {
|
|
760
777
|
line += ` (${fileLocation})`;
|
|
778
|
+
}
|
|
761
779
|
return line;
|
|
762
780
|
}
|
|
763
781
|
function cloneCallSite(frame) {
|
|
@@ -772,8 +790,9 @@ function cloneCallSite(frame) {
|
|
|
772
790
|
return object;
|
|
773
791
|
}
|
|
774
792
|
function wrapCallSite(frame, state) {
|
|
775
|
-
if (state === void 0)
|
|
793
|
+
if (state === void 0) {
|
|
776
794
|
state = { nextPosition: null, curPosition: null };
|
|
795
|
+
}
|
|
777
796
|
if (frame.isNative()) {
|
|
778
797
|
state.curPosition = null;
|
|
779
798
|
return frame;
|
|
@@ -784,8 +803,9 @@ function wrapCallSite(frame, state) {
|
|
|
784
803
|
let column = frame.getColumnNumber() - 1;
|
|
785
804
|
const noHeader = /^v(?:10\.1[6-9]|10\.[2-9]\d|10\.\d{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
|
|
786
805
|
const headerLength = noHeader.test(globalProcessVersion()) ? 0 : 62;
|
|
787
|
-
if (line === 1 && column > headerLength && !frame.isEval())
|
|
806
|
+
if (line === 1 && column > headerLength && !frame.isEval()) {
|
|
788
807
|
column -= headerLength;
|
|
808
|
+
}
|
|
789
809
|
const position = mapSourcePosition({
|
|
790
810
|
name: null,
|
|
791
811
|
source,
|
|
@@ -796,8 +816,9 @@ function wrapCallSite(frame, state) {
|
|
|
796
816
|
frame = cloneCallSite(frame);
|
|
797
817
|
const originalFunctionName = frame.getFunctionName;
|
|
798
818
|
frame.getFunctionName = function() {
|
|
799
|
-
if (state.nextPosition == null)
|
|
819
|
+
if (state.nextPosition == null) {
|
|
800
820
|
return originalFunctionName();
|
|
821
|
+
}
|
|
801
822
|
return state.nextPosition.name || originalFunctionName();
|
|
802
823
|
};
|
|
803
824
|
frame.getFileName = function() {
|
|
@@ -844,13 +865,15 @@ retrieveMapHandlers.slice(0);
|
|
|
844
865
|
const install = function(options) {
|
|
845
866
|
options = options || {};
|
|
846
867
|
if (options.retrieveFile) {
|
|
847
|
-
if (options.overrideRetrieveFile)
|
|
868
|
+
if (options.overrideRetrieveFile) {
|
|
848
869
|
retrieveFileHandlers.length = 0;
|
|
870
|
+
}
|
|
849
871
|
retrieveFileHandlers.unshift(options.retrieveFile);
|
|
850
872
|
}
|
|
851
873
|
if (options.retrieveSourceMap) {
|
|
852
|
-
if (options.overrideRetrieveSourceMap)
|
|
874
|
+
if (options.overrideRetrieveSourceMap) {
|
|
853
875
|
retrieveMapHandlers.length = 0;
|
|
876
|
+
}
|
|
854
877
|
retrieveMapHandlers.unshift(options.retrieveSourceMap);
|
|
855
878
|
}
|
|
856
879
|
if (!errorFormatterInstalled) {
|
|
@@ -863,17 +886,21 @@ let SOURCEMAPPING_URL = "sourceMa";
|
|
|
863
886
|
SOURCEMAPPING_URL += "ppingURL";
|
|
864
887
|
const VITE_NODE_SOURCEMAPPING_SOURCE = "//# sourceMappingSource=vite-node";
|
|
865
888
|
const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
|
|
866
|
-
const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(
|
|
889
|
+
const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(
|
|
890
|
+
`//# ${VITE_NODE_SOURCEMAPPING_URL};base64,(.+)`
|
|
891
|
+
);
|
|
867
892
|
function withInlineSourcemap(result, options) {
|
|
868
893
|
var _a;
|
|
869
894
|
const map = result.map;
|
|
870
895
|
let code = result.code;
|
|
871
|
-
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
|
|
896
|
+
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE)) {
|
|
872
897
|
return result;
|
|
898
|
+
}
|
|
873
899
|
if ("sources" in map) {
|
|
874
900
|
map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
|
|
875
|
-
if (!source)
|
|
901
|
+
if (!source) {
|
|
876
902
|
return source;
|
|
903
|
+
}
|
|
877
904
|
if (isAbsolute(source)) {
|
|
878
905
|
const actualPath = !source.startsWith(withTrailingSlash(options.root)) && source.startsWith("/") ? resolve$2(options.root, source.slice(1)) : source;
|
|
879
906
|
return relative(dirname(options.filepath), actualPath);
|
|
@@ -881,12 +908,19 @@ function withInlineSourcemap(result, options) {
|
|
|
881
908
|
return source;
|
|
882
909
|
});
|
|
883
910
|
}
|
|
884
|
-
const OTHER_SOURCE_MAP_REGEXP = new RegExp(
|
|
885
|
-
|
|
911
|
+
const OTHER_SOURCE_MAP_REGEXP = new RegExp(
|
|
912
|
+
`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`,
|
|
913
|
+
"gm"
|
|
914
|
+
);
|
|
915
|
+
while (OTHER_SOURCE_MAP_REGEXP.test(code)) {
|
|
886
916
|
code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
|
|
887
|
-
|
|
917
|
+
}
|
|
918
|
+
if (map.mappings.startsWith(";")) {
|
|
888
919
|
map.mappings = `AAAA,CAAA${map.mappings}`;
|
|
889
|
-
|
|
920
|
+
}
|
|
921
|
+
const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString(
|
|
922
|
+
"base64"
|
|
923
|
+
);
|
|
890
924
|
result.code = `${code.trimEnd()}
|
|
891
925
|
|
|
892
926
|
${VITE_NODE_SOURCEMAPPING_SOURCE}
|
|
@@ -897,8 +931,9 @@ ${VITE_NODE_SOURCEMAPPING_SOURCE}
|
|
|
897
931
|
function extractSourceMap(code) {
|
|
898
932
|
var _a;
|
|
899
933
|
const mapString = (_a = code.match(VITE_NODE_SOURCEMAPPING_REGEXP)) == null ? void 0 : _a[1];
|
|
900
|
-
if (mapString)
|
|
934
|
+
if (mapString) {
|
|
901
935
|
return JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
|
|
936
|
+
}
|
|
902
937
|
return null;
|
|
903
938
|
}
|
|
904
939
|
function installSourcemapsSupport(options) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, l as ViteNodeResolveModule, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-
|
|
1
|
+
export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, l as ViteNodeResolveModule, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-CCsqCcr7.js';
|
|
2
2
|
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-DLVdEqOp.js';
|