vite-node 3.2.0-beta.2 → 3.2.0-beta.3
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 +19 -3
- package/dist/chunk-hmr.mjs +19 -3
- package/dist/cli.cjs +5 -2
- package/dist/cli.mjs +5 -2
- package/dist/client.cjs +29 -0
- package/dist/client.mjs +29 -0
- package/dist/hmr.d.ts +3 -0
- package/dist/server.cjs +22 -1
- package/dist/server.mjs +22 -1
- package/dist/source-map.cjs +84 -3
- package/dist/source-map.mjs +84 -3
- package/dist/utils.cjs +9 -0
- package/dist/utils.mjs +9 -0
- package/package.json +3 -3
package/dist/utils.cjs
CHANGED
|
@@ -20,8 +20,12 @@ function isBareImport(id) {
|
|
|
20
20
|
const VALID_ID_PREFIX = "/@id/";
|
|
21
21
|
function normalizeRequestId(id, base) {
|
|
22
22
|
if (base && id.startsWith(withTrailingSlash(base))) id = `/${id.slice(base.length)}`;
|
|
23
|
+
// keep drive the same as in process cwd. ideally, this should be resolved on Vite side
|
|
24
|
+
// Vite always resolves drive letters to the upper case because of the use of `realpathSync`
|
|
25
|
+
// https://github.com/vitejs/vite/blob/0ab20a3ee26eacf302415b3087732497d0a2f358/packages/vite/src/node/utils.ts#L635
|
|
23
26
|
if (driveRegexp && !(driveRegexp === null || driveRegexp === void 0 ? void 0 : driveRegexp.test(id)) && (driveOppositeRegext === null || driveOppositeRegext === void 0 ? void 0 : driveOppositeRegext.test(id))) id = id.replace(driveOppositeRegext, `${drive}$1`);
|
|
24
27
|
if (id.startsWith("file://")) {
|
|
28
|
+
// preserve hash/query
|
|
25
29
|
const { file, postfix } = splitFileAndPostfix(id);
|
|
26
30
|
return node_url.fileURLToPath(file) + postfix;
|
|
27
31
|
}
|
|
@@ -43,6 +47,7 @@ const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join("|")})$`
|
|
|
43
47
|
function isInternalRequest(id) {
|
|
44
48
|
return internalRequestRegexp.test(id);
|
|
45
49
|
}
|
|
50
|
+
// https://nodejs.org/api/modules.html#built-in-modules-with-mandatory-node-prefix
|
|
46
51
|
const prefixedBuiltins = new Set([
|
|
47
52
|
"node:sea",
|
|
48
53
|
"node:sqlite",
|
|
@@ -66,6 +71,7 @@ const builtins = new Set([
|
|
|
66
71
|
"wasi"
|
|
67
72
|
]);
|
|
68
73
|
function normalizeModuleId(id) {
|
|
74
|
+
// unique id that is not available as "test"
|
|
69
75
|
if (prefixedBuiltins.has(id)) return id;
|
|
70
76
|
if (id.startsWith("file://")) return node_url.fileURLToPath(id);
|
|
71
77
|
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
@@ -79,6 +85,7 @@ function toFilePath(id, root) {
|
|
|
79
85
|
absolute: id.slice(4),
|
|
80
86
|
exists: true
|
|
81
87
|
};
|
|
88
|
+
// check if /src/module.js -> <root>/src/module.js
|
|
82
89
|
if (!id.startsWith(withTrailingSlash(root)) && id.startsWith("/")) {
|
|
83
90
|
const resolved = pathe.resolve(root, id.slice(1));
|
|
84
91
|
if (fs.existsSync(cleanUrl(resolved))) return {
|
|
@@ -95,6 +102,7 @@ function toFilePath(id, root) {
|
|
|
95
102
|
};
|
|
96
103
|
})();
|
|
97
104
|
if (absolute.startsWith("//")) absolute = absolute.slice(1);
|
|
105
|
+
// disambiguate the `<UNIT>:/` on windows: see nodejs/node#31710
|
|
98
106
|
return {
|
|
99
107
|
path: isWindows && absolute.startsWith("/") ? slash(node_url.fileURLToPath(node_url.pathToFileURL(absolute.slice(1)).href)) : absolute,
|
|
100
108
|
exists
|
|
@@ -149,6 +157,7 @@ function withTrailingSlash(path) {
|
|
|
149
157
|
return path;
|
|
150
158
|
}
|
|
151
159
|
function createImportMetaEnvProxy() {
|
|
160
|
+
// packages/vitest/src/node/plugins/index.ts:146
|
|
152
161
|
const booleanKeys = [
|
|
153
162
|
"DEV",
|
|
154
163
|
"PROD",
|
package/dist/utils.mjs
CHANGED
|
@@ -18,8 +18,12 @@ function isBareImport(id) {
|
|
|
18
18
|
const VALID_ID_PREFIX = "/@id/";
|
|
19
19
|
function normalizeRequestId(id, base) {
|
|
20
20
|
if (base && id.startsWith(withTrailingSlash(base))) id = `/${id.slice(base.length)}`;
|
|
21
|
+
// keep drive the same as in process cwd. ideally, this should be resolved on Vite side
|
|
22
|
+
// Vite always resolves drive letters to the upper case because of the use of `realpathSync`
|
|
23
|
+
// https://github.com/vitejs/vite/blob/0ab20a3ee26eacf302415b3087732497d0a2f358/packages/vite/src/node/utils.ts#L635
|
|
21
24
|
if (driveRegexp && !(driveRegexp === null || driveRegexp === void 0 ? void 0 : driveRegexp.test(id)) && (driveOppositeRegext === null || driveOppositeRegext === void 0 ? void 0 : driveOppositeRegext.test(id))) id = id.replace(driveOppositeRegext, `${drive}$1`);
|
|
22
25
|
if (id.startsWith("file://")) {
|
|
26
|
+
// preserve hash/query
|
|
23
27
|
const { file, postfix } = splitFileAndPostfix(id);
|
|
24
28
|
return fileURLToPath(file) + postfix;
|
|
25
29
|
}
|
|
@@ -41,6 +45,7 @@ const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join("|")})$`
|
|
|
41
45
|
function isInternalRequest(id) {
|
|
42
46
|
return internalRequestRegexp.test(id);
|
|
43
47
|
}
|
|
48
|
+
// https://nodejs.org/api/modules.html#built-in-modules-with-mandatory-node-prefix
|
|
44
49
|
const prefixedBuiltins = new Set([
|
|
45
50
|
"node:sea",
|
|
46
51
|
"node:sqlite",
|
|
@@ -64,6 +69,7 @@ const builtins = new Set([
|
|
|
64
69
|
"wasi"
|
|
65
70
|
]);
|
|
66
71
|
function normalizeModuleId(id) {
|
|
72
|
+
// unique id that is not available as "test"
|
|
67
73
|
if (prefixedBuiltins.has(id)) return id;
|
|
68
74
|
if (id.startsWith("file://")) return fileURLToPath(id);
|
|
69
75
|
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
@@ -77,6 +83,7 @@ function toFilePath(id, root) {
|
|
|
77
83
|
absolute: id.slice(4),
|
|
78
84
|
exists: true
|
|
79
85
|
};
|
|
86
|
+
// check if /src/module.js -> <root>/src/module.js
|
|
80
87
|
if (!id.startsWith(withTrailingSlash(root)) && id.startsWith("/")) {
|
|
81
88
|
const resolved = resolve(root, id.slice(1));
|
|
82
89
|
if (existsSync(cleanUrl(resolved))) return {
|
|
@@ -93,6 +100,7 @@ function toFilePath(id, root) {
|
|
|
93
100
|
};
|
|
94
101
|
})();
|
|
95
102
|
if (absolute.startsWith("//")) absolute = absolute.slice(1);
|
|
103
|
+
// disambiguate the `<UNIT>:/` on windows: see nodejs/node#31710
|
|
96
104
|
return {
|
|
97
105
|
path: isWindows && absolute.startsWith("/") ? slash(fileURLToPath(pathToFileURL(absolute.slice(1)).href)) : absolute,
|
|
98
106
|
exists
|
|
@@ -147,6 +155,7 @@ function withTrailingSlash(path) {
|
|
|
147
155
|
return path;
|
|
148
156
|
}
|
|
149
157
|
function createImportMetaEnvProxy() {
|
|
158
|
+
// packages/vitest/src/node/plugins/index.ts:146
|
|
150
159
|
const booleanKeys = [
|
|
151
160
|
"DEV",
|
|
152
161
|
"PROD",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.2.0-beta.
|
|
4
|
+
"version": "3.2.0-beta.3",
|
|
5
5
|
"description": "Vite as Node.js runtime",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -78,10 +78,10 @@
|
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"cac": "^6.7.14",
|
|
81
|
-
"debug": "^4.4.
|
|
81
|
+
"debug": "^4.4.1",
|
|
82
82
|
"es-module-lexer": "^1.7.0",
|
|
83
83
|
"pathe": "^2.0.3",
|
|
84
|
-
"vite": "^5.0.0 || ^6.0.0"
|
|
84
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@jridgewell/trace-mapping": "^0.3.25",
|