vite-node 4.0.0-beta.10 → 4.0.0-beta.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/dist/chunk-hmr.cjs +4 -4
- package/dist/chunk-hmr.mjs +4 -4
- 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 +2 -2
- package/dist/hmr.cjs +1 -1
- package/dist/hmr.mjs +1 -1
- package/dist/server.cjs +4 -4
- package/dist/server.mjs +4 -4
- package/dist/source-map.cjs +86 -89
- package/dist/source-map.mjs +86 -89
- package/dist/utils.cjs +5 -5
- package/dist/utils.mjs +5 -5
- package/package.json +3 -3
package/dist/chunk-hmr.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var node_events = require('node:events');
|
|
4
4
|
var createDebug = require('debug');
|
|
5
|
-
var
|
|
5
|
+
var index = require('./chunk-index.cjs');
|
|
6
6
|
var utils = require('./utils.cjs');
|
|
7
7
|
|
|
8
8
|
function createHmrEmitter() {
|
|
@@ -93,7 +93,7 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
|
93
93
|
return () => {
|
|
94
94
|
for (const { deps, fn } of qualifiedCallbacks) fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
|
|
95
95
|
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
|
96
|
-
console.log(`${
|
|
96
|
+
console.log(`${index.C.cyan("[vite-node]")} hot updated: ${loggedPath}`);
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
function warnFailedFetch(err, path) {
|
|
@@ -108,7 +108,7 @@ async function handleMessage(runner, emitter, files, payload) {
|
|
|
108
108
|
break;
|
|
109
109
|
case "update":
|
|
110
110
|
await notifyListeners(runner, "vite:beforeUpdate", payload), await Promise.all(payload.updates.map((update) => {
|
|
111
|
-
return update.type === "js-update" ? queueUpdate(runner, fetchUpdate(runner, update)) : (console.error(`${
|
|
111
|
+
return update.type === "js-update" ? queueUpdate(runner, fetchUpdate(runner, update)) : (console.error(`${index.C.cyan("[vite-node]")} no support css hmr.}`), null);
|
|
112
112
|
})), await notifyListeners(runner, "vite:afterUpdate", payload);
|
|
113
113
|
break;
|
|
114
114
|
case "full-reload":
|
|
@@ -126,7 +126,7 @@ async function handleMessage(runner, emitter, files, payload) {
|
|
|
126
126
|
case "error": {
|
|
127
127
|
await notifyListeners(runner, "vite:error", payload);
|
|
128
128
|
const err = payload.err;
|
|
129
|
-
console.error(`${
|
|
129
|
+
console.error(`${index.C.cyan("[vite-node]")} Internal Server Error\n${err.message}\n${err.stack}`);
|
|
130
130
|
break;
|
|
131
131
|
}
|
|
132
132
|
}
|
package/dist/chunk-hmr.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import createDebug from 'debug';
|
|
3
|
-
import {
|
|
3
|
+
import { C } from './chunk-index.mjs';
|
|
4
4
|
import { normalizeRequestId } from './utils.mjs';
|
|
5
5
|
|
|
6
6
|
function createHmrEmitter() {
|
|
@@ -91,7 +91,7 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
|
91
91
|
return () => {
|
|
92
92
|
for (const { deps, fn } of qualifiedCallbacks) fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
|
|
93
93
|
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
|
94
|
-
console.log(`${
|
|
94
|
+
console.log(`${C.cyan("[vite-node]")} hot updated: ${loggedPath}`);
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
function warnFailedFetch(err, path) {
|
|
@@ -106,7 +106,7 @@ async function handleMessage(runner, emitter, files, payload) {
|
|
|
106
106
|
break;
|
|
107
107
|
case "update":
|
|
108
108
|
await notifyListeners(runner, "vite:beforeUpdate", payload), await Promise.all(payload.updates.map((update) => {
|
|
109
|
-
return update.type === "js-update" ? queueUpdate(runner, fetchUpdate(runner, update)) : (console.error(`${
|
|
109
|
+
return update.type === "js-update" ? queueUpdate(runner, fetchUpdate(runner, update)) : (console.error(`${C.cyan("[vite-node]")} no support css hmr.}`), null);
|
|
110
110
|
})), await notifyListeners(runner, "vite:afterUpdate", payload);
|
|
111
111
|
break;
|
|
112
112
|
case "full-reload":
|
|
@@ -124,7 +124,7 @@ async function handleMessage(runner, emitter, files, payload) {
|
|
|
124
124
|
case "error": {
|
|
125
125
|
await notifyListeners(runner, "vite:error", payload);
|
|
126
126
|
const err = payload.err;
|
|
127
|
-
console.error(`${
|
|
127
|
+
console.error(`${C.cyan("[vite-node]")} Internal Server Error\n${err.message}\n${err.stack}`);
|
|
128
128
|
break;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
var
|
|
4
|
+
var d = {
|
|
5
5
|
reset: [0, 0],
|
|
6
6
|
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
7
7
|
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
@@ -43,41 +43,42 @@ var f = {
|
|
|
43
43
|
bgMagentaBright: [105, 49],
|
|
44
44
|
bgCyanBright: [106, 49],
|
|
45
45
|
bgWhiteBright: [107, 49]
|
|
46
|
-
}
|
|
47
|
-
function
|
|
48
|
-
return String(
|
|
46
|
+
};
|
|
47
|
+
function g(e) {
|
|
48
|
+
return String(e);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
let e = typeof process != "undefined" ? process : void 0,
|
|
54
|
-
return !("NO_COLOR" in
|
|
50
|
+
g.open = "";
|
|
51
|
+
g.close = "";
|
|
52
|
+
function h() {
|
|
53
|
+
let e = typeof process != "undefined" ? process : void 0, n = (e == null ? void 0 : e.env) || {}, a = n.FORCE_TTY !== "false", i = (e == null ? void 0 : e.argv) || [];
|
|
54
|
+
return !("NO_COLOR" in n || i.includes("--no-color")) && ("FORCE_COLOR" in n || i.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && n.TERM !== "dumb" || "CI" in n) || typeof window != "undefined" && !!window.chrome;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
let e =
|
|
56
|
+
function f() {
|
|
57
|
+
let e = h(), n = (r, t, u, o) => {
|
|
58
58
|
let l = "", s = 0;
|
|
59
59
|
do
|
|
60
|
-
l += r.substring(s, o) +
|
|
60
|
+
l += r.substring(s, o) + u, s = o + t.length, o = r.indexOf(t, s);
|
|
61
61
|
while (~o);
|
|
62
62
|
return l + r.substring(s);
|
|
63
|
-
},
|
|
63
|
+
}, a = (r, t, u = r) => {
|
|
64
64
|
let o = (l) => {
|
|
65
65
|
let s = String(l), b = s.indexOf(t, r.length);
|
|
66
|
-
return ~b ? r +
|
|
66
|
+
return ~b ? r + n(s, t, u, b) + t : r + s + t;
|
|
67
67
|
};
|
|
68
68
|
return o.open = r, o.close = t, o;
|
|
69
|
-
},
|
|
69
|
+
}, i = {
|
|
70
70
|
isColorSupported: e
|
|
71
|
-
},
|
|
72
|
-
for (let
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
}, c = (r) => `\x1B[${r}m`;
|
|
72
|
+
for (let r in d) {
|
|
73
|
+
let t = d[r];
|
|
74
|
+
i[r] = e ? a(
|
|
75
|
+
c(t[0]),
|
|
76
|
+
c(t[1]),
|
|
76
77
|
t[2]
|
|
77
|
-
) :
|
|
78
|
-
|
|
78
|
+
) : g;
|
|
79
|
+
}
|
|
80
|
+
return i;
|
|
79
81
|
}
|
|
82
|
+
var C = f();
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
exports.s = s;
|
|
84
|
+
exports.C = C;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
var
|
|
2
|
+
var d = {
|
|
3
3
|
reset: [0, 0],
|
|
4
4
|
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
5
5
|
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
@@ -41,41 +41,42 @@ var f = {
|
|
|
41
41
|
bgMagentaBright: [105, 49],
|
|
42
42
|
bgCyanBright: [106, 49],
|
|
43
43
|
bgWhiteBright: [107, 49]
|
|
44
|
-
}
|
|
45
|
-
function
|
|
46
|
-
return String(
|
|
44
|
+
};
|
|
45
|
+
function g(e) {
|
|
46
|
+
return String(e);
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
function
|
|
51
|
-
let e = typeof process != "undefined" ? process : void 0,
|
|
52
|
-
return !("NO_COLOR" in
|
|
48
|
+
g.open = "";
|
|
49
|
+
g.close = "";
|
|
50
|
+
function h() {
|
|
51
|
+
let e = typeof process != "undefined" ? process : void 0, n = (e == null ? void 0 : e.env) || {}, a = n.FORCE_TTY !== "false", i = (e == null ? void 0 : e.argv) || [];
|
|
52
|
+
return !("NO_COLOR" in n || i.includes("--no-color")) && ("FORCE_COLOR" in n || i.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && n.TERM !== "dumb" || "CI" in n) || typeof window != "undefined" && !!window.chrome;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
let e =
|
|
54
|
+
function f() {
|
|
55
|
+
let e = h(), n = (r, t, u, o) => {
|
|
56
56
|
let l = "", s = 0;
|
|
57
57
|
do
|
|
58
|
-
l += r.substring(s, o) +
|
|
58
|
+
l += r.substring(s, o) + u, s = o + t.length, o = r.indexOf(t, s);
|
|
59
59
|
while (~o);
|
|
60
60
|
return l + r.substring(s);
|
|
61
|
-
},
|
|
61
|
+
}, a = (r, t, u = r) => {
|
|
62
62
|
let o = (l) => {
|
|
63
63
|
let s = String(l), b = s.indexOf(t, r.length);
|
|
64
|
-
return ~b ? r +
|
|
64
|
+
return ~b ? r + n(s, t, u, b) + t : r + s + t;
|
|
65
65
|
};
|
|
66
66
|
return o.open = r, o.close = t, o;
|
|
67
|
-
},
|
|
67
|
+
}, i = {
|
|
68
68
|
isColorSupported: e
|
|
69
|
-
},
|
|
70
|
-
for (let
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
}, c = (r) => `\x1B[${r}m`;
|
|
70
|
+
for (let r in d) {
|
|
71
|
+
let t = d[r];
|
|
72
|
+
i[r] = e ? a(
|
|
73
|
+
c(t[0]),
|
|
74
|
+
c(t[1]),
|
|
74
75
|
t[2]
|
|
75
|
-
) :
|
|
76
|
-
|
|
76
|
+
) : g;
|
|
77
|
+
}
|
|
78
|
+
return i;
|
|
77
79
|
}
|
|
80
|
+
var C = f();
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
export { s };
|
|
82
|
+
export { C };
|
package/dist/cli.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var path = require('node:path');
|
|
4
4
|
var cac = require('cac');
|
|
5
|
-
var
|
|
5
|
+
var index = require('./chunk-index.cjs');
|
|
6
6
|
var vite = require('vite');
|
|
7
7
|
var client = require('./client.cjs');
|
|
8
8
|
var hmr = require('./chunk-hmr.cjs');
|
|
@@ -21,7 +21,7 @@ require('node:perf_hooks');
|
|
|
21
21
|
require('es-module-lexer');
|
|
22
22
|
require('./constants.cjs');
|
|
23
23
|
|
|
24
|
-
var version = "4.0.0-beta.
|
|
24
|
+
var version = "4.0.0-beta.11";
|
|
25
25
|
|
|
26
26
|
const cli = cac("vite-node");
|
|
27
27
|
if (cli.option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", "Restart on file changes, similar to \"nodemon\"").option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command"), cli.command("[...files]").allowUnknownOptions().action(run), cli.parse(process.argv, { run: false }), cli.args.length === 0) cli.runMatchedCommand();
|
|
@@ -43,7 +43,7 @@ async function run(files, options = {}) {
|
|
|
43
43
|
else process.argv = [...process.argv.slice(0, 2), ...options["--"] || []];
|
|
44
44
|
if (options.version) cli.version(version), cli.outputVersion(), process.exit(0);
|
|
45
45
|
if (options.help) cli.version(version).outputHelp(), process.exit(0);
|
|
46
|
-
if (!files.length) console.error(
|
|
46
|
+
if (!files.length) console.error(index.C.red("No files specified.")), cli.version(version).outputHelp(), process.exit(1);
|
|
47
47
|
const serverOptions = options.options ? parseServerOptions(options.options) : {}, server$1 = await vite.createServer({
|
|
48
48
|
logLevel: "error",
|
|
49
49
|
configFile: options.config,
|
|
@@ -86,7 +86,7 @@ async function run(files, options = {}) {
|
|
|
86
86
|
if ((_server$emitter = server$1.emitter) === null || _server$emitter === void 0 || _server$emitter.on("message", (payload) => {
|
|
87
87
|
hmr.handleMessage(runner, server$1.emitter, files, payload);
|
|
88
88
|
}), options.watch) process.on("uncaughtException", (err) => {
|
|
89
|
-
console.error(
|
|
89
|
+
console.error(index.C.red("[vite-node] Failed to execute file: \n"), err);
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
function parseServerOptions(serverOptions) {
|
|
@@ -98,10 +98,10 @@ function parseServerOptions(serverOptions) {
|
|
|
98
98
|
...serverOptions.deps,
|
|
99
99
|
inlineFiles: utils.toArray((_serverOptions$deps3 = serverOptions.deps) === null || _serverOptions$deps3 === void 0 ? void 0 : _serverOptions$deps3.inlineFiles),
|
|
100
100
|
inline: inlineOptions !== true ? inlineOptions.map((dep) => {
|
|
101
|
-
return dep
|
|
101
|
+
return dep[0] === "/" && dep.endsWith("/") ? new RegExp(dep) : dep;
|
|
102
102
|
}) : true,
|
|
103
103
|
external: utils.toArray((_serverOptions$deps4 = serverOptions.deps) === null || _serverOptions$deps4 === void 0 ? void 0 : _serverOptions$deps4.external).map((dep) => {
|
|
104
|
-
return dep
|
|
104
|
+
return dep[0] === "/" && dep.endsWith("/") ? new RegExp(dep) : dep;
|
|
105
105
|
}),
|
|
106
106
|
moduleDirectories: ((_serverOptions$deps5 = serverOptions.deps) === null || _serverOptions$deps5 === void 0 ? void 0 : _serverOptions$deps5.moduleDirectories) ? utils.toArray((_serverOptions$deps6 = serverOptions.deps) === null || _serverOptions$deps6 === void 0 ? void 0 : _serverOptions$deps6.moduleDirectories) : void 0
|
|
107
107
|
},
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import cac from 'cac';
|
|
3
|
-
import {
|
|
3
|
+
import { C } from './chunk-index.mjs';
|
|
4
4
|
import { createServer, version as version$1, loadEnv } from 'vite';
|
|
5
5
|
import { ViteNodeRunner } from './client.mjs';
|
|
6
6
|
import { v as viteNodeHmrPlugin, a as createHotContext, h as handleMessage } from './chunk-hmr.mjs';
|
|
@@ -19,7 +19,7 @@ import 'node:perf_hooks';
|
|
|
19
19
|
import 'es-module-lexer';
|
|
20
20
|
import './constants.mjs';
|
|
21
21
|
|
|
22
|
-
var version = "4.0.0-beta.
|
|
22
|
+
var version = "4.0.0-beta.11";
|
|
23
23
|
|
|
24
24
|
const cli = cac("vite-node");
|
|
25
25
|
if (cli.option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", "Restart on file changes, similar to \"nodemon\"").option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command"), cli.command("[...files]").allowUnknownOptions().action(run), cli.parse(process.argv, { run: false }), cli.args.length === 0) cli.runMatchedCommand();
|
|
@@ -41,7 +41,7 @@ async function run(files, options = {}) {
|
|
|
41
41
|
else process.argv = [...process.argv.slice(0, 2), ...options["--"] || []];
|
|
42
42
|
if (options.version) cli.version(version), cli.outputVersion(), process.exit(0);
|
|
43
43
|
if (options.help) cli.version(version).outputHelp(), process.exit(0);
|
|
44
|
-
if (!files.length) console.error(
|
|
44
|
+
if (!files.length) console.error(C.red("No files specified.")), cli.version(version).outputHelp(), process.exit(1);
|
|
45
45
|
const serverOptions = options.options ? parseServerOptions(options.options) : {}, server = await createServer({
|
|
46
46
|
logLevel: "error",
|
|
47
47
|
configFile: options.config,
|
|
@@ -84,7 +84,7 @@ async function run(files, options = {}) {
|
|
|
84
84
|
if ((_server$emitter = server.emitter) === null || _server$emitter === void 0 || _server$emitter.on("message", (payload) => {
|
|
85
85
|
handleMessage(runner, server.emitter, files, payload);
|
|
86
86
|
}), options.watch) process.on("uncaughtException", (err) => {
|
|
87
|
-
console.error(
|
|
87
|
+
console.error(C.red("[vite-node] Failed to execute file: \n"), err);
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
function parseServerOptions(serverOptions) {
|
|
@@ -96,10 +96,10 @@ function parseServerOptions(serverOptions) {
|
|
|
96
96
|
...serverOptions.deps,
|
|
97
97
|
inlineFiles: toArray((_serverOptions$deps3 = serverOptions.deps) === null || _serverOptions$deps3 === void 0 ? void 0 : _serverOptions$deps3.inlineFiles),
|
|
98
98
|
inline: inlineOptions !== true ? inlineOptions.map((dep) => {
|
|
99
|
-
return dep
|
|
99
|
+
return dep[0] === "/" && dep.endsWith("/") ? new RegExp(dep) : dep;
|
|
100
100
|
}) : true,
|
|
101
101
|
external: toArray((_serverOptions$deps4 = serverOptions.deps) === null || _serverOptions$deps4 === void 0 ? void 0 : _serverOptions$deps4.external).map((dep) => {
|
|
102
|
-
return dep
|
|
102
|
+
return dep[0] === "/" && dep.endsWith("/") ? new RegExp(dep) : dep;
|
|
103
103
|
}),
|
|
104
104
|
moduleDirectories: ((_serverOptions$deps5 = serverOptions.deps) === null || _serverOptions$deps5 === void 0 ? void 0 : _serverOptions$deps5.moduleDirectories) ? toArray((_serverOptions$deps6 = serverOptions.deps) === null || _serverOptions$deps6 === void 0 ? void 0 : _serverOptions$deps6.moduleDirectories) : void 0
|
|
105
105
|
},
|
package/dist/client.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var nodeModule = require('node:module');
|
|
4
4
|
var path = require('node:path');
|
|
5
5
|
var node_url = require('node:url');
|
|
6
6
|
var vm = require('node:vm');
|
|
@@ -314,7 +314,7 @@ class ViteNodeRunner {
|
|
|
314
314
|
get: getter
|
|
315
315
|
}),
|
|
316
316
|
__vite_ssr_import_meta__: meta,
|
|
317
|
-
require:
|
|
317
|
+
require: nodeModule.createRequire(href),
|
|
318
318
|
exports: cjsExports,
|
|
319
319
|
module: moduleProxy,
|
|
320
320
|
__filename,
|
package/dist/hmr.cjs
CHANGED
package/dist/hmr.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { c as createHmrEmitter, a as createHotContext, g as getCache, h as handleMessage, r as reload, s as sendMessageBuffer, v as viteNodeHmrPlugin } from './chunk-hmr.mjs';
|
|
2
2
|
import 'node:events';
|
|
3
3
|
import 'debug';
|
|
4
|
-
import './chunk-
|
|
4
|
+
import './chunk-index.mjs';
|
|
5
5
|
import './utils.mjs';
|
|
6
6
|
import 'node:fs';
|
|
7
7
|
import 'node:module';
|
package/dist/server.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var node_url = require('node:url');
|
|
|
7
7
|
var createDebug = require('debug');
|
|
8
8
|
var pathe = require('pathe');
|
|
9
9
|
var vite = require('vite');
|
|
10
|
-
var
|
|
10
|
+
var index = require('./chunk-index.cjs');
|
|
11
11
|
var esModuleLexer = require('es-module-lexer');
|
|
12
12
|
var constants = require('./constants.cjs');
|
|
13
13
|
var utils = require('./utils.cjs');
|
|
@@ -46,8 +46,8 @@ class Debugger {
|
|
|
46
46
|
externalizeMap = /* @__PURE__ */ new Map();
|
|
47
47
|
constructor(root, options) {
|
|
48
48
|
if (this.options = options, options.dumpModules) this.dumpDir = pathe.resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
|
|
49
|
-
if (this.dumpDir) if (options.loadDumppedModules) console.info(
|
|
50
|
-
else console.info(
|
|
49
|
+
if (this.dumpDir) if (options.loadDumppedModules) console.info(index.C.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
|
|
50
|
+
else console.info(index.C.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
|
|
51
51
|
this.initPromise = this.clearDump();
|
|
52
52
|
}
|
|
53
53
|
async clearDump() {
|
|
@@ -226,7 +226,7 @@ class ViteNodeServer {
|
|
|
226
226
|
if (customModuleDirectories) options.deps.moduleDirectories.push(...customModuleDirectories);
|
|
227
227
|
// always add node_modules as a module directory
|
|
228
228
|
if (options.deps.moduleDirectories = options.deps.moduleDirectories.map((dir) => {
|
|
229
|
-
if (
|
|
229
|
+
if (dir[0] !== "/") dir = `/${dir}`;
|
|
230
230
|
if (!dir.endsWith("/")) dir += "/";
|
|
231
231
|
return pathe.normalize(dir);
|
|
232
232
|
}), !options.deps.moduleDirectories.includes("/node_modules/")) options.deps.moduleDirectories.push("/node_modules/");
|
package/dist/server.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
5
5
|
import createDebug from 'debug';
|
|
6
6
|
import { resolve, join, extname, dirname, relative, normalize } from 'pathe';
|
|
7
7
|
import { version } from 'vite';
|
|
8
|
-
import {
|
|
8
|
+
import { C } from './chunk-index.mjs';
|
|
9
9
|
import * as esModuleLexer from 'es-module-lexer';
|
|
10
10
|
import { KNOWN_ASSET_RE } from './constants.mjs';
|
|
11
11
|
import { isNodeBuiltin, slash, findNearestPackageData, toArray, withTrailingSlash, normalizeModuleId, toFilePath } from './utils.mjs';
|
|
@@ -25,8 +25,8 @@ class Debugger {
|
|
|
25
25
|
externalizeMap = /* @__PURE__ */ new Map();
|
|
26
26
|
constructor(root, options) {
|
|
27
27
|
if (this.options = options, options.dumpModules) this.dumpDir = resolve(root, options.dumpModules === true ? ".vite-node/dump" : options.dumpModules);
|
|
28
|
-
if (this.dumpDir) if (options.loadDumppedModules) console.info(
|
|
29
|
-
else console.info(
|
|
28
|
+
if (this.dumpDir) if (options.loadDumppedModules) console.info(C.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`));
|
|
29
|
+
else console.info(C.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`));
|
|
30
30
|
this.initPromise = this.clearDump();
|
|
31
31
|
}
|
|
32
32
|
async clearDump() {
|
|
@@ -205,7 +205,7 @@ class ViteNodeServer {
|
|
|
205
205
|
if (customModuleDirectories) options.deps.moduleDirectories.push(...customModuleDirectories);
|
|
206
206
|
// always add node_modules as a module directory
|
|
207
207
|
if (options.deps.moduleDirectories = options.deps.moduleDirectories.map((dir) => {
|
|
208
|
-
if (
|
|
208
|
+
if (dir[0] !== "/") dir = `/${dir}`;
|
|
209
209
|
if (!dir.endsWith("/")) dir += "/";
|
|
210
210
|
return normalize(dir);
|
|
211
211
|
}), !options.deps.moduleDirectories.includes("/node_modules/")) options.deps.moduleDirectories.push("/node_modules/");
|
package/dist/source-map.cjs
CHANGED
|
@@ -7,106 +7,103 @@ var utils = require('./utils.cjs');
|
|
|
7
7
|
require('node:module');
|
|
8
8
|
require('node:url');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
// src/vlq.ts
|
|
11
|
+
var comma = ",".charCodeAt(0);
|
|
12
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
13
|
+
var intToChar = new Uint8Array(64);
|
|
14
|
+
var charToInt = new Uint8Array(128);
|
|
14
15
|
for (let i = 0; i < chars.length; i++) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const c = chars.charCodeAt(i);
|
|
17
|
+
intToChar[i] = c;
|
|
18
|
+
charToInt[c] = i;
|
|
18
19
|
}
|
|
19
20
|
function decodeInteger(reader, relative) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
let value = 0;
|
|
22
|
+
let shift = 0;
|
|
23
|
+
let integer = 0;
|
|
24
|
+
do {
|
|
25
|
+
const c = reader.next();
|
|
26
|
+
integer = charToInt[c];
|
|
27
|
+
value |= (integer & 31) << shift;
|
|
28
|
+
shift += 5;
|
|
29
|
+
} while (integer & 32);
|
|
30
|
+
const shouldNegate = value & 1;
|
|
31
|
+
value >>>= 1;
|
|
32
|
+
if (shouldNegate) {
|
|
33
|
+
value = -2147483648 | -value;
|
|
34
|
+
}
|
|
35
|
+
return relative + value;
|
|
35
36
|
}
|
|
36
37
|
function hasMoreVlq(reader, max) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return reader.peek() !== comma;
|
|
40
|
-
}
|
|
41
|
-
class StringReader {
|
|
42
|
-
constructor(buffer) {
|
|
43
|
-
this.pos = 0;
|
|
44
|
-
this.buffer = buffer;
|
|
45
|
-
}
|
|
46
|
-
next() {
|
|
47
|
-
return this.buffer.charCodeAt(this.pos++);
|
|
48
|
-
}
|
|
49
|
-
peek() {
|
|
50
|
-
return this.buffer.charCodeAt(this.pos);
|
|
51
|
-
}
|
|
52
|
-
indexOf(char) {
|
|
53
|
-
const { buffer, pos } = this;
|
|
54
|
-
const idx = buffer.indexOf(char, pos);
|
|
55
|
-
return idx === -1 ? buffer.length : idx;
|
|
56
|
-
}
|
|
38
|
+
if (reader.pos >= max) return false;
|
|
39
|
+
return reader.peek() !== comma;
|
|
57
40
|
}
|
|
41
|
+
var StringReader = class {
|
|
42
|
+
constructor(buffer) {
|
|
43
|
+
this.pos = 0;
|
|
44
|
+
this.buffer = buffer;
|
|
45
|
+
}
|
|
46
|
+
next() {
|
|
47
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
48
|
+
}
|
|
49
|
+
peek() {
|
|
50
|
+
return this.buffer.charCodeAt(this.pos);
|
|
51
|
+
}
|
|
52
|
+
indexOf(char) {
|
|
53
|
+
const { buffer, pos } = this;
|
|
54
|
+
const idx = buffer.indexOf(char, pos);
|
|
55
|
+
return idx === -1 ? buffer.length : idx;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
58
|
|
|
59
|
+
// src/sourcemap-codec.ts
|
|
59
60
|
function decode(mappings) {
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
else {
|
|
89
|
-
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
seg = [genColumn];
|
|
94
|
-
}
|
|
95
|
-
line.push(seg);
|
|
96
|
-
reader.pos++;
|
|
61
|
+
const { length } = mappings;
|
|
62
|
+
const reader = new StringReader(mappings);
|
|
63
|
+
const decoded = [];
|
|
64
|
+
let genColumn = 0;
|
|
65
|
+
let sourcesIndex = 0;
|
|
66
|
+
let sourceLine = 0;
|
|
67
|
+
let sourceColumn = 0;
|
|
68
|
+
let namesIndex = 0;
|
|
69
|
+
do {
|
|
70
|
+
const semi = reader.indexOf(";");
|
|
71
|
+
const line = [];
|
|
72
|
+
let sorted = true;
|
|
73
|
+
let lastCol = 0;
|
|
74
|
+
genColumn = 0;
|
|
75
|
+
while (reader.pos < semi) {
|
|
76
|
+
let seg;
|
|
77
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
78
|
+
if (genColumn < lastCol) sorted = false;
|
|
79
|
+
lastCol = genColumn;
|
|
80
|
+
if (hasMoreVlq(reader, semi)) {
|
|
81
|
+
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
82
|
+
sourceLine = decodeInteger(reader, sourceLine);
|
|
83
|
+
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
84
|
+
if (hasMoreVlq(reader, semi)) {
|
|
85
|
+
namesIndex = decodeInteger(reader, namesIndex);
|
|
86
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
|
87
|
+
} else {
|
|
88
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
97
89
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
90
|
+
} else {
|
|
91
|
+
seg = [genColumn];
|
|
92
|
+
}
|
|
93
|
+
line.push(seg);
|
|
94
|
+
reader.pos++;
|
|
95
|
+
}
|
|
96
|
+
if (!sorted) sort(line);
|
|
97
|
+
decoded.push(line);
|
|
98
|
+
reader.pos = semi + 1;
|
|
99
|
+
} while (reader.pos <= length);
|
|
100
|
+
return decoded;
|
|
104
101
|
}
|
|
105
102
|
function sort(line) {
|
|
106
|
-
|
|
103
|
+
line.sort(sortComparator$1);
|
|
107
104
|
}
|
|
108
105
|
function sortComparator$1(a, b) {
|
|
109
|
-
|
|
106
|
+
return a[0] - b[0];
|
|
110
107
|
}
|
|
111
108
|
|
|
112
109
|
// Matches the scheme of a URL, eg "http://"
|
|
@@ -828,7 +825,7 @@ function withInlineSourcemap(result, options) {
|
|
|
828
825
|
// this is a bug in Vite
|
|
829
826
|
// all files should be either absolute to the file system or relative to the source map file
|
|
830
827
|
if (pathe.isAbsolute(source)) {
|
|
831
|
-
const actualPath = !source.startsWith(utils.withTrailingSlash(options.root)) && source
|
|
828
|
+
const actualPath = !source.startsWith(utils.withTrailingSlash(options.root)) && source[0] === "/" ? pathe.resolve(options.root, source.slice(1)) : source;
|
|
832
829
|
return pathe.relative(pathe.dirname(options.filepath), actualPath);
|
|
833
830
|
}
|
|
834
831
|
return source;
|
|
@@ -841,7 +838,7 @@ function withInlineSourcemap(result, options) {
|
|
|
841
838
|
// so that debuggers can be set to break on first line
|
|
842
839
|
// Since Vite 6, import statements at the top of the file are preserved correctly,
|
|
843
840
|
// so we don't need to add this mapping anymore.
|
|
844
|
-
if (!options.noFirstLineMapping && map.mappings
|
|
841
|
+
if (!options.noFirstLineMapping && map.mappings[0] === ";") map.mappings = `AAAA,CAAA${map.mappings}`;
|
|
845
842
|
const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString("base64");
|
|
846
843
|
return result.code = `${code.trimEnd()}\n\n${VITE_NODE_SOURCEMAPPING_SOURCE}\n//# ${VITE_NODE_SOURCEMAPPING_URL};base64,${sourceMap}\n`, result;
|
|
847
844
|
}
|
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://"
|
|
@@ -826,7 +823,7 @@ function withInlineSourcemap(result, options) {
|
|
|
826
823
|
// this is a bug in Vite
|
|
827
824
|
// all files should be either absolute to the file system or relative to the source map file
|
|
828
825
|
if (isAbsolute(source)) {
|
|
829
|
-
const actualPath = !source.startsWith(withTrailingSlash(options.root)) && source
|
|
826
|
+
const actualPath = !source.startsWith(withTrailingSlash(options.root)) && source[0] === "/" ? resolve$1(options.root, source.slice(1)) : source;
|
|
830
827
|
return relative(dirname(options.filepath), actualPath);
|
|
831
828
|
}
|
|
832
829
|
return source;
|
|
@@ -839,7 +836,7 @@ function withInlineSourcemap(result, options) {
|
|
|
839
836
|
// so that debuggers can be set to break on first line
|
|
840
837
|
// Since Vite 6, import statements at the top of the file are preserved correctly,
|
|
841
838
|
// so we don't need to add this mapping anymore.
|
|
842
|
-
if (!options.noFirstLineMapping && map.mappings
|
|
839
|
+
if (!options.noFirstLineMapping && map.mappings[0] === ";") map.mappings = `AAAA,CAAA${map.mappings}`;
|
|
843
840
|
const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString("base64");
|
|
844
841
|
return result.code = `${code.trimEnd()}\n\n${VITE_NODE_SOURCEMAPPING_SOURCE}\n//# ${VITE_NODE_SOURCEMAPPING_URL};base64,${sourceMap}\n`, result;
|
|
845
842
|
}
|
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
|
|
|
@@ -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>`
|
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
|
|
|
@@ -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>`
|
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.11",
|
|
5
5
|
"description": "Vite as Node.js runtime",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -84,9 +84,9 @@
|
|
|
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.30",
|
|
88
88
|
"@types/debug": "^4.1.12",
|
|
89
|
-
"tinyrainbow": "^
|
|
89
|
+
"tinyrainbow": "^3.0.3"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"build": "rimraf dist && rollup -c",
|