vite-node 2.1.4 → 2.1.6
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 +1 -1
- package/dist/chunk-hmr.mjs +1 -1
- package/dist/cli.cjs +2 -1
- package/dist/cli.mjs +2 -1
- package/dist/server.cjs +28 -4
- package/dist/server.mjs +9 -4
- package/package.json +4 -3
package/dist/chunk-hmr.cjs
CHANGED
|
@@ -127,7 +127,7 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
function warnFailedFetch(err, path) {
|
|
130
|
-
if (!err.message.match("fetch")) {
|
|
130
|
+
if (!(err instanceof Error) || !err.message.match("fetch")) {
|
|
131
131
|
console.error(err);
|
|
132
132
|
}
|
|
133
133
|
console.error(
|
package/dist/chunk-hmr.mjs
CHANGED
|
@@ -125,7 +125,7 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
function warnFailedFetch(err, path) {
|
|
128
|
-
if (!err.message.match("fetch")) {
|
|
128
|
+
if (!(err instanceof Error) || !err.message.match("fetch")) {
|
|
129
129
|
console.error(err);
|
|
130
130
|
}
|
|
131
131
|
console.error(
|
package/dist/cli.cjs
CHANGED
|
@@ -17,10 +17,11 @@ require('pathe');
|
|
|
17
17
|
require('node:fs');
|
|
18
18
|
require('node:assert');
|
|
19
19
|
require('node:perf_hooks');
|
|
20
|
+
require('es-module-lexer');
|
|
20
21
|
require('./constants.cjs');
|
|
21
22
|
require('node:events');
|
|
22
23
|
|
|
23
|
-
var version = "2.1.
|
|
24
|
+
var version = "2.1.6";
|
|
24
25
|
|
|
25
26
|
const cli = cac("vite-node");
|
|
26
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");
|
package/dist/cli.mjs
CHANGED
|
@@ -15,10 +15,11 @@ import 'pathe';
|
|
|
15
15
|
import 'node:fs';
|
|
16
16
|
import 'node:assert';
|
|
17
17
|
import 'node:perf_hooks';
|
|
18
|
+
import 'es-module-lexer';
|
|
18
19
|
import './constants.mjs';
|
|
19
20
|
import 'node:events';
|
|
20
21
|
|
|
21
|
-
var version = "2.1.
|
|
22
|
+
var version = "2.1.6";
|
|
22
23
|
|
|
23
24
|
const cli = cac("vite-node");
|
|
24
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");
|
package/dist/server.cjs
CHANGED
|
@@ -7,12 +7,32 @@ var node_url = require('node:url');
|
|
|
7
7
|
var createDebug = require('debug');
|
|
8
8
|
var pathe = require('pathe');
|
|
9
9
|
var browser = require('./chunk-browser.cjs');
|
|
10
|
+
var esModuleLexer = require('es-module-lexer');
|
|
10
11
|
var constants = require('./constants.cjs');
|
|
11
12
|
var utils = require('./utils.cjs');
|
|
12
13
|
var sourceMap = require('./source-map.cjs');
|
|
13
14
|
require('node:module');
|
|
14
15
|
require('node:path');
|
|
15
16
|
|
|
17
|
+
function _interopNamespaceDefault(e) {
|
|
18
|
+
var n = Object.create(null);
|
|
19
|
+
if (e) {
|
|
20
|
+
Object.keys(e).forEach(function (k) {
|
|
21
|
+
if (k !== 'default') {
|
|
22
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return e[k]; }
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
n.default = e;
|
|
31
|
+
return Object.freeze(n);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var esModuleLexer__namespace = /*#__PURE__*/_interopNamespaceDefault(esModuleLexer);
|
|
35
|
+
|
|
16
36
|
function hashCode(s) {
|
|
17
37
|
return s.split("").reduce((a, b) => {
|
|
18
38
|
a = (a << 5) - a + b.charCodeAt(0);
|
|
@@ -111,10 +131,8 @@ ${result.code}`,
|
|
|
111
131
|
}
|
|
112
132
|
|
|
113
133
|
const BUILTIN_EXTENSIONS = /* @__PURE__ */ new Set([".mjs", ".cjs", ".node", ".wasm"]);
|
|
114
|
-
const ESM_SYNTAX_RE = /(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
|
|
115
134
|
const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
|
|
116
135
|
const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
|
|
117
|
-
const COMMENT_RE = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm;
|
|
118
136
|
const defaultInline = [
|
|
119
137
|
/virtual:/,
|
|
120
138
|
/\.[mc]?ts$/,
|
|
@@ -169,8 +187,14 @@ async function isValidNodeImport(id) {
|
|
|
169
187
|
if (/\.(?:\w+-)?esm?(?:-\w+)?\.js$|\/esm?\//.test(id)) {
|
|
170
188
|
return false;
|
|
171
189
|
}
|
|
172
|
-
|
|
173
|
-
|
|
190
|
+
try {
|
|
191
|
+
await esModuleLexer__namespace.init;
|
|
192
|
+
const code = await fs.promises.readFile(id, "utf8");
|
|
193
|
+
const [, , , hasModuleSyntax] = esModuleLexer__namespace.parse(code);
|
|
194
|
+
return !hasModuleSyntax;
|
|
195
|
+
} catch {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
174
198
|
}
|
|
175
199
|
const _defaultExternalizeCache = /* @__PURE__ */ new Map();
|
|
176
200
|
async function shouldExternalize(id, options, cache = _defaultExternalizeCache) {
|
package/dist/server.mjs
CHANGED
|
@@ -5,6 +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 { f } from './chunk-browser.mjs';
|
|
8
|
+
import * as esModuleLexer from 'es-module-lexer';
|
|
8
9
|
import { KNOWN_ASSET_RE } from './constants.mjs';
|
|
9
10
|
import { isNodeBuiltin, slash, findNearestPackageData, toArray, withTrailingSlash, normalizeModuleId, toFilePath } from './utils.mjs';
|
|
10
11
|
import { withInlineSourcemap } from './source-map.mjs';
|
|
@@ -109,10 +110,8 @@ ${result.code}`,
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
const BUILTIN_EXTENSIONS = /* @__PURE__ */ new Set([".mjs", ".cjs", ".node", ".wasm"]);
|
|
112
|
-
const ESM_SYNTAX_RE = /(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
|
|
113
113
|
const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
|
|
114
114
|
const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
|
|
115
|
-
const COMMENT_RE = /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm;
|
|
116
115
|
const defaultInline = [
|
|
117
116
|
/virtual:/,
|
|
118
117
|
/\.[mc]?ts$/,
|
|
@@ -167,8 +166,14 @@ async function isValidNodeImport(id) {
|
|
|
167
166
|
if (/\.(?:\w+-)?esm?(?:-\w+)?\.js$|\/esm?\//.test(id)) {
|
|
168
167
|
return false;
|
|
169
168
|
}
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
try {
|
|
170
|
+
await esModuleLexer.init;
|
|
171
|
+
const code = await promises.readFile(id, "utf8");
|
|
172
|
+
const [, , , hasModuleSyntax] = esModuleLexer.parse(code);
|
|
173
|
+
return !hasModuleSyntax;
|
|
174
|
+
} catch {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
172
177
|
}
|
|
173
178
|
const _defaultExternalizeCache = /* @__PURE__ */ new Map();
|
|
174
179
|
async function shouldExternalize(id, options, cache = _defaultExternalizeCache) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.6",
|
|
5
5
|
"description": "Vite as Node.js runtime",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -74,13 +74,14 @@
|
|
|
74
74
|
"dist"
|
|
75
75
|
],
|
|
76
76
|
"engines": {
|
|
77
|
-
"node": "^18.0.0 ||
|
|
77
|
+
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"cac": "^6.7.14",
|
|
81
81
|
"debug": "^4.3.7",
|
|
82
|
+
"es-module-lexer": "^1.5.4",
|
|
82
83
|
"pathe": "^1.1.2",
|
|
83
|
-
"vite": "^5.0.0"
|
|
84
|
+
"vite": "^5.0.0 || ^6.0.0"
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
87
|
"@jridgewell/trace-mapping": "^0.3.25",
|