vite-node 4.0.0-beta.10 → 4.0.0-beta.12
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/dist/chunk-hmr.cjs +7 -9
- package/dist/chunk-hmr.mjs +7 -9
- package/dist/{chunk-browser.cjs → chunk-index.cjs} +26 -25
- package/dist/{chunk-browser.mjs → chunk-index.mjs} +26 -25
- package/dist/cli.cjs +6 -6
- package/dist/cli.mjs +6 -6
- package/dist/client.cjs +5 -6
- package/dist/client.mjs +3 -4
- package/dist/hmr.cjs +1 -1
- package/dist/hmr.mjs +1 -1
- package/dist/server.cjs +12 -19
- package/dist/server.mjs +12 -19
- package/dist/source-map.cjs +108 -126
- package/dist/source-map.mjs +108 -126
- package/dist/utils.cjs +7 -7
- package/dist/utils.mjs +7 -7
- package/package.json +5 -5
package/dist/source-map.mjs
CHANGED
|
@@ -5,106 +5,103 @@ import { withTrailingSlash } from './utils.mjs';
|
|
|
5
5
|
import 'node:module';
|
|
6
6
|
import 'node:url';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
// src/vlq.ts
|
|
9
|
+
var comma = ",".charCodeAt(0);
|
|
10
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
11
|
+
var intToChar = new Uint8Array(64);
|
|
12
|
+
var charToInt = new Uint8Array(128);
|
|
12
13
|
for (let i = 0; i < chars.length; i++) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const c = chars.charCodeAt(i);
|
|
15
|
+
intToChar[i] = c;
|
|
16
|
+
charToInt[c] = i;
|
|
16
17
|
}
|
|
17
18
|
function decodeInteger(reader, relative) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
let value = 0;
|
|
20
|
+
let shift = 0;
|
|
21
|
+
let integer = 0;
|
|
22
|
+
do {
|
|
23
|
+
const c = reader.next();
|
|
24
|
+
integer = charToInt[c];
|
|
25
|
+
value |= (integer & 31) << shift;
|
|
26
|
+
shift += 5;
|
|
27
|
+
} while (integer & 32);
|
|
28
|
+
const shouldNegate = value & 1;
|
|
29
|
+
value >>>= 1;
|
|
30
|
+
if (shouldNegate) {
|
|
31
|
+
value = -2147483648 | -value;
|
|
32
|
+
}
|
|
33
|
+
return relative + value;
|
|
33
34
|
}
|
|
34
35
|
function hasMoreVlq(reader, max) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return reader.peek() !== comma;
|
|
38
|
-
}
|
|
39
|
-
class StringReader {
|
|
40
|
-
constructor(buffer) {
|
|
41
|
-
this.pos = 0;
|
|
42
|
-
this.buffer = buffer;
|
|
43
|
-
}
|
|
44
|
-
next() {
|
|
45
|
-
return this.buffer.charCodeAt(this.pos++);
|
|
46
|
-
}
|
|
47
|
-
peek() {
|
|
48
|
-
return this.buffer.charCodeAt(this.pos);
|
|
49
|
-
}
|
|
50
|
-
indexOf(char) {
|
|
51
|
-
const { buffer, pos } = this;
|
|
52
|
-
const idx = buffer.indexOf(char, pos);
|
|
53
|
-
return idx === -1 ? buffer.length : idx;
|
|
54
|
-
}
|
|
36
|
+
if (reader.pos >= max) return false;
|
|
37
|
+
return reader.peek() !== comma;
|
|
55
38
|
}
|
|
39
|
+
var StringReader = class {
|
|
40
|
+
constructor(buffer) {
|
|
41
|
+
this.pos = 0;
|
|
42
|
+
this.buffer = buffer;
|
|
43
|
+
}
|
|
44
|
+
next() {
|
|
45
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
46
|
+
}
|
|
47
|
+
peek() {
|
|
48
|
+
return this.buffer.charCodeAt(this.pos);
|
|
49
|
+
}
|
|
50
|
+
indexOf(char) {
|
|
51
|
+
const { buffer, pos } = this;
|
|
52
|
+
const idx = buffer.indexOf(char, pos);
|
|
53
|
+
return idx === -1 ? buffer.length : idx;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
56
|
|
|
57
|
+
// src/sourcemap-codec.ts
|
|
57
58
|
function decode(mappings) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
else {
|
|
87
|
-
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
seg = [genColumn];
|
|
92
|
-
}
|
|
93
|
-
line.push(seg);
|
|
94
|
-
reader.pos++;
|
|
59
|
+
const { length } = mappings;
|
|
60
|
+
const reader = new StringReader(mappings);
|
|
61
|
+
const decoded = [];
|
|
62
|
+
let genColumn = 0;
|
|
63
|
+
let sourcesIndex = 0;
|
|
64
|
+
let sourceLine = 0;
|
|
65
|
+
let sourceColumn = 0;
|
|
66
|
+
let namesIndex = 0;
|
|
67
|
+
do {
|
|
68
|
+
const semi = reader.indexOf(";");
|
|
69
|
+
const line = [];
|
|
70
|
+
let sorted = true;
|
|
71
|
+
let lastCol = 0;
|
|
72
|
+
genColumn = 0;
|
|
73
|
+
while (reader.pos < semi) {
|
|
74
|
+
let seg;
|
|
75
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
76
|
+
if (genColumn < lastCol) sorted = false;
|
|
77
|
+
lastCol = genColumn;
|
|
78
|
+
if (hasMoreVlq(reader, semi)) {
|
|
79
|
+
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
80
|
+
sourceLine = decodeInteger(reader, sourceLine);
|
|
81
|
+
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
82
|
+
if (hasMoreVlq(reader, semi)) {
|
|
83
|
+
namesIndex = decodeInteger(reader, namesIndex);
|
|
84
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
|
85
|
+
} else {
|
|
86
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
95
87
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
} else {
|
|
89
|
+
seg = [genColumn];
|
|
90
|
+
}
|
|
91
|
+
line.push(seg);
|
|
92
|
+
reader.pos++;
|
|
93
|
+
}
|
|
94
|
+
if (!sorted) sort(line);
|
|
95
|
+
decoded.push(line);
|
|
96
|
+
reader.pos = semi + 1;
|
|
97
|
+
} while (reader.pos <= length);
|
|
98
|
+
return decoded;
|
|
102
99
|
}
|
|
103
100
|
function sort(line) {
|
|
104
|
-
|
|
101
|
+
line.sort(sortComparator$1);
|
|
105
102
|
}
|
|
106
103
|
function sortComparator$1(a, b) {
|
|
107
|
-
|
|
104
|
+
return a[0] - b[0];
|
|
108
105
|
}
|
|
109
106
|
|
|
110
107
|
// Matches the scheme of a URL, eg "http://"
|
|
@@ -130,16 +127,6 @@ const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#
|
|
|
130
127
|
* 4. Hash, including "#", optional.
|
|
131
128
|
*/
|
|
132
129
|
const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
|
133
|
-
var UrlType;
|
|
134
|
-
(function (UrlType) {
|
|
135
|
-
UrlType[UrlType["Empty"] = 1] = "Empty";
|
|
136
|
-
UrlType[UrlType["Hash"] = 2] = "Hash";
|
|
137
|
-
UrlType[UrlType["Query"] = 3] = "Query";
|
|
138
|
-
UrlType[UrlType["RelativePath"] = 4] = "RelativePath";
|
|
139
|
-
UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath";
|
|
140
|
-
UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative";
|
|
141
|
-
UrlType[UrlType["Absolute"] = 7] = "Absolute";
|
|
142
|
-
})(UrlType || (UrlType = {}));
|
|
143
130
|
function isAbsoluteUrl(input) {
|
|
144
131
|
return schemeRegex.test(input);
|
|
145
132
|
}
|
|
@@ -173,21 +160,21 @@ function makeUrl(scheme, user, host, port, path, query, hash) {
|
|
|
173
160
|
path,
|
|
174
161
|
query,
|
|
175
162
|
hash,
|
|
176
|
-
type:
|
|
163
|
+
type: 7 /* Absolute */,
|
|
177
164
|
};
|
|
178
165
|
}
|
|
179
166
|
function parseUrl(input) {
|
|
180
167
|
if (isSchemeRelativeUrl(input)) {
|
|
181
168
|
const url = parseAbsoluteUrl('http:' + input);
|
|
182
169
|
url.scheme = '';
|
|
183
|
-
url.type =
|
|
170
|
+
url.type = 6 /* SchemeRelative */;
|
|
184
171
|
return url;
|
|
185
172
|
}
|
|
186
173
|
if (isAbsolutePath(input)) {
|
|
187
174
|
const url = parseAbsoluteUrl('http://foo.com' + input);
|
|
188
175
|
url.scheme = '';
|
|
189
176
|
url.host = '';
|
|
190
|
-
url.type =
|
|
177
|
+
url.type = 5 /* AbsolutePath */;
|
|
191
178
|
return url;
|
|
192
179
|
}
|
|
193
180
|
if (isFileUrl(input))
|
|
@@ -199,11 +186,11 @@ function parseUrl(input) {
|
|
|
199
186
|
url.host = '';
|
|
200
187
|
url.type = input
|
|
201
188
|
? input.startsWith('?')
|
|
202
|
-
?
|
|
189
|
+
? 3 /* Query */
|
|
203
190
|
: input.startsWith('#')
|
|
204
|
-
?
|
|
205
|
-
:
|
|
206
|
-
:
|
|
191
|
+
? 2 /* Hash */
|
|
192
|
+
: 4 /* RelativePath */
|
|
193
|
+
: 1 /* Empty */;
|
|
207
194
|
return url;
|
|
208
195
|
}
|
|
209
196
|
function stripPathFilename(path) {
|
|
@@ -231,7 +218,7 @@ function mergePaths(url, base) {
|
|
|
231
218
|
* "foo/.". We need to normalize to a standard representation.
|
|
232
219
|
*/
|
|
233
220
|
function normalizePath(url, type) {
|
|
234
|
-
const rel = type <=
|
|
221
|
+
const rel = type <= 4 /* RelativePath */;
|
|
235
222
|
const pieces = url.path.split('/');
|
|
236
223
|
// We need to preserve the first piece always, so that we output a leading slash. The item at
|
|
237
224
|
// pieces[0] is an empty string.
|
|
@@ -292,27 +279,27 @@ function resolve(input, base) {
|
|
|
292
279
|
return '';
|
|
293
280
|
const url = parseUrl(input);
|
|
294
281
|
let inputType = url.type;
|
|
295
|
-
if (base && inputType !==
|
|
282
|
+
if (base && inputType !== 7 /* Absolute */) {
|
|
296
283
|
const baseUrl = parseUrl(base);
|
|
297
284
|
const baseType = baseUrl.type;
|
|
298
285
|
switch (inputType) {
|
|
299
|
-
case
|
|
286
|
+
case 1 /* Empty */:
|
|
300
287
|
url.hash = baseUrl.hash;
|
|
301
288
|
// fall through
|
|
302
|
-
case
|
|
289
|
+
case 2 /* Hash */:
|
|
303
290
|
url.query = baseUrl.query;
|
|
304
291
|
// fall through
|
|
305
|
-
case
|
|
306
|
-
case
|
|
292
|
+
case 3 /* Query */:
|
|
293
|
+
case 4 /* RelativePath */:
|
|
307
294
|
mergePaths(url, baseUrl);
|
|
308
295
|
// fall through
|
|
309
|
-
case
|
|
296
|
+
case 5 /* AbsolutePath */:
|
|
310
297
|
// The host, user, and port are joined, you can't copy one without the others.
|
|
311
298
|
url.user = baseUrl.user;
|
|
312
299
|
url.host = baseUrl.host;
|
|
313
300
|
url.port = baseUrl.port;
|
|
314
301
|
// fall through
|
|
315
|
-
case
|
|
302
|
+
case 6 /* SchemeRelative */:
|
|
316
303
|
// The input doesn't have a schema at least, so we need to copy at least that over.
|
|
317
304
|
url.scheme = baseUrl.scheme;
|
|
318
305
|
}
|
|
@@ -324,10 +311,10 @@ function resolve(input, base) {
|
|
|
324
311
|
switch (inputType) {
|
|
325
312
|
// This is impossible, because of the empty checks at the start of the function.
|
|
326
313
|
// case UrlType.Empty:
|
|
327
|
-
case
|
|
328
|
-
case
|
|
314
|
+
case 2 /* Hash */:
|
|
315
|
+
case 3 /* Query */:
|
|
329
316
|
return queryHash;
|
|
330
|
-
case
|
|
317
|
+
case 4 /* RelativePath */: {
|
|
331
318
|
// The first char is always a "/", and we need it to be relative.
|
|
332
319
|
const path = url.path.slice(1);
|
|
333
320
|
if (!path)
|
|
@@ -340,7 +327,7 @@ function resolve(input, base) {
|
|
|
340
327
|
}
|
|
341
328
|
return path + queryHash;
|
|
342
329
|
}
|
|
343
|
-
case
|
|
330
|
+
case 5 /* AbsolutePath */:
|
|
344
331
|
return url.path + queryHash;
|
|
345
332
|
default:
|
|
346
333
|
return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
|
|
@@ -707,8 +694,8 @@ function CallSiteToString() {
|
|
|
707
694
|
let line = "";
|
|
708
695
|
const functionName = this.getFunctionName();
|
|
709
696
|
let addSuffix = true;
|
|
710
|
-
const isConstructor = this.isConstructor()
|
|
711
|
-
if (
|
|
697
|
+
const isConstructor = this.isConstructor();
|
|
698
|
+
if (!(this.isToplevel() || isConstructor)) {
|
|
712
699
|
let typeName = this.getTypeName();
|
|
713
700
|
// Fixes shim to be backward compatible with Node v0 to v4
|
|
714
701
|
if (typeName === "[object Object]") typeName = "null";
|
|
@@ -748,12 +735,7 @@ function wrapCallSite(frame, state) {
|
|
|
748
735
|
if (source) {
|
|
749
736
|
const line = frame.getLineNumber();
|
|
750
737
|
let column = frame.getColumnNumber() - 1;
|
|
751
|
-
|
|
752
|
-
// See https://github.com/evanw/node-source-map-support/issues/36
|
|
753
|
-
// Header removed in node at ^10.16 || >=11.11.0
|
|
754
|
-
// v11 is not an LTS candidate, we can just test the one version with it.
|
|
755
|
-
// Test node versions for: 10.16-19, 10.20+, 12-19, 20-99, 100+, or 11.11
|
|
756
|
-
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)/, headerLength = noHeader.test(globalProcessVersion()) ? 0 : 62;
|
|
738
|
+
const headerLength = /^v(?:10\.1[6-9]|10\.[2-9]\d|10\.\d{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/.test(globalProcessVersion()) ? 0 : 62;
|
|
757
739
|
if (line === 1 && column > headerLength && !frame.isEval()) column -= headerLength;
|
|
758
740
|
const position = mapSourcePosition({
|
|
759
741
|
name: null,
|
|
@@ -826,7 +808,7 @@ function withInlineSourcemap(result, options) {
|
|
|
826
808
|
// this is a bug in Vite
|
|
827
809
|
// all files should be either absolute to the file system or relative to the source map file
|
|
828
810
|
if (isAbsolute(source)) {
|
|
829
|
-
const actualPath = !source.startsWith(withTrailingSlash(options.root)) && source
|
|
811
|
+
const actualPath = !source.startsWith(withTrailingSlash(options.root)) && source[0] === "/" ? resolve$1(options.root, source.slice(1)) : source;
|
|
830
812
|
return relative(dirname(options.filepath), actualPath);
|
|
831
813
|
}
|
|
832
814
|
return source;
|
|
@@ -839,7 +821,7 @@ function withInlineSourcemap(result, options) {
|
|
|
839
821
|
// so that debuggers can be set to break on first line
|
|
840
822
|
// Since Vite 6, import statements at the top of the file are preserved correctly,
|
|
841
823
|
// so we don't need to add this mapping anymore.
|
|
842
|
-
if (!options.noFirstLineMapping && map.mappings
|
|
824
|
+
if (!options.noFirstLineMapping && map.mappings[0] === ";") map.mappings = `AAAA,CAAA${map.mappings}`;
|
|
843
825
|
const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString("base64");
|
|
844
826
|
return result.code = `${code.trimEnd()}\n\n${VITE_NODE_SOURCEMAPPING_SOURCE}\n//# ${VITE_NODE_SOURCEMAPPING_URL};base64,${sourceMap}\n`, result;
|
|
845
827
|
}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs');
|
|
4
|
-
var
|
|
4
|
+
var nodeModule = require('node:module');
|
|
5
5
|
var node_url = require('node:url');
|
|
6
6
|
var pathe = require('pathe');
|
|
7
7
|
|
|
@@ -39,7 +39,7 @@ function splitFileAndPostfix(path) {
|
|
|
39
39
|
postfix: path.slice(file.length)
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const internalRequestRegexp = /* @__PURE__ */ new RegExp(`^/?(?:${["@vite/client", "@vite/env"].join("|")})$`);
|
|
43
43
|
function isInternalRequest(id) {
|
|
44
44
|
return internalRequestRegexp.test(id);
|
|
45
45
|
}
|
|
@@ -50,7 +50,7 @@ const prefixedBuiltins = new Set([
|
|
|
50
50
|
"node:test",
|
|
51
51
|
"node:test/reporters"
|
|
52
52
|
]), builtins = new Set([
|
|
53
|
-
...
|
|
53
|
+
...nodeModule.builtinModules,
|
|
54
54
|
"assert/strict",
|
|
55
55
|
"diagnostics_channel",
|
|
56
56
|
"dns/promises",
|
|
@@ -78,7 +78,7 @@ function toFilePath(id, root) {
|
|
|
78
78
|
exists: true
|
|
79
79
|
};
|
|
80
80
|
// check if /src/module.js -> <root>/src/module.js
|
|
81
|
-
if (!id.startsWith(withTrailingSlash(root)) && id
|
|
81
|
+
if (!id.startsWith(withTrailingSlash(root)) && id[0] === "/") {
|
|
82
82
|
const resolved = pathe.resolve(root, id.slice(1));
|
|
83
83
|
if (fs.existsSync(cleanUrl(resolved))) return {
|
|
84
84
|
absolute: resolved,
|
|
@@ -96,13 +96,13 @@ function toFilePath(id, root) {
|
|
|
96
96
|
if (absolute.startsWith("//")) absolute = absolute.slice(1);
|
|
97
97
|
// disambiguate the `<UNIT>:/` on windows: see nodejs/node#31710
|
|
98
98
|
return {
|
|
99
|
-
path: isWindows && absolute
|
|
99
|
+
path: isWindows && absolute[0] === "/" ? slash(node_url.fileURLToPath(node_url.pathToFileURL(absolute.slice(1)).href)) : absolute,
|
|
100
100
|
exists
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
104
104
|
function isNodeBuiltin(id) {
|
|
105
|
-
return prefixedBuiltins.has(id) ? true : builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
|
|
105
|
+
return nodeModule.isBuiltin ? nodeModule.isBuiltin(id) : prefixedBuiltins.has(id) ? true : builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Convert `Arrayable<T>` to `Array<T>`
|
|
@@ -147,7 +147,7 @@ function createImportMetaEnvProxy() {
|
|
|
147
147
|
];
|
|
148
148
|
return new Proxy(process.env, {
|
|
149
149
|
get(_, key) {
|
|
150
|
-
|
|
150
|
+
if (typeof key === "string") return booleanKeys.includes(key) ? !!process.env[key] : process.env[key];
|
|
151
151
|
},
|
|
152
152
|
set(_, key, value) {
|
|
153
153
|
if (typeof key !== "string") return true;
|
package/dist/utils.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, promises } from 'node:fs';
|
|
2
|
-
import
|
|
2
|
+
import nodeModule from 'node:module';
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
4
|
import { resolve, join, dirname } from 'pathe';
|
|
5
5
|
|
|
@@ -37,7 +37,7 @@ function splitFileAndPostfix(path) {
|
|
|
37
37
|
postfix: path.slice(file.length)
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
const
|
|
40
|
+
const internalRequestRegexp = /* @__PURE__ */ new RegExp(`^/?(?:${["@vite/client", "@vite/env"].join("|")})$`);
|
|
41
41
|
function isInternalRequest(id) {
|
|
42
42
|
return internalRequestRegexp.test(id);
|
|
43
43
|
}
|
|
@@ -48,7 +48,7 @@ const prefixedBuiltins = new Set([
|
|
|
48
48
|
"node:test",
|
|
49
49
|
"node:test/reporters"
|
|
50
50
|
]), builtins = new Set([
|
|
51
|
-
...builtinModules,
|
|
51
|
+
...nodeModule.builtinModules,
|
|
52
52
|
"assert/strict",
|
|
53
53
|
"diagnostics_channel",
|
|
54
54
|
"dns/promises",
|
|
@@ -76,7 +76,7 @@ function toFilePath(id, root) {
|
|
|
76
76
|
exists: true
|
|
77
77
|
};
|
|
78
78
|
// check if /src/module.js -> <root>/src/module.js
|
|
79
|
-
if (!id.startsWith(withTrailingSlash(root)) && id
|
|
79
|
+
if (!id.startsWith(withTrailingSlash(root)) && id[0] === "/") {
|
|
80
80
|
const resolved = resolve(root, id.slice(1));
|
|
81
81
|
if (existsSync(cleanUrl(resolved))) return {
|
|
82
82
|
absolute: resolved,
|
|
@@ -94,13 +94,13 @@ function toFilePath(id, root) {
|
|
|
94
94
|
if (absolute.startsWith("//")) absolute = absolute.slice(1);
|
|
95
95
|
// disambiguate the `<UNIT>:/` on windows: see nodejs/node#31710
|
|
96
96
|
return {
|
|
97
|
-
path: isWindows && absolute
|
|
97
|
+
path: isWindows && absolute[0] === "/" ? slash(fileURLToPath(pathToFileURL(absolute.slice(1)).href)) : absolute,
|
|
98
98
|
exists
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
102
102
|
function isNodeBuiltin(id) {
|
|
103
|
-
return prefixedBuiltins.has(id) ? true : builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
|
|
103
|
+
return nodeModule.isBuiltin ? nodeModule.isBuiltin(id) : prefixedBuiltins.has(id) ? true : builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* Convert `Arrayable<T>` to `Array<T>`
|
|
@@ -145,7 +145,7 @@ function createImportMetaEnvProxy() {
|
|
|
145
145
|
];
|
|
146
146
|
return new Proxy(process.env, {
|
|
147
147
|
get(_, key) {
|
|
148
|
-
|
|
148
|
+
if (typeof key === "string") return booleanKeys.includes(key) ? !!process.env[key] : process.env[key];
|
|
149
149
|
},
|
|
150
150
|
set(_, key, value) {
|
|
151
151
|
if (typeof key !== "string") return true;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.12",
|
|
5
5
|
"description": "Vite as Node.js runtime",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -78,18 +78,18 @@
|
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"cac": "^6.7.14",
|
|
81
|
-
"debug": "^4.4.
|
|
81
|
+
"debug": "^4.4.3",
|
|
82
82
|
"es-module-lexer": "^1.7.0",
|
|
83
83
|
"pathe": "^2.0.3",
|
|
84
84
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@jridgewell/trace-mapping": "
|
|
87
|
+
"@jridgewell/trace-mapping": "0.3.31",
|
|
88
88
|
"@types/debug": "^4.1.12",
|
|
89
|
-
"tinyrainbow": "^
|
|
89
|
+
"tinyrainbow": "^3.0.3"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
|
-
"build": "
|
|
92
|
+
"build": "premove dist && rollup -c",
|
|
93
93
|
"dev": "rollup -c --watch --watch.include 'src/**' -m inline",
|
|
94
94
|
"typecheck": "tsc --noEmit"
|
|
95
95
|
}
|