vite-node 3.0.0-beta.3 → 3.0.0
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 +1 -1
- package/dist/chunk-browser.cjs +4 -5
- package/dist/chunk-browser.mjs +4 -5
- package/dist/chunk-hmr.cjs +4 -13
- package/dist/chunk-hmr.mjs +5 -14
- package/dist/cli.cjs +3 -3
- package/dist/cli.mjs +6 -6
- package/dist/server.cjs +2 -2
- package/dist/server.mjs +3 -3
- package/dist/utils.cjs +14 -3
- package/dist/utils.mjs +14 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
vite-node
|
|
7
7
|
</h1>
|
|
8
8
|
<p align="center">
|
|
9
|
-
Vite as Node runtime.<br>The engine that powers <a href="https://github.com/vitest-dev/vitest">Vitest</a> and <a href="https://github.com/nuxt/
|
|
9
|
+
Vite as Node runtime.<br>The engine that powers <a href="https://github.com/vitest-dev/vitest">Vitest</a> and <a href="https://github.com/nuxt/nuxt">Nuxt 3 Dev SSR</a>.
|
|
10
10
|
<p>
|
|
11
11
|
<p align="center">
|
|
12
12
|
<a href="https://www.npmjs.com/package/vitest"><img src="https://img.shields.io/npm/v/vite-node?color=FCC72B&label="></a>
|
package/dist/chunk-browser.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
var f
|
|
4
|
+
var f = {
|
|
5
5
|
reset: [0, 0],
|
|
6
6
|
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
7
7
|
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
@@ -43,7 +43,7 @@ var f$1 = {
|
|
|
43
43
|
bgMagentaBright: [105, 49],
|
|
44
44
|
bgCyanBright: [106, 49],
|
|
45
45
|
bgWhiteBright: [107, 49]
|
|
46
|
-
}, h = Object.entries(f
|
|
46
|
+
}, h = Object.entries(f);
|
|
47
47
|
function a(n) {
|
|
48
48
|
return String(n);
|
|
49
49
|
}
|
|
@@ -78,7 +78,6 @@ function p(n = !1) {
|
|
|
78
78
|
return u;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
var f = p(!1);
|
|
81
|
+
var s = p();
|
|
83
82
|
|
|
84
|
-
exports.
|
|
83
|
+
exports.s = s;
|
package/dist/chunk-browser.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
var f
|
|
2
|
+
var f = {
|
|
3
3
|
reset: [0, 0],
|
|
4
4
|
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
5
5
|
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
@@ -41,7 +41,7 @@ var f$1 = {
|
|
|
41
41
|
bgMagentaBright: [105, 49],
|
|
42
42
|
bgCyanBright: [106, 49],
|
|
43
43
|
bgWhiteBright: [107, 49]
|
|
44
|
-
}, h = Object.entries(f
|
|
44
|
+
}, h = Object.entries(f);
|
|
45
45
|
function a(n) {
|
|
46
46
|
return String(n);
|
|
47
47
|
}
|
|
@@ -76,7 +76,6 @@ function p(n = !1) {
|
|
|
76
76
|
return u;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
var f = p(!1);
|
|
79
|
+
var s = p();
|
|
81
80
|
|
|
82
|
-
export {
|
|
81
|
+
export { s };
|
package/dist/chunk-hmr.cjs
CHANGED
|
@@ -14,16 +14,7 @@ function viteNodeHmrPlugin() {
|
|
|
14
14
|
return {
|
|
15
15
|
name: "vite-node:hmr",
|
|
16
16
|
config() {
|
|
17
|
-
if (process.platform === "darwin" && false)
|
|
18
|
-
return {
|
|
19
|
-
server: {
|
|
20
|
-
watch: {
|
|
21
|
-
useFsEvents: false,
|
|
22
|
-
usePolling: false
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
17
|
+
if (process.platform === "darwin" && false) ;
|
|
27
18
|
},
|
|
28
19
|
configureServer(server) {
|
|
29
20
|
const _send = server.ws.send;
|
|
@@ -123,7 +114,7 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
|
123
114
|
fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
|
|
124
115
|
}
|
|
125
116
|
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
|
126
|
-
console.log(`${browser.
|
|
117
|
+
console.log(`${browser.s.cyan("[vite-node]")} hot updated: ${loggedPath}`);
|
|
127
118
|
};
|
|
128
119
|
}
|
|
129
120
|
function warnFailedFetch(err, path) {
|
|
@@ -147,7 +138,7 @@ async function handleMessage(runner, emitter, files, payload) {
|
|
|
147
138
|
if (update.type === "js-update") {
|
|
148
139
|
return queueUpdate(runner, fetchUpdate(runner, update));
|
|
149
140
|
}
|
|
150
|
-
console.error(`${browser.
|
|
141
|
+
console.error(`${browser.s.cyan("[vite-node]")} no support css hmr.}`);
|
|
151
142
|
return null;
|
|
152
143
|
})
|
|
153
144
|
);
|
|
@@ -174,7 +165,7 @@ async function handleMessage(runner, emitter, files, payload) {
|
|
|
174
165
|
await notifyListeners(runner, "vite:error", payload);
|
|
175
166
|
const err = payload.err;
|
|
176
167
|
console.error(
|
|
177
|
-
`${browser.
|
|
168
|
+
`${browser.s.cyan("[vite-node]")} Internal Server Error
|
|
178
169
|
${err.message}
|
|
179
170
|
${err.stack}`
|
|
180
171
|
);
|
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 { s } from './chunk-browser.mjs';
|
|
4
4
|
import { normalizeRequestId } from './utils.mjs';
|
|
5
5
|
|
|
6
6
|
function createHmrEmitter() {
|
|
@@ -12,16 +12,7 @@ function viteNodeHmrPlugin() {
|
|
|
12
12
|
return {
|
|
13
13
|
name: "vite-node:hmr",
|
|
14
14
|
config() {
|
|
15
|
-
if (process.platform === "darwin" && false)
|
|
16
|
-
return {
|
|
17
|
-
server: {
|
|
18
|
-
watch: {
|
|
19
|
-
useFsEvents: false,
|
|
20
|
-
usePolling: false
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
15
|
+
if (process.platform === "darwin" && false) ;
|
|
25
16
|
},
|
|
26
17
|
configureServer(server) {
|
|
27
18
|
const _send = server.ws.send;
|
|
@@ -121,7 +112,7 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
|
121
112
|
fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
|
|
122
113
|
}
|
|
123
114
|
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
|
124
|
-
console.log(`${
|
|
115
|
+
console.log(`${s.cyan("[vite-node]")} hot updated: ${loggedPath}`);
|
|
125
116
|
};
|
|
126
117
|
}
|
|
127
118
|
function warnFailedFetch(err, path) {
|
|
@@ -145,7 +136,7 @@ async function handleMessage(runner, emitter, files, payload) {
|
|
|
145
136
|
if (update.type === "js-update") {
|
|
146
137
|
return queueUpdate(runner, fetchUpdate(runner, update));
|
|
147
138
|
}
|
|
148
|
-
console.error(`${
|
|
139
|
+
console.error(`${s.cyan("[vite-node]")} no support css hmr.}`);
|
|
149
140
|
return null;
|
|
150
141
|
})
|
|
151
142
|
);
|
|
@@ -172,7 +163,7 @@ async function handleMessage(runner, emitter, files, payload) {
|
|
|
172
163
|
await notifyListeners(runner, "vite:error", payload);
|
|
173
164
|
const err = payload.err;
|
|
174
165
|
console.error(
|
|
175
|
-
`${
|
|
166
|
+
`${s.cyan("[vite-node]")} Internal Server Error
|
|
176
167
|
${err.message}
|
|
177
168
|
${err.stack}`
|
|
178
169
|
);
|
package/dist/cli.cjs
CHANGED
|
@@ -21,7 +21,7 @@ require('es-module-lexer');
|
|
|
21
21
|
require('./constants.cjs');
|
|
22
22
|
require('node:events');
|
|
23
23
|
|
|
24
|
-
var version = "3.0.0
|
|
24
|
+
var version = "3.0.0";
|
|
25
25
|
|
|
26
26
|
const cli = cac("vite-node");
|
|
27
27
|
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");
|
|
@@ -58,7 +58,7 @@ async function run(files, options = {}) {
|
|
|
58
58
|
process.exit(0);
|
|
59
59
|
}
|
|
60
60
|
if (!files.length) {
|
|
61
|
-
console.error(browser.
|
|
61
|
+
console.error(browser.s.red("No files specified."));
|
|
62
62
|
cli.version(version).outputHelp();
|
|
63
63
|
process.exit(1);
|
|
64
64
|
}
|
|
@@ -108,7 +108,7 @@ async function run(files, options = {}) {
|
|
|
108
108
|
});
|
|
109
109
|
if (options.watch) {
|
|
110
110
|
process.on("uncaughtException", (err) => {
|
|
111
|
-
console.error(browser.
|
|
111
|
+
console.error(browser.s.red("[vite-node] Failed to execute file: \n"), err);
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import cac from 'cac';
|
|
3
|
-
import {
|
|
3
|
+
import { s } from './chunk-browser.mjs';
|
|
4
4
|
import { createServer, loadEnv } from 'vite';
|
|
5
5
|
import { ViteNodeRunner } from './client.mjs';
|
|
6
|
+
import { v as viteNodeHmrPlugin, a as createHotContext, h as handleMessage } from './chunk-hmr.mjs';
|
|
6
7
|
import { ViteNodeServer } from './server.mjs';
|
|
7
8
|
import { installSourcemapsSupport } from './source-map.mjs';
|
|
8
9
|
import { toArray } from './utils.mjs';
|
|
9
|
-
import { v as viteNodeHmrPlugin, a as createHotContext, h as handleMessage } from './chunk-hmr.mjs';
|
|
10
10
|
import 'node:module';
|
|
11
11
|
import 'node:url';
|
|
12
12
|
import 'node:vm';
|
|
13
13
|
import 'debug';
|
|
14
14
|
import 'pathe';
|
|
15
15
|
import 'node:fs';
|
|
16
|
+
import 'node:events';
|
|
16
17
|
import 'node:assert';
|
|
17
18
|
import 'node:perf_hooks';
|
|
18
19
|
import 'es-module-lexer';
|
|
19
20
|
import './constants.mjs';
|
|
20
|
-
import 'node:events';
|
|
21
21
|
|
|
22
|
-
var version = "3.0.0
|
|
22
|
+
var version = "3.0.0";
|
|
23
23
|
|
|
24
24
|
const cli = cac("vite-node");
|
|
25
25
|
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");
|
|
@@ -56,7 +56,7 @@ async function run(files, options = {}) {
|
|
|
56
56
|
process.exit(0);
|
|
57
57
|
}
|
|
58
58
|
if (!files.length) {
|
|
59
|
-
console.error(
|
|
59
|
+
console.error(s.red("No files specified."));
|
|
60
60
|
cli.version(version).outputHelp();
|
|
61
61
|
process.exit(1);
|
|
62
62
|
}
|
|
@@ -106,7 +106,7 @@ async function run(files, options = {}) {
|
|
|
106
106
|
});
|
|
107
107
|
if (options.watch) {
|
|
108
108
|
process.on("uncaughtException", (err) => {
|
|
109
|
-
console.error(
|
|
109
|
+
console.error(s.red("[vite-node] Failed to execute file: \n"), err);
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
}
|
package/dist/server.cjs
CHANGED
|
@@ -51,11 +51,11 @@ class Debugger {
|
|
|
51
51
|
if (this.dumpDir) {
|
|
52
52
|
if (options.loadDumppedModules) {
|
|
53
53
|
console.info(
|
|
54
|
-
browser.
|
|
54
|
+
browser.s.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`)
|
|
55
55
|
);
|
|
56
56
|
} else {
|
|
57
57
|
console.info(
|
|
58
|
-
browser.
|
|
58
|
+
browser.s.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`)
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
}
|
package/dist/server.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { performance } from 'node:perf_hooks';
|
|
|
4
4
|
import { pathToFileURL } from 'node:url';
|
|
5
5
|
import createDebug from 'debug';
|
|
6
6
|
import { resolve, join, extname, dirname, relative, normalize } from 'pathe';
|
|
7
|
-
import {
|
|
7
|
+
import { s } from './chunk-browser.mjs';
|
|
8
8
|
import * as esModuleLexer from 'es-module-lexer';
|
|
9
9
|
import { KNOWN_ASSET_RE } from './constants.mjs';
|
|
10
10
|
import { isNodeBuiltin, slash, findNearestPackageData, toArray, withTrailingSlash, normalizeModuleId, toFilePath } from './utils.mjs';
|
|
@@ -30,11 +30,11 @@ class Debugger {
|
|
|
30
30
|
if (this.dumpDir) {
|
|
31
31
|
if (options.loadDumppedModules) {
|
|
32
32
|
console.info(
|
|
33
|
-
|
|
33
|
+
s.gray(`[vite-node] [debug] load modules from ${this.dumpDir}`)
|
|
34
34
|
);
|
|
35
35
|
} else {
|
|
36
36
|
console.info(
|
|
37
|
-
|
|
37
|
+
s.gray(`[vite-node] [debug] dump modules to ${this.dumpDir}`)
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
}
|
package/dist/utils.cjs
CHANGED
|
@@ -21,7 +21,10 @@ function normalizeRequestId(id, base) {
|
|
|
21
21
|
if (driveRegexp && !(driveRegexp == null ? void 0 : driveRegexp.test(id)) && (driveOppositeRegext == null ? void 0 : driveOppositeRegext.test(id))) {
|
|
22
22
|
id = id.replace(driveOppositeRegext, `${drive}$1`);
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
if (id.startsWith("file://")) {
|
|
25
|
+
return node_url.fileURLToPath(id);
|
|
26
|
+
}
|
|
27
|
+
return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
|
|
25
28
|
}
|
|
26
29
|
const postfixRE = /[?#].*$/;
|
|
27
30
|
function cleanUrl(url) {
|
|
@@ -34,7 +37,12 @@ const internalRequestRegexp = new RegExp(
|
|
|
34
37
|
function isInternalRequest(id) {
|
|
35
38
|
return internalRequestRegexp.test(id);
|
|
36
39
|
}
|
|
37
|
-
const prefixedBuiltins = /* @__PURE__ */ new Set([
|
|
40
|
+
const prefixedBuiltins = /* @__PURE__ */ new Set([
|
|
41
|
+
"node:sea",
|
|
42
|
+
"node:sqlite",
|
|
43
|
+
"node:test",
|
|
44
|
+
"node:test/reporters"
|
|
45
|
+
]);
|
|
38
46
|
const builtins = /* @__PURE__ */ new Set([
|
|
39
47
|
...node_module.builtinModules,
|
|
40
48
|
"assert/strict",
|
|
@@ -55,7 +63,10 @@ function normalizeModuleId(id) {
|
|
|
55
63
|
if (prefixedBuiltins.has(id)) {
|
|
56
64
|
return id;
|
|
57
65
|
}
|
|
58
|
-
|
|
66
|
+
if (id.startsWith("file://")) {
|
|
67
|
+
return node_url.fileURLToPath(id);
|
|
68
|
+
}
|
|
69
|
+
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
59
70
|
}
|
|
60
71
|
function isPrimitive(v) {
|
|
61
72
|
return v !== Object(v);
|
package/dist/utils.mjs
CHANGED
|
@@ -19,7 +19,10 @@ function normalizeRequestId(id, base) {
|
|
|
19
19
|
if (driveRegexp && !(driveRegexp == null ? void 0 : driveRegexp.test(id)) && (driveOppositeRegext == null ? void 0 : driveOppositeRegext.test(id))) {
|
|
20
20
|
id = id.replace(driveOppositeRegext, `${drive}$1`);
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
if (id.startsWith("file://")) {
|
|
23
|
+
return fileURLToPath(id);
|
|
24
|
+
}
|
|
25
|
+
return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
|
|
23
26
|
}
|
|
24
27
|
const postfixRE = /[?#].*$/;
|
|
25
28
|
function cleanUrl(url) {
|
|
@@ -32,7 +35,12 @@ const internalRequestRegexp = new RegExp(
|
|
|
32
35
|
function isInternalRequest(id) {
|
|
33
36
|
return internalRequestRegexp.test(id);
|
|
34
37
|
}
|
|
35
|
-
const prefixedBuiltins = /* @__PURE__ */ new Set([
|
|
38
|
+
const prefixedBuiltins = /* @__PURE__ */ new Set([
|
|
39
|
+
"node:sea",
|
|
40
|
+
"node:sqlite",
|
|
41
|
+
"node:test",
|
|
42
|
+
"node:test/reporters"
|
|
43
|
+
]);
|
|
36
44
|
const builtins = /* @__PURE__ */ new Set([
|
|
37
45
|
...builtinModules,
|
|
38
46
|
"assert/strict",
|
|
@@ -53,7 +61,10 @@ function normalizeModuleId(id) {
|
|
|
53
61
|
if (prefixedBuiltins.has(id)) {
|
|
54
62
|
return id;
|
|
55
63
|
}
|
|
56
|
-
|
|
64
|
+
if (id.startsWith("file://")) {
|
|
65
|
+
return fileURLToPath(id);
|
|
66
|
+
}
|
|
67
|
+
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
57
68
|
}
|
|
58
69
|
function isPrimitive(v) {
|
|
59
70
|
return v !== Object(v);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"description": "Vite as Node.js runtime",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"cac": "^6.7.14",
|
|
81
81
|
"debug": "^4.4.0",
|
|
82
82
|
"es-module-lexer": "^1.5.4",
|
|
83
|
-
"pathe": "^
|
|
83
|
+
"pathe": "^2.0.0",
|
|
84
84
|
"vite": "^5.0.0 || ^6.0.0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@jridgewell/trace-mapping": "^0.3.25",
|
|
88
88
|
"@types/debug": "^4.1.12",
|
|
89
|
-
"tinyrainbow": "^
|
|
89
|
+
"tinyrainbow": "^2.0.0"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"build": "rimraf dist && rollup -c",
|