vite-node 3.2.4 → 4.0.0-beta.10
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 +1 -1
- package/README.md +4 -2
- package/dist/chunk-hmr.cjs +25 -53
- package/dist/chunk-hmr.mjs +25 -53
- package/dist/cli.cjs +15 -36
- package/dist/cli.d.ts +2 -2
- package/dist/cli.mjs +15 -36
- package/dist/client.cjs +43 -107
- package/dist/client.d.ts +2 -2
- package/dist/client.mjs +43 -107
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/hmr.d.ts +4 -7
- package/dist/{index.d-DGmxD2U7.d.ts → index.d-uN06xifv.d.ts} +6 -7
- package/dist/index.d.ts +2 -2
- package/dist/server.cjs +42 -100
- package/dist/server.d.ts +3 -3
- package/dist/server.mjs +42 -100
- package/dist/source-map.cjs +209 -319
- package/dist/source-map.d.ts +4 -4
- package/dist/source-map.mjs +211 -321
- package/dist/{trace-mapping.d-DLVdEqOp.d.ts → trace-mapping.d-BWFx6tPc.d.ts} +6 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils.cjs +13 -33
- package/dist/utils.d.ts +5 -5
- package/dist/utils.mjs +13 -33
- package/package.json +2 -2
|
@@ -36,6 +36,11 @@ declare abstract class SourceMap {
|
|
|
36
36
|
resolvedSources: SourceMapV3['sources'];
|
|
37
37
|
ignoreList: SourceMapV3['ignoreList'];
|
|
38
38
|
}
|
|
39
|
+
type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
|
|
40
|
+
type RoArray<T> = Ro<T>[];
|
|
41
|
+
type RoObject<T> = {
|
|
42
|
+
[K in keyof T]: T[K] | Ro<T[K]>;
|
|
43
|
+
};
|
|
39
44
|
|
|
40
45
|
declare class TraceMap implements SourceMap {
|
|
41
46
|
version: SourceMapV3['version'];
|
|
@@ -51,7 +56,7 @@ declare class TraceMap implements SourceMap {
|
|
|
51
56
|
private _decodedMemo;
|
|
52
57
|
private _bySources;
|
|
53
58
|
private _bySourceMemos;
|
|
54
|
-
constructor(map: SourceMapInput
|
|
59
|
+
constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
export type { DecodedSourceMap as D, EncodedSourceMap as E, SourceMapInput as S };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-
|
|
2
|
-
export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-
|
|
1
|
+
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-BWFx6tPc.js';
|
|
2
|
+
export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-uN06xifv.js';
|
package/dist/utils.cjs
CHANGED
|
@@ -6,10 +6,7 @@ var node_url = require('node:url');
|
|
|
6
6
|
var pathe = require('pathe');
|
|
7
7
|
|
|
8
8
|
const isWindows = process.platform === "win32";
|
|
9
|
-
const drive = isWindows ? process.cwd()[0] : null;
|
|
10
|
-
const driveOpposite = drive ? drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase() : null;
|
|
11
|
-
const driveRegexp = drive ? new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
|
|
12
|
-
const driveOppositeRegext = driveOpposite ? new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
|
|
9
|
+
const drive = isWindows ? process.cwd()[0] : null, driveOpposite = drive ? drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase() : null, driveRegexp = drive ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null, driveOppositeRegext = driveOpposite ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
|
|
13
10
|
function slash(str) {
|
|
14
11
|
return str.replace(/\\/g, "/");
|
|
15
12
|
}
|
|
@@ -42,8 +39,7 @@ function splitFileAndPostfix(path) {
|
|
|
42
39
|
postfix: path.slice(file.length)
|
|
43
40
|
};
|
|
44
41
|
}
|
|
45
|
-
const internalRequests = ["@vite/client", "@vite/env"];
|
|
46
|
-
const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join("|")})$`);
|
|
42
|
+
const internalRequests = ["@vite/client", "@vite/env"], internalRequestRegexp = /* @__PURE__ */ new RegExp(`^/?(?:${internalRequests.join("|")})$`);
|
|
47
43
|
function isInternalRequest(id) {
|
|
48
44
|
return internalRequestRegexp.test(id);
|
|
49
45
|
}
|
|
@@ -53,8 +49,7 @@ const prefixedBuiltins = new Set([
|
|
|
53
49
|
"node:sqlite",
|
|
54
50
|
"node:test",
|
|
55
51
|
"node:test/reporters"
|
|
56
|
-
])
|
|
57
|
-
const builtins = new Set([
|
|
52
|
+
]), builtins = new Set([
|
|
58
53
|
...node_module.builtinModules,
|
|
59
54
|
"assert/strict",
|
|
60
55
|
"diagnostics_channel",
|
|
@@ -71,10 +66,7 @@ const builtins = new Set([
|
|
|
71
66
|
"wasi"
|
|
72
67
|
]);
|
|
73
68
|
function normalizeModuleId(id) {
|
|
74
|
-
|
|
75
|
-
if (prefixedBuiltins.has(id)) return id;
|
|
76
|
-
if (id.startsWith("file://")) return node_url.fileURLToPath(id);
|
|
77
|
-
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
69
|
+
return prefixedBuiltins.has(id) ? id : id.startsWith("file://") ? node_url.fileURLToPath(id) : id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
78
70
|
}
|
|
79
71
|
function isPrimitive(v) {
|
|
80
72
|
return v !== Object(v);
|
|
@@ -110,8 +102,7 @@ function toFilePath(id, root) {
|
|
|
110
102
|
}
|
|
111
103
|
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
112
104
|
function isNodeBuiltin(id) {
|
|
113
|
-
|
|
114
|
-
return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(NODE_BUILTIN_NAMESPACE.length) : id);
|
|
105
|
+
return prefixedBuiltins.has(id) ? true : builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
|
|
115
106
|
}
|
|
116
107
|
/**
|
|
117
108
|
* Convert `Arrayable<T>` to `Array<T>`
|
|
@@ -120,21 +111,16 @@ function isNodeBuiltin(id) {
|
|
|
120
111
|
*/
|
|
121
112
|
function toArray(array) {
|
|
122
113
|
if (array === null || array === void 0) array = [];
|
|
123
|
-
|
|
124
|
-
return [array];
|
|
114
|
+
return Array.isArray(array) ? array : [array];
|
|
125
115
|
}
|
|
126
116
|
function getCachedData(cache, basedir, originalBasedir) {
|
|
127
117
|
const pkgData = cache.get(getFnpdCacheKey(basedir));
|
|
128
|
-
if (pkgData) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
return pkgData;
|
|
133
|
-
}
|
|
118
|
+
if (pkgData) return traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
119
|
+
cache.set(getFnpdCacheKey(dir), pkgData);
|
|
120
|
+
}), pkgData;
|
|
134
121
|
}
|
|
135
122
|
function setCacheData(cache, data, basedir, originalBasedir) {
|
|
136
|
-
cache.set(getFnpdCacheKey(basedir), data)
|
|
137
|
-
traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
123
|
+
cache.set(getFnpdCacheKey(basedir), data), traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
138
124
|
cache.set(getFnpdCacheKey(dir), data);
|
|
139
125
|
});
|
|
140
126
|
}
|
|
@@ -147,14 +133,10 @@ function getFnpdCacheKey(basedir) {
|
|
|
147
133
|
* @param shorterDir Shorter dir path, e.g. `/User/foo`
|
|
148
134
|
*/
|
|
149
135
|
function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
150
|
-
while (longerDir !== shorterDir)
|
|
151
|
-
cb(longerDir);
|
|
152
|
-
longerDir = pathe.dirname(longerDir);
|
|
153
|
-
}
|
|
136
|
+
while (longerDir !== shorterDir) cb(longerDir), longerDir = pathe.dirname(longerDir);
|
|
154
137
|
}
|
|
155
138
|
function withTrailingSlash(path) {
|
|
156
|
-
|
|
157
|
-
return path;
|
|
139
|
+
return path.at(-1) === "/" ? path : `${path}/`;
|
|
158
140
|
}
|
|
159
141
|
function createImportMetaEnvProxy() {
|
|
160
142
|
// packages/vitest/src/node/plugins/index.ts:146
|
|
@@ -165,9 +147,7 @@ function createImportMetaEnvProxy() {
|
|
|
165
147
|
];
|
|
166
148
|
return new Proxy(process.env, {
|
|
167
149
|
get(_, key) {
|
|
168
|
-
|
|
169
|
-
if (booleanKeys.includes(key)) return !!process.env[key];
|
|
170
|
-
return process.env[key];
|
|
150
|
+
return typeof key === "string" ? booleanKeys.includes(key) ? !!process.env[key] : process.env[key] : void 0;
|
|
171
151
|
},
|
|
172
152
|
set(_, key, value) {
|
|
173
153
|
if (typeof key !== "string") return true;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Nullable, A as Arrayable } from './index.d-
|
|
2
|
-
import './trace-mapping.d-
|
|
1
|
+
import { N as Nullable, A as Arrayable } from './index.d-uN06xifv.js';
|
|
2
|
+
import './trace-mapping.d-BWFx6tPc.js';
|
|
3
3
|
|
|
4
4
|
declare const isWindows: boolean;
|
|
5
5
|
declare function slash(str: string): string;
|
|
@@ -11,8 +11,8 @@ declare function isInternalRequest(id: string): boolean;
|
|
|
11
11
|
declare function normalizeModuleId(id: string): string;
|
|
12
12
|
declare function isPrimitive(v: any): boolean;
|
|
13
13
|
declare function toFilePath(id: string, root: string): {
|
|
14
|
-
path: string
|
|
15
|
-
exists: boolean
|
|
14
|
+
path: string;
|
|
15
|
+
exists: boolean;
|
|
16
16
|
};
|
|
17
17
|
declare function isNodeBuiltin(id: string): boolean;
|
|
18
18
|
/**
|
|
@@ -26,7 +26,7 @@ declare function setCacheData<T>(cache: Map<string, T>, data: T, basedir: string
|
|
|
26
26
|
declare function withTrailingSlash(path: string): string;
|
|
27
27
|
declare function createImportMetaEnvProxy(): NodeJS.ProcessEnv;
|
|
28
28
|
declare function findNearestPackageData(basedir: string): Promise<{
|
|
29
|
-
type?: "module" | "commonjs"
|
|
29
|
+
type?: "module" | "commonjs";
|
|
30
30
|
}>;
|
|
31
31
|
|
|
32
32
|
export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, findNearestPackageData, getCachedData, isBareImport, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
|
package/dist/utils.mjs
CHANGED
|
@@ -4,10 +4,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
4
4
|
import { resolve, join, dirname } from 'pathe';
|
|
5
5
|
|
|
6
6
|
const isWindows = process.platform === "win32";
|
|
7
|
-
const drive = isWindows ? process.cwd()[0] : null;
|
|
8
|
-
const driveOpposite = drive ? drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase() : null;
|
|
9
|
-
const driveRegexp = drive ? new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
|
|
10
|
-
const driveOppositeRegext = driveOpposite ? new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
|
|
7
|
+
const drive = isWindows ? process.cwd()[0] : null, driveOpposite = drive ? drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase() : null, driveRegexp = drive ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null, driveOppositeRegext = driveOpposite ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
|
|
11
8
|
function slash(str) {
|
|
12
9
|
return str.replace(/\\/g, "/");
|
|
13
10
|
}
|
|
@@ -40,8 +37,7 @@ function splitFileAndPostfix(path) {
|
|
|
40
37
|
postfix: path.slice(file.length)
|
|
41
38
|
};
|
|
42
39
|
}
|
|
43
|
-
const internalRequests = ["@vite/client", "@vite/env"];
|
|
44
|
-
const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join("|")})$`);
|
|
40
|
+
const internalRequests = ["@vite/client", "@vite/env"], internalRequestRegexp = /* @__PURE__ */ new RegExp(`^/?(?:${internalRequests.join("|")})$`);
|
|
45
41
|
function isInternalRequest(id) {
|
|
46
42
|
return internalRequestRegexp.test(id);
|
|
47
43
|
}
|
|
@@ -51,8 +47,7 @@ const prefixedBuiltins = new Set([
|
|
|
51
47
|
"node:sqlite",
|
|
52
48
|
"node:test",
|
|
53
49
|
"node:test/reporters"
|
|
54
|
-
])
|
|
55
|
-
const builtins = new Set([
|
|
50
|
+
]), builtins = new Set([
|
|
56
51
|
...builtinModules,
|
|
57
52
|
"assert/strict",
|
|
58
53
|
"diagnostics_channel",
|
|
@@ -69,10 +64,7 @@ const builtins = new Set([
|
|
|
69
64
|
"wasi"
|
|
70
65
|
]);
|
|
71
66
|
function normalizeModuleId(id) {
|
|
72
|
-
|
|
73
|
-
if (prefixedBuiltins.has(id)) return id;
|
|
74
|
-
if (id.startsWith("file://")) return fileURLToPath(id);
|
|
75
|
-
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
67
|
+
return prefixedBuiltins.has(id) ? id : id.startsWith("file://") ? fileURLToPath(id) : id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
76
68
|
}
|
|
77
69
|
function isPrimitive(v) {
|
|
78
70
|
return v !== Object(v);
|
|
@@ -108,8 +100,7 @@ function toFilePath(id, root) {
|
|
|
108
100
|
}
|
|
109
101
|
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
110
102
|
function isNodeBuiltin(id) {
|
|
111
|
-
|
|
112
|
-
return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(NODE_BUILTIN_NAMESPACE.length) : id);
|
|
103
|
+
return prefixedBuiltins.has(id) ? true : builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
|
|
113
104
|
}
|
|
114
105
|
/**
|
|
115
106
|
* Convert `Arrayable<T>` to `Array<T>`
|
|
@@ -118,21 +109,16 @@ function isNodeBuiltin(id) {
|
|
|
118
109
|
*/
|
|
119
110
|
function toArray(array) {
|
|
120
111
|
if (array === null || array === void 0) array = [];
|
|
121
|
-
|
|
122
|
-
return [array];
|
|
112
|
+
return Array.isArray(array) ? array : [array];
|
|
123
113
|
}
|
|
124
114
|
function getCachedData(cache, basedir, originalBasedir) {
|
|
125
115
|
const pkgData = cache.get(getFnpdCacheKey(basedir));
|
|
126
|
-
if (pkgData) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
return pkgData;
|
|
131
|
-
}
|
|
116
|
+
if (pkgData) return traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
117
|
+
cache.set(getFnpdCacheKey(dir), pkgData);
|
|
118
|
+
}), pkgData;
|
|
132
119
|
}
|
|
133
120
|
function setCacheData(cache, data, basedir, originalBasedir) {
|
|
134
|
-
cache.set(getFnpdCacheKey(basedir), data)
|
|
135
|
-
traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
121
|
+
cache.set(getFnpdCacheKey(basedir), data), traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
136
122
|
cache.set(getFnpdCacheKey(dir), data);
|
|
137
123
|
});
|
|
138
124
|
}
|
|
@@ -145,14 +131,10 @@ function getFnpdCacheKey(basedir) {
|
|
|
145
131
|
* @param shorterDir Shorter dir path, e.g. `/User/foo`
|
|
146
132
|
*/
|
|
147
133
|
function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
148
|
-
while (longerDir !== shorterDir)
|
|
149
|
-
cb(longerDir);
|
|
150
|
-
longerDir = dirname(longerDir);
|
|
151
|
-
}
|
|
134
|
+
while (longerDir !== shorterDir) cb(longerDir), longerDir = dirname(longerDir);
|
|
152
135
|
}
|
|
153
136
|
function withTrailingSlash(path) {
|
|
154
|
-
|
|
155
|
-
return path;
|
|
137
|
+
return path.at(-1) === "/" ? path : `${path}/`;
|
|
156
138
|
}
|
|
157
139
|
function createImportMetaEnvProxy() {
|
|
158
140
|
// packages/vitest/src/node/plugins/index.ts:146
|
|
@@ -163,9 +145,7 @@ function createImportMetaEnvProxy() {
|
|
|
163
145
|
];
|
|
164
146
|
return new Proxy(process.env, {
|
|
165
147
|
get(_, key) {
|
|
166
|
-
|
|
167
|
-
if (booleanKeys.includes(key)) return !!process.env[key];
|
|
168
|
-
return process.env[key];
|
|
148
|
+
return typeof key === "string" ? booleanKeys.includes(key) ? !!process.env[key] : process.env[key] : void 0;
|
|
169
149
|
},
|
|
170
150
|
set(_, key, value) {
|
|
171
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
|
+
"version": "4.0.0-beta.10",
|
|
5
5
|
"description": "Vite as Node.js runtime",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@jridgewell/trace-mapping": "^0.3.
|
|
87
|
+
"@jridgewell/trace-mapping": "^0.3.30",
|
|
88
88
|
"@types/debug": "^4.1.12",
|
|
89
89
|
"tinyrainbow": "^2.0.0"
|
|
90
90
|
},
|