vite-node 0.27.1 → 0.27.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
@@ -6,8 +6,8 @@ var vite = require('vite');
6
6
  var server = require('./server.cjs');
7
7
  var client = require('./client.cjs');
8
8
  var utils = require('./utils.cjs');
9
- var hmr = require('./chunk-hmr.cjs');
10
9
  var sourceMap = require('./source-map.cjs');
10
+ var hmr = require('./chunk-hmr.cjs');
11
11
  require('perf_hooks');
12
12
  require('pathe');
13
13
  require('debug');
@@ -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.1";
28
+ var version = "0.27.3";
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.1";
21
+ var version = "0.27.3";
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
@@ -188,16 +188,19 @@ class ViteNodeRunner {
188
188
  return !utils.isInternalRequest(id) && !mlly.isNodeBuiltin(id);
189
189
  }
190
190
  async _resolveUrl(id, importee) {
191
- if (!this.shouldResolveId(id))
192
- return [id, id];
193
191
  if (importee && id.startsWith(utils.VALID_ID_PREFIX))
194
192
  importee = void 0;
195
193
  id = utils.normalizeRequestId(id, this.options.base);
196
- if (!this.options.resolveId)
197
- return [id, utils.toFilePath(id, this.root)];
194
+ if (!id.startsWith("/") && !id.startsWith("./") && !id.startsWith("../"))
195
+ importee = void 0;
196
+ if (!this.shouldResolveId(id))
197
+ return [id, id];
198
+ const { path, exists } = utils.toFilePath(id, this.root);
199
+ if (!this.options.resolveId || exists)
200
+ return [id, path];
198
201
  const resolved = await this.options.resolveId(id, importee);
199
202
  const resolvedId = resolved ? utils.normalizeRequestId(resolved.id, this.options.base) : id;
200
- const fsPath = resolved ? resolvedId : utils.toFilePath(id, this.root);
203
+ const fsPath = resolved ? resolvedId : path;
201
204
  return [resolvedId, fsPath];
202
205
  }
203
206
  async resolveUrl(id, importee) {
package/dist/client.mjs CHANGED
@@ -161,16 +161,19 @@ class ViteNodeRunner {
161
161
  return !isInternalRequest(id) && !isNodeBuiltin(id);
162
162
  }
163
163
  async _resolveUrl(id, importee) {
164
- if (!this.shouldResolveId(id))
165
- return [id, id];
166
164
  if (importee && id.startsWith(VALID_ID_PREFIX))
167
165
  importee = void 0;
168
166
  id = normalizeRequestId(id, this.options.base);
169
- if (!this.options.resolveId)
170
- return [id, toFilePath(id, this.root)];
167
+ if (!id.startsWith("/") && !id.startsWith("./") && !id.startsWith("../"))
168
+ importee = void 0;
169
+ if (!this.shouldResolveId(id))
170
+ return [id, id];
171
+ const { path, exists } = toFilePath(id, this.root);
172
+ if (!this.options.resolveId || exists)
173
+ return [id, path];
171
174
  const resolved = await this.options.resolveId(id, importee);
172
175
  const resolvedId = resolved ? normalizeRequestId(resolved.id, this.options.base) : id;
173
- const fsPath = resolved ? resolvedId : toFilePath(id, this.root);
176
+ const fsPath = resolved ? resolvedId : path;
174
177
  return [resolvedId, fsPath];
175
178
  }
176
179
  async resolveUrl(id, importee) {
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.1",
3
+ "version": "0.27.3",
4
4
  "description": "Vite as Node.js runtime",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",