vite-node 0.27.0 → 0.27.2

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
@@ -25,7 +25,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
25
25
  var cac__default = /*#__PURE__*/_interopDefaultLegacy(cac);
26
26
  var c__default = /*#__PURE__*/_interopDefaultLegacy(c);
27
27
 
28
- var version = "0.27.0";
28
+ var version = "0.27.2";
29
29
 
30
30
  const cli = cac__default["default"]("vite-node");
31
31
  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.mjs CHANGED
@@ -18,7 +18,7 @@ import 'node:path';
18
18
  import 'node:vm';
19
19
  import 'node:events';
20
20
 
21
- var version = "0.27.0";
21
+ var version = "0.27.2";
22
22
 
23
23
  const cli = cac("vite-node");
24
24
  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
@@ -193,11 +193,12 @@ class ViteNodeRunner {
193
193
  if (importee && id.startsWith(utils.VALID_ID_PREFIX))
194
194
  importee = void 0;
195
195
  id = utils.normalizeRequestId(id, this.options.base);
196
- if (!this.options.resolveId)
197
- return [id, utils.toFilePath(id, this.root)];
196
+ const { path, exists } = utils.toFilePath(id, this.root);
197
+ if (!this.options.resolveId || exists)
198
+ return [id, path];
198
199
  const resolved = await this.options.resolveId(id, importee);
199
200
  const resolvedId = resolved ? utils.normalizeRequestId(resolved.id, this.options.base) : id;
200
- const fsPath = resolved ? resolvedId : utils.toFilePath(id, this.root);
201
+ const fsPath = resolved ? resolvedId : path;
201
202
  return [resolvedId, fsPath];
202
203
  }
203
204
  async resolveUrl(id, importee) {
@@ -344,12 +345,6 @@ ${getStack()}`), 2e3);
344
345
  if (!this.shouldInterop(path, importedModule))
345
346
  return importedModule;
346
347
  const { mod, defaultExport } = interopModule(importedModule);
347
- const modKeys = Reflect.ownKeys(mod);
348
- let defaultKeys = !utils.isPrimitive(defaultExport) ? Reflect.ownKeys(defaultExport) : [];
349
- if (typeof mod !== "function" && typeof defaultExport === "function") {
350
- const reservedKeys = ["arguments", "caller", "prototype", "name", "length"];
351
- defaultKeys = defaultKeys.filter((n) => typeof n === "string" && !reservedKeys.includes(n));
352
- }
353
348
  return new Proxy(mod, {
354
349
  get(mod2, prop) {
355
350
  if (prop === "default")
@@ -361,12 +356,6 @@ ${getStack()}`), 2e3);
361
356
  return defaultExport !== void 0;
362
357
  return prop in mod2 || defaultExport && prop in defaultExport;
363
358
  },
364
- ownKeys() {
365
- if (!defaultExport || utils.isPrimitive(defaultExport))
366
- return modKeys;
367
- const allKeys = [...modKeys, "default", ...defaultKeys];
368
- return Array.from(new Set(allKeys));
369
- },
370
359
  getOwnPropertyDescriptor(mod2, prop) {
371
360
  const descriptor = Reflect.getOwnPropertyDescriptor(mod2, prop);
372
361
  if (descriptor)
package/dist/client.mjs CHANGED
@@ -166,11 +166,12 @@ class ViteNodeRunner {
166
166
  if (importee && id.startsWith(VALID_ID_PREFIX))
167
167
  importee = void 0;
168
168
  id = normalizeRequestId(id, this.options.base);
169
- if (!this.options.resolveId)
170
- return [id, toFilePath(id, this.root)];
169
+ const { path, exists } = toFilePath(id, this.root);
170
+ if (!this.options.resolveId || exists)
171
+ return [id, path];
171
172
  const resolved = await this.options.resolveId(id, importee);
172
173
  const resolvedId = resolved ? normalizeRequestId(resolved.id, this.options.base) : id;
173
- const fsPath = resolved ? resolvedId : toFilePath(id, this.root);
174
+ const fsPath = resolved ? resolvedId : path;
174
175
  return [resolvedId, fsPath];
175
176
  }
176
177
  async resolveUrl(id, importee) {
@@ -317,12 +318,6 @@ ${getStack()}`), 2e3);
317
318
  if (!this.shouldInterop(path, importedModule))
318
319
  return importedModule;
319
320
  const { mod, defaultExport } = interopModule(importedModule);
320
- const modKeys = Reflect.ownKeys(mod);
321
- let defaultKeys = !isPrimitive(defaultExport) ? Reflect.ownKeys(defaultExport) : [];
322
- if (typeof mod !== "function" && typeof defaultExport === "function") {
323
- const reservedKeys = ["arguments", "caller", "prototype", "name", "length"];
324
- defaultKeys = defaultKeys.filter((n) => typeof n === "string" && !reservedKeys.includes(n));
325
- }
326
321
  return new Proxy(mod, {
327
322
  get(mod2, prop) {
328
323
  if (prop === "default")
@@ -334,12 +329,6 @@ ${getStack()}`), 2e3);
334
329
  return defaultExport !== void 0;
335
330
  return prop in mod2 || defaultExport && prop in defaultExport;
336
331
  },
