vite-node 0.25.6 → 0.25.8

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.
@@ -193,6 +193,9 @@ function createHotContext(runner, emitter, files, ownerPath) {
193
193
  get data() {
194
194
  return maps.dataMap.get(ownerPath);
195
195
  },
196
+ acceptExports(_, callback) {
197
+ acceptDeps([ownerPath], callback && (([mod2]) => callback(mod2)));
198
+ },
196
199
  accept(deps, callback) {
197
200
  if (typeof deps === "function" || !deps) {
198
201
  acceptDeps([ownerPath], ([mod2]) => deps && deps(mod2));
@@ -211,7 +214,7 @@ function createHotContext(runner, emitter, files, ownerPath) {
211
214
  maps.pruneMap.set(ownerPath, cb);
212
215
  },
213
216
  invalidate() {
214
- notifyListeners(runner, "vite:invalidate", { path: ownerPath });
217
+ notifyListeners(runner, "vite:invalidate", { path: ownerPath, message: void 0 });
215
218
  return reload(runner, files);
216
219
  },
217
220
  on(event, cb) {
@@ -187,6 +187,9 @@ function createHotContext(runner, emitter, files, ownerPath) {
187
187
  get data() {
188
188
  return maps.dataMap.get(ownerPath);
189
189
  },
190
+ acceptExports(_, callback) {
191
+ acceptDeps([ownerPath], callback && (([mod2]) => callback(mod2)));
192
+ },
190
193
  accept(deps, callback) {
191
194
  if (typeof deps === "function" || !deps) {
192
195
  acceptDeps([ownerPath], ([mod2]) => deps && deps(mod2));
@@ -205,7 +208,7 @@ function createHotContext(runner, emitter, files, ownerPath) {
205
208
  maps.pruneMap.set(ownerPath, cb);
206
209
  },
207
210
  invalidate() {
208
- notifyListeners(runner, "vite:invalidate", { path: ownerPath });
211
+ notifyListeners(runner, "vite:invalidate", { path: ownerPath, message: void 0 });
209
212
  return reload(runner, files);
210
213
  },
211
214
  on(event, cb) {
package/dist/cli.cjs CHANGED
@@ -632,7 +632,7 @@ class CAC extends events.EventEmitter {
632
632
 
633
633
  const cac = (name = "") => new CAC(name);
634
634
 
635
- var version = "0.25.6";
635
+ var version = "0.25.8";
636
636
 
637
637
  const cli = cac("vite-node");
638
638
  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();
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { e as ViteNodeServerOptions } from './types-60eb9672.js';
1
+ import { e as ViteNodeServerOptions } from './types-fc7e68bc.js';
2
2
 
3
3
  interface CliOptions {
4
4
  root?: string;
@@ -7,10 +7,10 @@ interface CliOptions {
7
7
  options?: ViteNodeServerOptionsCLI;
8
8
  '--'?: string[];
9
9
  }
10
- declare type Optional<T> = T | undefined;
11
- declare type ComputeViteNodeServerOptionsCLI<T extends Record<string, any>> = {
10
+ type Optional<T> = T | undefined;
11
+ type ComputeViteNodeServerOptionsCLI<T extends Record<string, any>> = {
12
12
  [K in keyof T]: T[K] extends Optional<RegExp[]> ? string | string[] : T[K] extends Optional<(string | RegExp)[]> ? string | string[] : T[K] extends Optional<(string | RegExp)[] | true> ? string | string[] | true : T[K] extends Optional<Record<string, any>> ? ComputeViteNodeServerOptionsCLI<T[K]> : T[K];
13
13
  };
14
- declare type ViteNodeServerOptionsCLI = ComputeViteNodeServerOptionsCLI<ViteNodeServerOptions>;
14
+ type ViteNodeServerOptionsCLI = ComputeViteNodeServerOptionsCLI<ViteNodeServerOptions>;
15
15
 
16
16
  export { CliOptions, ViteNodeServerOptionsCLI };
package/dist/cli.mjs CHANGED
@@ -630,7 +630,7 @@ class CAC extends EventEmitter {
630
630
 
631
631
  const cac = (name = "") => new CAC(name);
632
632
 
633
- var version = "0.25.6";
633
+ var version = "0.25.8";
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();
package/dist/client.cjs CHANGED
@@ -169,10 +169,11 @@ class ViteNodeRunner {
169
169
  return mod.promise;
170
170
  const promise = this.directRequest(id, fsPath, callstack);
171
171
  Object.assign(mod, { promise, evaluated: false });
172
- promise.finally(() => {
172
+ try {
173
+ return await promise;
174
+ } finally {
173
175
  mod.evaluated = true;
174
- });
175
- return await promise;
176
+ }
176
177
  }
177
178
  async directRequest(id, fsPath, _callstack) {
178
179
  const callstack = [..._callstack, fsPath];
package/dist/client.d.ts CHANGED
@@ -1 +1 @@
1
- export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-60eb9672.js';
1
+ export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-fc7e68bc.js';
package/dist/client.mjs CHANGED
@@ -142,10 +142,11 @@ class ViteNodeRunner {
142
142
  return mod.promise;
143
143
  const promise = this.directRequest(id, fsPath, callstack);
144
144
  Object.assign(mod, { promise, evaluated: false });
145
- promise.finally(() => {
145
+ try {
146
+ return await promise;
147
+ } finally {
146
148
  mod.evaluated = true;
147
- });
148
- return await promise;
149
+ }
149
150
  }
150
151
  async directRequest(id, fsPath, _callstack) {
151
152
  const callstack = [..._callstack, fsPath];
package/dist/hmr.d.ts CHANGED
@@ -1,16 +1,16 @@
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-60eb9672.js';
3
+ import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-fc7e68bc.js';
4
4
 
5
- declare type EventType = string | symbol;
6
- declare type Handler<T = unknown> = (event: T) => void;
5
+ type EventType = string | symbol;
6
+ type Handler<T = unknown> = (event: T) => void;
7
7
  interface Emitter<Events extends Record<EventType, unknown>> {
8
8
  on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
9
9
  off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;
10
10
  emit<Key extends keyof Events>(type: Key, event: Events[Key]): void;
11
11
  emit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;
12
12
  }
13
- declare type HMREmitter = Emitter<{
13
+ type HMREmitter = Emitter<{
14
14
  'message': HMRPayload;
15
15
  }> & EventEmitter;
16
16
  declare module 'vite' {
@@ -21,7 +21,7 @@ declare module 'vite' {
21
21
  declare function createHmrEmitter(): HMREmitter;
22
22
  declare function viteNodeHmrPlugin(): Plugin;
23
23
 
24
- declare type InferCustomEventPayload<T extends string> = T extends keyof CustomEventMap ? CustomEventMap[T] : any;
24
+ type InferCustomEventPayload<T extends string> = T extends keyof CustomEventMap ? CustomEventMap[T] : any;
25
25
  interface HotModule {
26
26
  id: string;
27
27
  callbacks: HotCallback[];
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-60eb9672.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-fc7e68bc.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, R as RawSourceMap } from './types-60eb9672.js';
2
+ import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId, R as RawSourceMap } from './types-fc7e68bc.js';
3
3
 
4
4
  declare class Debugger {
5
5
  options: DebuggerOptions;
@@ -1,5 +1,5 @@
1
1
  import { TransformResult } from 'vite';
2
- import { R as RawSourceMap } from './types-60eb9672.js';
2
+ import { R as RawSourceMap } from './types-fc7e68bc.js';
3
3
 
4
4
  interface InstallSourceMapSupportOptions {
5
5
  getSourceMap: (source: string) => RawSourceMap | null | undefined;
@@ -71,6 +71,7 @@ interface CustomEventMap {
71
71
 
72
72
  interface InvalidatePayload {
73
73
  path: string
74
+ message: string | undefined
74
75
  }
75
76
 
76
77
  type InferCustomEventPayload<T extends string> =
@@ -88,22 +89,21 @@ interface ViteHotContext {
88
89
  accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
89
90
  accept(
90
91
  deps: readonly string[],
91
- cb: (mods: Array<ModuleNamespace | undefined>) => void
92
+ cb: (mods: Array<ModuleNamespace | undefined>) => void,
92
93
  ): void
93
94
 
94
- acceptExports(exportNames: string | readonly string[]): void
95
95
  acceptExports(
96
96
  exportNames: string | readonly string[],
97
- cb: (mod: ModuleNamespace | undefined) => void
97
+ cb?: (mod: ModuleNamespace | undefined) => void,
98
98
  ): void
99
99
 
100
100
  dispose(cb: (data: any) => void): void
101
- decline(): void
102
- invalidate(): void
101
+ prune(cb: (data: any) => void): void
102
+ invalidate(message?: string): void
103
103
 
104
104
  on<T extends string>(
105
105
  event: T,
106
- cb: (payload: InferCustomEventPayload<T>) => void
106
+ cb: (payload: InferCustomEventPayload<T>) => void,
107
107
  ): void
108
108
  send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
109
109
  }
@@ -175,8 +175,8 @@ declare class ViteNodeRunner {
175
175
  hasNestedDefault(target: any): any;
176
176
  }
177
177
 
178
- declare type Nullable<T> = T | null | undefined;
179
- declare type Arrayable<T> = T | Array<T>;
178
+ type Nullable<T> = T | null | undefined;
179
+ type Arrayable<T> = T | Array<T>;
180
180
  interface DepsHandlingOptions {
181
181
  external?: (string | RegExp)[];
182
182
  inline?: (string | RegExp)[] | true;
@@ -202,10 +202,10 @@ interface FetchResult {
202
202
  externalize?: string;
203
203
  map?: RawSourceMap;
204
204
  }
205
- declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
206
- declare type FetchFunction = (id: string) => Promise<FetchResult>;
207
- declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
208
- declare type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
205
+ type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
206
+ type FetchFunction = (id: string) => Promise<FetchResult>;
207
+ type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
208
+ type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
209
209
  interface ModuleCache {
210
210
  promise?: Promise<any>;
211
211
  exports?: any;
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-60eb9672.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-fc7e68bc.js';
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as Nullable, A as Arrayable } from './types-60eb9672.js';
1
+ import { N as Nullable, A as Arrayable } from './types-fc7e68bc.js';
2
2
 
3
3
  declare const isWindows: boolean;
4
4
  declare function slash(str: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-node",
3
- "version": "0.25.6",
3
+ "version": "0.25.8",
4
4
  "description": "Vite as Node.js runtime",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -74,7 +74,7 @@
74
74
  "pathe": "^0.2.0",
75
75
  "source-map": "^0.6.1",
76
76
  "source-map-support": "^0.5.21",
77
- "vite": "^3.0.0"
77
+ "vite": "^3.0.0 || ^4.0.0"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/debug": "^4.1.7",