vite-node 0.24.3 → 0.24.5
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 +3 -0
- package/dist/chunk-hmr.mjs +3 -0
- package/dist/cli.cjs +6 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +6 -1
- package/dist/client.cjs +10 -11
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +10 -11
- package/dist/hmr.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/{types-11eb03da.d.ts → types-ab8db104.d.ts} +5 -0
- package/dist/types.d.ts +1 -1
- package/dist/utils.cjs +14 -10
- package/dist/utils.d.ts +1 -1
- package/dist/utils.mjs +14 -10
- package/package.json +2 -2
package/dist/chunk-hmr.cjs
CHANGED
|
@@ -146,9 +146,11 @@ async function handleMessage(runner, emitter, files, payload) {
|
|
|
146
146
|
});
|
|
147
147
|
break;
|
|
148
148
|
case "full-reload":
|
|
149
|
+
notifyListeners(runner, "vite:beforeFullReload", payload);
|
|
149
150
|
reload(runner, files);
|
|
150
151
|
break;
|
|
151
152
|
case "prune":
|
|
153
|
+
notifyListeners(runner, "vite:beforePrune", payload);
|
|
152
154
|
payload.paths.forEach((path) => {
|
|
153
155
|
const fn = maps.pruneMap.get(path);
|
|
154
156
|
if (fn)
|
|
@@ -209,6 +211,7 @@ function createHotContext(runner, emitter, files, ownerPath) {
|
|
|
209
211
|
maps.pruneMap.set(ownerPath, cb);
|
|
210
212
|
},
|
|
211
213
|
invalidate() {
|
|
214
|
+
notifyListeners(runner, "vite:invalidate", { path: ownerPath });
|
|
212
215
|
return reload(runner, files);
|
|
213
216
|
},
|
|
214
217
|
on(event, cb) {
|
package/dist/chunk-hmr.mjs
CHANGED
|
@@ -140,9 +140,11 @@ async function handleMessage(runner, emitter, files, payload) {
|
|
|
140
140
|
});
|
|
141
141
|
break;
|
|
142
142
|
case "full-reload":
|
|
143
|
+
notifyListeners(runner, "vite:beforeFullReload", payload);
|
|
143
144
|
reload(runner, files);
|
|
144
145
|
break;
|
|
145
146
|
case "prune":
|
|
147
|
+
notifyListeners(runner, "vite:beforePrune", payload);
|
|
146
148
|
payload.paths.forEach((path) => {
|
|
147
149
|
const fn = maps.pruneMap.get(path);
|
|
148
150
|
if (fn)
|
|
@@ -203,6 +205,7 @@ function createHotContext(runner, emitter, files, ownerPath) {
|
|
|
203
205
|
maps.pruneMap.set(ownerPath, cb);
|
|
204
206
|
},
|
|
205
207
|
invalidate() {
|
|
208
|
+
notifyListeners(runner, "vite:invalidate", { path: ownerPath });
|
|
206
209
|
return reload(runner, files);
|
|
207
210
|
},
|
|
208
211
|
on(event, cb) {
|
package/dist/cli.cjs
CHANGED
|
@@ -630,7 +630,7 @@ class CAC extends events.EventEmitter {
|
|
|
630
630
|
|
|
631
631
|
const cac = (name = "") => new CAC(name);
|
|
632
632
|
|
|
633
|
-
var version = "0.24.
|
|
633
|
+
var version = "0.24.5";
|
|
634
634
|
|
|
635
635
|
const cli = cac("vite-node");
|
|
636
636
|
cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--options <options>", "Use specified Vite server options").help();
|
|
@@ -676,6 +676,11 @@ async function run(files, options = {}) {
|
|
|
676
676
|
(_a = server$1.emitter) == null ? void 0 : _a.on("message", (payload) => {
|
|
677
677
|
hmr.handleMessage(runner, server$1.emitter, files, payload);
|
|
678
678
|
});
|
|
679
|
+
if (options.watch) {
|
|
680
|
+
process.on("uncaughtException", (err) => {
|
|
681
|
+
console.error(picocolors.picocolors.exports.red("[vite-node] Failed to execute file: \n"), err);
|
|
682
|
+
});
|
|
683
|
+
}
|
|
679
684
|
}
|
|
680
685
|
function parseServerOptions(serverOptions) {
|
|
681
686
|
var _a, _b, _c, _d, _e;
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -628,7 +628,7 @@ class CAC extends EventEmitter {
|
|
|
628
628
|
|
|
629
629
|
const cac = (name = "") => new CAC(name);
|
|
630
630
|
|
|
631
|
-
var version = "0.24.
|
|
631
|
+
var version = "0.24.5";
|
|
632
632
|
|
|
633
633
|
const cli = cac("vite-node");
|
|
634
634
|
cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--options <options>", "Use specified Vite server options").help();
|
|
@@ -674,6 +674,11 @@ async function run(files, options = {}) {
|
|
|
674
674
|
(_a = server.emitter) == null ? void 0 : _a.on("message", (payload) => {
|
|
675
675
|
handleMessage(runner, server.emitter, files, payload);
|
|
676
676
|
});
|
|
677
|
+
if (options.watch) {
|
|
678
|
+
process.on("uncaughtException", (err) => {
|
|
679
|
+
console.error(picocolors.exports.red("[vite-node] Failed to execute file: \n"), err);
|
|
680
|
+
});
|
|
681
|
+
}
|
|
677
682
|
}
|
|
678
683
|
function parseServerOptions(serverOptions) {
|
|
679
684
|
var _a, _b, _c, _d, _e;
|
package/dist/client.cjs
CHANGED
|
@@ -9,6 +9,7 @@ var pathe = require('pathe');
|
|
|
9
9
|
var mlly = require('mlly');
|
|
10
10
|
var createDebug = require('debug');
|
|
11
11
|
var utils = require('./utils.cjs');
|
|
12
|
+
require('fs');
|
|
12
13
|
|
|
13
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
15
|
|
|
@@ -218,18 +219,16 @@ ${getStack()}`), 2e3);
|
|
|
218
219
|
return Reflect.get(exports, p, receiver);
|
|
219
220
|
},
|
|
220
221
|
set(_, p, value) {
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
defineExport(exports, p, () => void 0);
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
exports.default[p] = value;
|
|
229
|
-
defineExport(exports, p, () => value);
|
|
222
|
+
if (!Reflect.has(exports, "default"))
|
|
223
|
+
exports.default = {};
|
|
224
|
+
if (exports.default === null || typeof exports.default !== "object") {
|
|
225
|
+
defineExport(exports, p, () => void 0);
|
|
230
226
|
return true;
|
|
231
227
|
}
|
|
232
|
-
|
|
228
|
+
exports.default[p] = value;
|
|
229
|
+
if (p !== "default")
|
|
230
|
+
defineExport(exports, p, () => value);
|
|
231
|
+
return true;
|
|
233
232
|
}
|
|
234
233
|
});
|
|
235
234
|
Object.assign(mod, { code: transformed, exports });
|
|
@@ -237,7 +236,7 @@ ${getStack()}`), 2e3);
|
|
|
237
236
|
const moduleProxy = {
|
|
238
237
|
set exports(value) {
|
|
239
238
|
exportAll(cjsExports, value);
|
|
240
|
-
|
|
239
|
+
exports.default = value;
|
|
241
240
|
},
|
|
242
241
|
get exports() {
|
|
243
242
|
return cjsExports;
|
package/dist/client.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-
|
|
1
|
+
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-ab8db104.js';
|
package/dist/client.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { resolve, dirname, isAbsolute, extname } from 'pathe';
|
|
|
5
5
|
import { isNodeBuiltin } from 'mlly';
|
|
6
6
|
import createDebug from 'debug';
|
|
7
7
|
import { normalizeModuleId, slash, normalizeRequestId, toFilePath, isPrimitive, mergeSlashes } from './utils.mjs';
|
|
8
|
+
import 'fs';
|
|
8
9
|
|
|
9
10
|
const debugExecute = createDebug("vite-node:client:execute");
|
|
10
11
|
const debugNative = createDebug("vite-node:client:native");
|
|
@@ -191,18 +192,16 @@ ${getStack()}`), 2e3);
|
|
|
191
192
|
return Reflect.get(exports, p, receiver);
|
|
192
193
|
},
|
|
193
194
|
set(_, p, value) {
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
defineExport(exports, p, () => void 0);
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
exports.default[p] = value;
|
|
202
|
-
defineExport(exports, p, () => value);
|
|
195
|
+
if (!Reflect.has(exports, "default"))
|
|
196
|
+
exports.default = {};
|
|
197
|
+
if (exports.default === null || typeof exports.default !== "object") {
|
|
198
|
+
defineExport(exports, p, () => void 0);
|
|
203
199
|
return true;
|
|
204
200
|
}
|
|
205
|
-
|
|
201
|
+
exports.default[p] = value;
|
|
202
|
+
if (p !== "default")
|
|
203
|
+
defineExport(exports, p, () => value);
|
|
204
|
+
return true;
|
|
206
205
|
}
|
|
207
206
|
});
|
|
208
207
|
Object.assign(mod, { code: transformed, exports });
|
|
@@ -210,7 +209,7 @@ ${getStack()}`), 2e3);
|
|
|
210
209
|
const moduleProxy = {
|
|
211
210
|
set exports(value) {
|
|
212
211
|
exportAll(cjsExports, value);
|
|
213
|
-
|
|
212
|
+
exports.default = value;
|
|
214
213
|
},
|
|
215
214
|
get exports() {
|
|
216
215
|
return cjsExports;
|
package/dist/hmr.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { HMRPayload, Plugin } from 'vite';
|
|
3
|
-
import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-
|
|
3
|
+
import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-ab8db104.js';
|
|
4
4
|
|
|
5
5
|
declare type EventType = string | symbol;
|
|
6
6
|
declare type Handler<T = unknown> = (event: T) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-ab8db104.js';
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
|
-
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './types-
|
|
2
|
+
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './types-ab8db104.js';
|
|
3
3
|
|
|
4
4
|
declare class Debugger {
|
|
5
5
|
options: DebuggerOptions;
|
|
@@ -65,6 +65,11 @@ interface CustomEventMap {
|
|
|
65
65
|
'vite:beforePrune': PrunePayload
|
|
66
66
|
'vite:beforeFullReload': FullReloadPayload
|
|
67
67
|
'vite:error': ErrorPayload
|
|
68
|
+
'vite:invalidate': InvalidatePayload
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface InvalidatePayload {
|
|
72
|
+
path: string
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
type InferCustomEventPayload<T extends string> =
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-ab8db104.js';
|
package/dist/utils.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var url = require('url');
|
|
6
|
+
var fs = require('fs');
|
|
6
7
|
var pathe = require('pathe');
|
|
7
8
|
var mlly = require('mlly');
|
|
8
9
|
|
|
@@ -31,18 +32,21 @@ function pathFromRoot(root, filename) {
|
|
|
31
32
|
if (!filename.startsWith(root))
|
|
32
33
|
return filename;
|
|
33
34
|
const relativePath = pathe.relative(root, filename);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
for (const char of relativePath) {
|
|
38
|
-
if (char !== "." && char !== "/")
|
|
39
|
-
return relativePath.slice(index - 1);
|
|
40
|
-
index++;
|
|
41
|
-
}
|
|
42
|
-
return relativePath;
|
|
35
|
+
const segments = relativePath.split("/");
|
|
36
|
+
const startIndex = segments.findIndex((segment) => segment !== ".." && segment !== ".");
|
|
37
|
+
return `/${segments.slice(startIndex).join("/")}`;
|
|
43
38
|
}
|
|
44
39
|
function toFilePath(id, root) {
|
|
45
|
-
let absolute =
|
|
40
|
+
let absolute = (() => {
|
|
41
|
+
if (id.startsWith("/@fs/"))
|
|
42
|
+
return id.slice(4);
|
|
43
|
+
if (!id.startsWith(root) && id.startsWith("/")) {
|
|
44
|
+
const resolved = pathe.resolve(root, id.slice(1));
|
|
45
|
+
if (fs.existsSync(resolved.replace(/\?.*$/, "")))
|
|
46
|
+
return resolved;
|
|
47
|
+
}
|
|
48
|
+
return id;
|
|
49
|
+
})();
|
|
46
50
|
if (absolute.startsWith("//"))
|
|
47
51
|
absolute = absolute.slice(1);
|
|
48
52
|
return isWindows && absolute.startsWith("/") ? slash(url.fileURLToPath(url.pathToFileURL(absolute.slice(1)).href)) : absolute;
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
2
3
|
import { relative, resolve } from 'pathe';
|
|
3
4
|
import { isNodeBuiltin } from 'mlly';
|
|
4
5
|
|
|
@@ -27,18 +28,21 @@ function pathFromRoot(root, filename) {
|
|
|
27
28
|
if (!filename.startsWith(root))
|
|
28
29
|
return filename;
|
|
29
30
|
const relativePath = relative(root, filename);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
for (const char of relativePath) {
|
|
34
|
-
if (char !== "." && char !== "/")
|
|
35
|
-
return relativePath.slice(index - 1);
|
|
36
|
-
index++;
|
|
37
|
-
}
|
|
38
|
-
return relativePath;
|
|
31
|
+
const segments = relativePath.split("/");
|
|
32
|
+
const startIndex = segments.findIndex((segment) => segment !== ".." && segment !== ".");
|
|
33
|
+
return `/${segments.slice(startIndex).join("/")}`;
|
|
39
34
|
}
|
|
40
35
|
function toFilePath(id, root) {
|
|
41
|
-
let absolute =
|
|
36
|
+
let absolute = (() => {
|
|
37
|
+
if (id.startsWith("/@fs/"))
|
|
38
|
+
return id.slice(4);
|
|
39
|
+
if (!id.startsWith(root) && id.startsWith("/")) {
|
|
40
|
+
const resolved = resolve(root, id.slice(1));
|
|
41
|
+
if (existsSync(resolved.replace(/\?.*$/, "")))
|
|
42
|
+
return resolved;
|
|
43
|
+
}
|
|
44
|
+
return id;
|
|
45
|
+
})();
|
|
42
46
|
if (absolute.startsWith("//"))
|
|
43
47
|
absolute = absolute.slice(1);
|
|
44
48
|
return isWindows && absolute.startsWith("/") ? slash(fileURLToPath(pathToFileURL(absolute.slice(1)).href)) : absolute;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.5",
|
|
4
4
|
"description": "Vite as Node.js runtime",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"debug": "^4.3.4",
|
|
68
68
|
"mlly": "^0.5.16",
|
|
69
69
|
"pathe": "^0.2.0",
|
|
70
|
-
"vite": "^3.
|
|
70
|
+
"vite": "^3.0.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/debug": "^4.1.7",
|