337
- ownKeys() {
338
- if (!defaultExport || isPrimitive(defaultExport))
339
- return modKeys;
340
- const allKeys = [...modKeys, "default", ...defaultKeys];
341
- return Array.from(new Set(allKeys));
342
- },
343
332
  getOwnPropertyDescriptor(mod2, prop) {
344
333
  const descriptor = Reflect.getOwnPropertyDescriptor(mod2, prop);
345
334
  if (descriptor)
package/dist/server.cjs CHANGED
@@ -287,7 +287,7 @@ class ViteNodeServer {
287
287
  async _fetchModule(id) {
288
288
  var _a;
289
289
  let result;
290
- const filePath = utils.toFilePath(id, this.server.config.root);
290
+ const { path: filePath } = utils.toFilePath(id, this.server.config.root);
291
291
  const module = this.server.moduleGraph.getModuleById(id);
292
292
  const timestamp = module ? module.lastHMRTimestamp : null;
293
293
  const cache = this.fetchCache.get(filePath);
package/dist/server.mjs CHANGED
@@ -278,7 +278,7 @@ class ViteNodeServer {
278
278
  async _fetchModule(id) {
279
279
  var _a;
280
280
  let result;
281
- const filePath = toFilePath(id, this.server.config.root);
281
+ const { path: filePath } = toFilePath(id, this.server.config.root);
282
282
  const module = this.server.moduleGraph.getModuleById(id);
283
283
  const timestamp = module ? module.lastHMRTimestamp : null;
284
284
  const cache = this.fetchCache.get(filePath);
package/dist/utils.cjs CHANGED
@@ -34,19 +34,24 @@ function isPrimitive(v) {
34
34
  return v !== Object(v);
35
35
  }
36
36
  function toFilePath(id, root) {
37
- let absolute = (() => {
37
+ let { absolute, exists } = (() => {
38
38
  if (id.startsWith("/@fs/"))
39
- return id.slice(4);
39
+ return { absolute: id.slice(4), exists: true };
40
40
  if (!id.startsWith(root) && id.startsWith("/")) {
41
41
  const resolved = pathe.resolve(root, id.slice(1));
42
- if (fs.existsSync(resolved.replace(/\?.*$/, "")))
43
- return resolved;
42
+ if (fs.existsSync(cleanUrl(resolved)))
43
+ return { absolute: resolved, exists: true };
44
+ } else if (id.startsWith(root) && fs.existsSync(cleanUrl(id))) {
45
+ return { absolute: id, exists: true };
44
46
  }
45
- return id;
47
+ return { absolute: id, exists: false };
46
48
  })();
47
49
  if (absolute.startsWith("//"))
48
50
  absolute = absolute.slice(1);
49
- return isWindows && absolute.startsWith("/") ? slash(node_url.fileURLToPath(node_url.pathToFileURL(absolute.slice(1)).href)) : absolute;
51
+ return {
52
+ path: isWindows && absolute.startsWith("/") ? slash(node_url.fileURLToPath(node_url.pathToFileURL(absolute.slice(1)).href)) : absolute,
53
+ exists
54
+ };
50
55
  }
51
56
  function toArray(array) {
52
57
  if (array === null || array === void 0)
package/dist/utils.d.ts CHANGED
@@ -10,7 +10,10 @@ declare const cleanUrl: (url: string) => string;
10
10
  declare const isInternalRequest: (id: string) => boolean;
11
11
  declare function normalizeModuleId(id: string): string;
12
12
  declare function isPrimitive(v: any): boolean;
13
- declare function toFilePath(id: string, root: string): string;
13
+ declare function toFilePath(id: string, root: string): {
14
+ path: string;
15
+ exists: boolean;
16
+ };
14
17
  /**
15
18
  * Convert `Arrayable<T>` to `Array<T>`
16
19
  *
package/dist/utils.mjs CHANGED
@@ -30,19 +30,24 @@ function isPrimitive(v) {
30
30
  return v !== Object(v);
31
31
  }
32
32
  function toFilePath(id, root) {
33
- let absolute = (() => {
33
+ let { absolute, exists } = (() => {
34
34
  if (id.startsWith("/@fs/"))
35
- return id.slice(4);
35
+ return { absolute: id.slice(4), exists: true };
36
36
  if (!id.startsWith(root) && id.startsWith("/")) {
37
37
  const resolved = resolve(root, id.slice(1));
38
- if (existsSync(resolved.replace(/\?.*$/, "")))
39
- return resolved;
38
+ if (existsSync(cleanUrl(resolved)))
39
+ return { absolute: resolved, exists: true };
40
+ } else if (id.startsWith(root) && existsSync(cleanUrl(id))) {
41
+ return { absolute: id, exists: true };
40
42
  }
41
- return id;
43
+ return { absolute: id, exists: false };
42
44
  })();
43
45
  if (absolute.startsWith("//"))
44
46
  absolute = absolute.slice(1);
45
- return isWindows && absolute.startsWith("/") ? slash(fileURLToPath(pathToFileURL(absolute.slice(1)).href)) : absolute;
47
+ return {
48
+ path: isWindows && absolute.startsWith("/") ? slash(fileURLToPath(pathToFileURL(absolute.slice(1)).href)) : absolute,
49
+ exists
50
+ };
46
51
  }
47
52
  function toArray(array) {
48
53
  if (array === null || array === void 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-node",
3
- "version": "0.27.0",
3
+ "version": "0.27.2",
4
4
  "description": "Vite as Node.js runtime",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -72,7 +72,7 @@
72
72
  "dependencies": {
73
73
  "cac": "^6.7.14",
74
74
  "debug": "^4.3.4",
75
- "mlly": "^1.0.0",
75
+ "mlly": "^1.1.0",
76
76
  "pathe": "^0.2.0",
77
77
  "picocolors": "^1.0.0",
78
78
  "source-map": "^0.6.1",