vite-node 0.24.2 → 0.24.4

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/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.2";
633
+ var version = "0.24.4";
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
@@ -1,4 +1,4 @@
1
- import { e as ViteNodeServerOptions } from './types-11eb03da.js';
1
+ import { e as ViteNodeServerOptions } from './types-ab8db104.js';
2
2
 
3
3
  interface CliOptions {
4
4
  root?: string;
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.2";
631
+ var version = "0.24.4";
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 (p !== "default") {
222
- if (!Reflect.has(exports, "default"))
223
- exports.default = {};
224
- if (exports.default === null || typeof exports.default !== "object") {
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
- return Reflect.set(exports, p, value);
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
- cjsExports.default = value;
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-11eb03da.js';
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 (p !== "default") {
195
- if (!Reflect.has(exports, "default"))
196
- exports.default = {};
197
- if (exports.default === null || typeof exports.default !== "object") {
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
- return Reflect.set(exports, p, value);
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
- cjsExports.default = value;
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-11eb03da.js';
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-11eb03da.js';
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-11eb03da.js';
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-11eb03da.js';
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
 
@@ -42,7 +43,16 @@ function pathFromRoot(root, filename) {
42
43
  return relativePath;
43
44
  }
44
45
  function toFilePath(id, root) {
45
- let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? pathe.resolve(root, id.slice(1)) : id;
46
+ let absolute = (() => {
47
+ if (id.startsWith("/@fs/"))
48
+ return id.slice(4);
49
+ if (!id.startsWith(root) && id.startsWith("/")) {
50
+ const resolved = pathe.resolve(root, id.slice(1));
51
+ if (fs.existsSync(resolved.replace(/\?.*$/, "")))
52
+ return resolved;
53
+ }
54
+ return id;
55
+ })();
46
56
  if (absolute.startsWith("//"))
47
57
  absolute = absolute.slice(1);
48
58
  return isWindows && absolute.startsWith("/") ? slash(url.fileURLToPath(url.pathToFileURL(absolute.slice(1)).href)) : absolute;
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TransformResult } from 'vite';
2
- import { N as Nullable, A as Arrayable } from './types-11eb03da.js';
2
+ import { N as Nullable, A as Arrayable } from './types-ab8db104.js';
3
3
 
4
4
  declare const isWindows: boolean;
5
5
  declare function slash(str: string): string;
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
 
@@ -38,7 +39,16 @@ function pathFromRoot(root, filename) {
38
39
  return relativePath;
39
40
  }
40
41
  function toFilePath(id, root) {
41
- let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? resolve(root, id.slice(1)) : id;
42
+ let absolute = (() => {
43
+ if (id.startsWith("/@fs/"))
44
+ return id.slice(4);
45
+ if (!id.startsWith(root) && id.startsWith("/")) {
46
+ const resolved = resolve(root, id.slice(1));
47
+ if (existsSync(resolved.replace(/\?.*$/, "")))
48
+ return resolved;
49
+ }
50
+ return id;
51
+ })();
42
52
  if (absolute.startsWith("//"))
43
53
  absolute = absolute.slice(1);
44
54
  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.2",
3
+ "version": "0.24.4",
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.1.7"
70
+ "vite": "^3.0.0"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/debug": "^4.1.7",