vite-node 0.26.2 → 0.26.3

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
@@ -634,7 +634,7 @@ class CAC extends events.EventEmitter {
634
634
 
635
635
  const cac = (name = "") => new CAC(name);
636
636
 
637
- var version = "0.26.2";
637
+ var version = "0.26.3";
638
638
 
639
639
  const cli = cac("vite-node");
640
640
  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-6a15e0b9.js';
1
+ import { e as ViteNodeServerOptions } from './types-63205a44.js';
2
2
 
3
3
  interface CliOptions {
4
4
  root?: string;
package/dist/cli.mjs CHANGED
@@ -632,7 +632,7 @@ class CAC extends EventEmitter {
632
632
 
633
633
  const cac = (name = "") => new CAC(name);
634
634
 
635
- var version = "0.26.2";
635
+ var version = "0.26.3";
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/client.cjs CHANGED
@@ -87,19 +87,25 @@ class ModuleCacheMap extends Map {
87
87
  Object.assign(super.get(fsPath), mod);
88
88
  return this;
89
89
  }
90
+ setByModuleId(modulePath, mod) {
91
+ return super.set(modulePath, mod);
92
+ }
90
93
  set(fsPath, mod) {
91
- fsPath = this.normalizePath(fsPath);
92
- return super.set(fsPath, mod);
94
+ return this.setByModuleId(this.normalizePath(fsPath), mod);
95
+ }
96
+ getByModuleId(modulePath) {
97
+ if (!super.has(modulePath))
98
+ super.set(modulePath, {});
99
+ return super.get(modulePath);
93
100
  }
94
101
  get(fsPath) {
95
- fsPath = this.normalizePath(fsPath);
96
- if (!super.has(fsPath))
97
- super.set(fsPath, {});
98
- return super.get(fsPath);
102
+ return this.getByModuleId(this.normalizePath(fsPath));
103
+ }
104
+ deleteByModuleId(modulePath) {
105
+ return super.delete(modulePath);
99
106
  }
100
107
  delete(fsPath) {
101
- fsPath = this.normalizePath(fsPath);
102
- return super.delete(fsPath);
108
+ return this.deleteByModuleId(this.normalizePath(fsPath));
103
109
  }
104
110
  invalidateDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
105
111
  for (const _id of ids) {
@@ -181,7 +187,7 @@ class ViteNodeRunner {
181
187
  shouldResolveId(id, _importee) {
182
188
  return !utils.isInternalRequest(id) && !mlly.isNodeBuiltin(id);
183
189
  }
184
- async resolveUrl(id, importee) {
190
+ async _resolveUrl(id, importee) {
185
191
  if (!this.shouldResolveId(id))
186
192
  return [id, id];
187
193
  if (importee && id.startsWith(utils.VALID_ID_PREFIX))
@@ -194,6 +200,15 @@ class ViteNodeRunner {
194
200
  const fsPath = resolved ? resolvedId : utils.toFilePath(id, this.root);
195
201
  return [resolvedId, fsPath];
196
202
  }
203
+ async resolveUrl(id, importee) {
204
+ const resolveKey = `resolve:${id}`;
205
+ this.moduleCache.setByModuleId(resolveKey, { resolving: true });
206
+ try {
207
+ return await this._resolveUrl(id, importee);
208
+ } finally {
209
+ this.moduleCache.deleteByModuleId(resolveKey);
210
+ }
211
+ }
197
212
  async dependencyRequest(id, fsPath, callstack) {
198
213
  var _a;
199
214
  const getStack = () => {
@@ -220,7 +235,7 @@ ${getStack()}`), 2e3);
220
235
  async directRequest(id, fsPath, _callstack) {
221
236
  const moduleId = utils.normalizeModuleId(fsPath);
222
237
  const callstack = [..._callstack, moduleId];
223
- const mod = this.moduleCache.get(fsPath);
238
+ const mod = this.moduleCache.getByModuleId(moduleId);
224
239
  const request = async (dep) => {
225
240
  const [id2, depFsPath] = await this.resolveUrl(dep, fsPath);
226
241
  return this.dependencyRequest(id2, depFsPath, callstack);
@@ -339,6 +354,25 @@ ${getStack()}`), 2e3);
339
354
  if (prop === "default")
340
355
  return defaultExport !== void 0;
341
356
  return prop in mod2 || defaultExport && prop in defaultExport;
357
+ },
358
+ ownKeys(mod2) {
359
+ const keys = Reflect.ownKeys(mod2);
360
+ if (!defaultExport || utils.isPrimitive(defaultExport))
361
+ return keys;
362
+ const allKeys = [...keys, "default", ...Reflect.ownKeys(defaultExport)];
363
+ return Array.from(new Set(allKeys));
364
+ },
365
+ getOwnPropertyDescriptor(mod2, prop) {
366
+ const descriptor = Reflect.getOwnPropertyDescriptor(mod2, prop);
367
+ if (descriptor)
368
+ return descriptor;
369
+ if (prop === "default" && defaultExport !== void 0) {
370
+ return {
371
+ value: defaultExport,
372
+ enumerable: true,
373
+ configurable: true
374
+ };
375
+ }
342
376
  }
343
377
  });
344
378
  }
package/dist/client.d.ts CHANGED
@@ -1 +1 @@
1
- export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-6a15e0b9.js';
1
+ export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-63205a44.js';
package/dist/client.mjs CHANGED
@@ -60,19 +60,25 @@ class ModuleCacheMap extends Map {
60
60
  Object.assign(super.get(fsPath), mod);
61
61
  return this;
62
62
  }
63
+ setByModuleId(modulePath, mod) {
64
+ return super.set(modulePath, mod);
65
+ }
63
66
  set(fsPath, mod) {
64
- fsPath = this.normalizePath(fsPath);
65
- return super.set(fsPath, mod);
67
+ return this.setByModuleId(this.normalizePath(fsPath), mod);
68
+ }
69
+ getByModuleId(modulePath) {
70
+ if (!super.has(modulePath))
71
+ super.set(modulePath, {});
72
+ return super.get(modulePath);
66
73
  }
67
74
  get(fsPath) {
68
- fsPath = this.normalizePath(fsPath);
69
- if (!super.has(fsPath))
70
- super.set(fsPath, {});
71
- return super.get(fsPath);
75
+ return this.getByModuleId(this.normalizePath(fsPath));
76
+ }
77
+ deleteByModuleId(modulePath) {
78
+ return super.delete(modulePath);
72
79
  }
73
80
  delete(fsPath) {
74
- fsPath = this.normalizePath(fsPath);
75
- return super.delete(fsPath);
81
+ return this.deleteByModuleId(this.normalizePath(fsPath));
76
82
  }
77
83
  invalidateDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
78
84
  for (const _id of ids) {
@@ -154,7 +160,7 @@ class ViteNodeRunner {
154
160
  shouldResolveId(id, _importee) {
155
161
  return !isInternalRequest(id) && !isNodeBuiltin(id);
156
162
  }
157
- async resolveUrl(id, importee) {
163
+ async _resolveUrl(id, importee) {
158
164
  if (!this.shouldResolveId(id))
159
165
  return [id, id];
160
166
  if (importee && id.startsWith(VALID_ID_PREFIX))
@@ -167,6 +173,15 @@ class ViteNodeRunner {
167
173
  const fsPath = resolved ? resolvedId : toFilePath(id, this.root);
168
174
  return [resolvedId, fsPath];
169
175
  }
176
+ async resolveUrl(id, importee) {
177
+ const resolveKey = `resolve:${id}`;
178
+ this.moduleCache.setByModuleId(resolveKey, { resolving: true });
179
+ try {
180
+ return await this._resolveUrl(id, importee);
181
+ } finally {
182
+ this.moduleCache.deleteByModuleId(resolveKey);
183
+ }
184
+ }
170
185
  async dependencyRequest(id, fsPath, callstack) {
171
186
  var _a;
172
187
  const getStack = () => {
@@ -193,7 +208,7 @@ ${getStack()}`), 2e3);
193
208
  async directRequest(id, fsPath, _callstack) {
194
209
  const moduleId = normalizeModuleId(fsPath);
195
210
  const callstack = [..._callstack, moduleId];
196
- const mod = this.moduleCache.get(fsPath);
211
+ const mod = this.moduleCache.getByModuleId(moduleId);
197
212
  const request = async (dep) => {
198
213
  const [id2, depFsPath] = await this.resolveUrl(dep, fsPath);
199
214
  return this.dependencyRequest(id2, depFsPath, callstack);
@@ -312,6 +327,25 @@ ${getStack()}`), 2e3);
312
327
  if (prop === "default")
313
328
  return defaultExport !== void 0;
314
329
  return prop in mod2 || defaultExport && prop in defaultExport;
330
+ },
331
+ ownKeys(mod2) {
332
+ const keys = Reflect.ownKeys(mod2);
333
+ if (!defaultExport || isPrimitive(defaultExport))
334
+ return keys;
335
+ const allKeys = [...keys, "default", ...Reflect.ownKeys(defaultExport)];
336
+ return Array.from(new Set(allKeys));
337
+ },
338
+ getOwnPropertyDescriptor(mod2, prop) {
339
+ const descriptor = Reflect.getOwnPropertyDescriptor(mod2, prop);
340
+ if (descriptor)
341
+ return descriptor;
342
+ if (prop === "default" && defaultExport !== void 0) {
343
+ return {
344
+ value: defaultExport,
345
+ enumerable: true,
346
+ configurable: true
347
+ };
348
+ }
315
349
  }
316
350
  });
317
351
  }
package/dist/hmr.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'node: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-6a15e0b9.js';
3
+ import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-63205a44.js';
4
4
 
5
5
  type EventType = string | symbol;
6
6
  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-6a15e0b9.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-63205a44.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-6a15e0b9.js';
2
+ import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId, R as RawSourceMap } from './types-63205a44.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-6a15e0b9.js';
2
+ import { R as RawSourceMap } from './types-63205a44.js';
3
3
 
4
4
  interface InstallSourceMapSupportOptions {
5
5
  getSourceMap: (source: string) => RawSourceMap | null | undefined;
@@ -140,8 +140,11 @@ declare class ModuleCacheMap extends Map<string, ModuleCache> {
140
140
  * Assign partial data to the map
141
141
  */
142
142
  update(fsPath: string, mod: Partial<ModuleCache>): this;
143
+ setByModuleId(modulePath: string, mod: ModuleCache): this;
143
144
  set(fsPath: string, mod: ModuleCache): this;
145
+ getByModuleId(modulePath: string): ModuleCache;
144
146
  get(fsPath: string): ModuleCache;
147
+ deleteByModuleId(modulePath: string): boolean;
145
148
  delete(fsPath: string): boolean;
146
149
  /**
147
150
  * Invalidate modules that dependent on the given modules, up to the main entry
@@ -172,6 +175,7 @@ declare class ViteNodeRunner {
172
175
  /** @internal */
173
176
  cachedRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
174
177
  shouldResolveId(id: string, _importee?: string): boolean;
178
+ private _resolveUrl;
175
179
  resolveUrl(id: string, importee?: string): Promise<[url: string, fsPath: string]>;
176
180
  /** @internal */
177
181
  dependencyRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
@@ -224,6 +228,7 @@ interface ModuleCache {
224
228
  promise?: Promise<any>;
225
229
  exports?: any;
226
230
  evaluated?: boolean;
231
+ resolving?: boolean;
227
232
  code?: string;
228
233
  map?: RawSourceMap;
229
234
  /**
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-6a15e0b9.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-63205a44.js';
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as Nullable, A as Arrayable } from './types-6a15e0b9.js';
1
+ import { N as Nullable, A as Arrayable } from './types-63205a44.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.26.2",
3
+ "version": "0.26.3",
4
4
  "description": "Vite as Node.js runtime",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",