vite-node 0.26.0 → 0.26.1

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var events = require('events');
3
+ var node_events = require('node:events');
4
4
  var picocolors = require('./chunk-picocolors.cjs');
5
5
  var createDebug = require('debug');
6
6
 
@@ -9,7 +9,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
9
9
  var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
10
10
 
11
11
  function createHmrEmitter() {
12
- const emitter = new events.EventEmitter();
12
+ const emitter = new node_events.EventEmitter();
13
13
  return emitter;
14
14
  }
15
15
  function viteNodeHmrPlugin() {
@@ -1,4 +1,4 @@
1
- import { EventEmitter } from 'events';
1
+ import { EventEmitter } from 'node:events';
2
2
  import { p as picocolors } from './chunk-picocolors.mjs';
3
3
  import createDebug from 'debug';
4
4
 
package/dist/cli.cjs CHANGED
@@ -14,11 +14,12 @@ require('pathe');
14
14
  require('debug');
15
15
  require('fs');
16
16
  require('mlly');
17
- require('url');
17
+ require('node:url');
18
18
  require('source-map-support');
19
19
  require('module');
20
20
  require('path');
21
21
  require('vm');
22
+ require('node:events');
22
23
 
23
24
  function toArr(any) {
24
25
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -633,7 +634,7 @@ class CAC extends events.EventEmitter {
633
634
 
634
635
  const cac = (name = "") => new CAC(name);
635
636
 
636
- var version = "0.26.0";
637
+ var version = "0.26.1";
637
638
 
638
639
  const cli = cac("vite-node");
639
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-aaf02e1c.js';
1
+ import { e as ViteNodeServerOptions } from './types-57a192bf.js';
2
2
 
3
3
  interface CliOptions {
4
4
  root?: string;
package/dist/cli.mjs CHANGED
@@ -7,16 +7,17 @@ import { toArray } from './utils.mjs';
7
7
  import { v as viteNodeHmrPlugin, c as createHotContext, h as handleMessage } from './chunk-hmr.mjs';
8
8
  import { installSourcemapsSupport } from './source-map.mjs';
9
9
  import 'tty';
10
- import 'perf_hooks';
10
+ import 'node:perf_hooks';
11
11
  import 'pathe';
12
12
  import 'debug';
13
- import 'fs';
13
+ import 'node:fs';
14
14
  import 'mlly';
15
- import 'url';
15
+ import 'node:url';
16
16
  import 'source-map-support';
17
- import 'module';
18
- import 'path';
19
- import 'vm';
17
+ import 'node:module';
18
+ import 'node:path';
19
+ import 'node:vm';
20
+ import 'node:events';
20
21
 
21
22
  function toArr(any) {
22
23
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -631,7 +632,7 @@ class CAC extends EventEmitter {
631
632
 
632
633
  const cac = (name = "") => new CAC(name);
633
634
 
634
- var version = "0.26.0";
635
+ var version = "0.26.1";
635
636
 
636
637
  const cli = cac("vite-node");
637
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
@@ -4,8 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var module$1 = require('module');
6
6
  var path = require('path');
7
- var url = require('url');
7
+ var node_url = require('node:url');
8
8
  var vm = require('vm');
9
+ var mlly = require('mlly');
9
10
  var pathe = require('pathe');
10
11
  var createDebug = require('debug');
11
12
  var utils = require('./utils.cjs');
@@ -175,8 +176,11 @@ class ViteNodeRunner {
175
176
  mod.evaluated = true;
176
177
  }
177
178
  }
179
+ shouldResolveId(id, _importee) {
180
+ return !utils.isInternalRequest(id) && !mlly.isNodeBuiltin(id);
181
+ }
178
182
  async resolveUrl(id, importee) {
179
- if (utils.isInternalRequest(id))
183
+ if (!this.shouldResolveId(id))
180
184
  return [id, id];
181
185
  if (importee && id.startsWith(utils.VALID_ID_PREFIX))
182
186
  importee = void 0;
@@ -232,7 +236,7 @@ ${getStack()}`), 2e3);
232
236
  if (transformed == null)
233
237
  throw new Error(`[vite-node] Failed to load "${id}" imported from ${callstack[callstack.length - 2]}`);
234
238
  const modulePath = utils.cleanUrl(moduleId);
235
- const href = url.pathToFileURL(modulePath).href;
239
+ const href = node_url.pathToFileURL(modulePath).href;
236
240
  const meta = { url: href };
237
241
  const exports = /* @__PURE__ */ Object.create(null);
238
242
  Object.defineProperty(exports, Symbol.toStringTag, {
@@ -260,7 +264,7 @@ ${getStack()}`), 2e3);
260
264
  }
261
265
  });
262
266
  Object.assign(mod, { code: transformed, exports });
263
- const __filename = url.fileURLToPath(href);
267
+ const __filename = node_url.fileURLToPath(href);
264
268
  const moduleProxy = {
265
269
  set exports(value) {
266
270
  exportAll(cjsExports, value);
package/dist/client.d.ts CHANGED
@@ -1 +1 @@
1
- export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-aaf02e1c.js';
1
+ export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-57a192bf.js';
package/dist/client.mjs CHANGED
@@ -1,12 +1,13 @@
1
- import { createRequire } from 'module';
2
- import { dirname } from 'path';
3
- import { pathToFileURL, fileURLToPath } from 'url';
4
- import vm from 'vm';
1
+ import { createRequire } from 'node:module';
2
+ import { dirname } from 'node:path';
3
+ import { pathToFileURL, fileURLToPath } from 'node:url';
4
+ import vm from 'node:vm';
5
+ import { isNodeBuiltin } from 'mlly';
5
6
  import { resolve } from 'pathe';
6
7
  import createDebug from 'debug';
7
8
  import { normalizeModuleId, slash, isInternalRequest, VALID_ID_PREFIX, normalizeRequestId, toFilePath, cleanUrl, isPrimitive } from './utils.mjs';
8
9
  import { extractSourceMap } from './source-map.mjs';
9
- import 'fs';
10
+ import 'node:fs';
10
11
  import 'source-map-support';
11
12
 
12
13
  const debugExecute = createDebug("vite-node:client:execute");
@@ -148,8 +149,11 @@ class ViteNodeRunner {
148
149
  mod.evaluated = true;
149
150
  }
150
151
  }
152
+ shouldResolveId(id, _importee) {
153
+ return !isInternalRequest(id) && !isNodeBuiltin(id);
154
+ }
151
155
  async resolveUrl(id, importee) {
152
- if (isInternalRequest(id))
156
+ if (!this.shouldResolveId(id))
153
157
  return [id, id];
154
158
  if (importee && id.startsWith(VALID_ID_PREFIX))
155
159
  importee = void 0;
package/dist/hmr.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var hmr = require('./chunk-hmr.cjs');
6
- require('events');
6
+ require('node:events');
7
7
  require('./chunk-picocolors.cjs');
8
8
  require('tty');
9
9
  require('debug');
package/dist/hmr.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { EventEmitter } from 'events';
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-aaf02e1c.js';
3
+ import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-57a192bf.js';
4
4
 
5
5
  type EventType = string | symbol;
6
6
  type Handler<T = unknown> = (event: T) => void;
package/dist/hmr.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  export { a as createHmrEmitter, c as createHotContext, g as getCache, h as handleMessage, r as reload, s as sendMessageBuffer, v as viteNodeHmrPlugin } from './chunk-hmr.mjs';
2
- import 'events';
2
+ import 'node:events';
3
3
  import './chunk-picocolors.mjs';
4
4
  import 'tty';
5
5
  import 'debug';
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-aaf02e1c.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-57a192bf.js';
package/dist/server.cjs CHANGED
@@ -10,7 +10,7 @@ var mlly = require('mlly');
10
10
  var utils = require('./utils.cjs');
11
11
  var picocolors = require('./chunk-picocolors.cjs');
12
12
  var sourceMap = require('./source-map.cjs');
13
- require('url');
13
+ require('node:url');
14
14
  require('tty');
15
15
  require('source-map-support');
16
16
 
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-aaf02e1c.js';
2
+ import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId, R as RawSourceMap } from './types-57a192bf.js';
3
3
 
4
4
  declare class Debugger {
5
5
  options: DebuggerOptions;
package/dist/server.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { performance } from 'perf_hooks';
1
+ import { performance } from 'node:perf_hooks';
2
2
  import { resolve, join } from 'pathe';
3
3
  import createDebug from 'debug';
4
- import { existsSync, promises } from 'fs';
4
+ import { existsSync, promises } from 'node:fs';
5
5
  import { isNodeBuiltin, isValidNodeImport } from 'mlly';
6
6
  import { slash, toArray, normalizeModuleId, toFilePath } from './utils.mjs';
7
7
  import { p as picocolors } from './chunk-picocolors.mjs';
8
8
  import { withInlineSourcemap } from './source-map.mjs';
9
- import 'url';
9
+ import 'node:url';
10
10
  import 'tty';
11
11
  import 'source-map-support';
12
12
 
@@ -1,5 +1,5 @@
1
1
  import { TransformResult } from 'vite';
2
- import { R as RawSourceMap } from './types-aaf02e1c.js';
2
+ import { R as RawSourceMap } from './types-57a192bf.js';
3
3
 
4
4
  interface InstallSourceMapSupportOptions {
5
5
  getSourceMap: (source: string) => RawSourceMap | null | undefined;
@@ -159,6 +159,7 @@ declare class ViteNodeRunner {
159
159
  getSourceMap(id: string): RawSourceMap | null;
160
160
  /** @internal */
161
161
  cachedRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
162
+ shouldResolveId(id: string, _importee?: string): boolean;
162
163
  resolveUrl(id: string, importee?: string): Promise<[url: string, fsPath: string]>;
163
164
  /** @internal */
164
165
  dependencyRequest(id: string, fsPath: string, callstack: string[]): Promise<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-aaf02e1c.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-57a192bf.js';
package/dist/utils.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var url = require('url');
5
+ var node_url = require('node:url');
6
6
  var fs = require('fs');
7
7
  var pathe = require('pathe');
8
8
 
@@ -17,7 +17,7 @@ const VALID_ID_PREFIX = "/@id/";
17
17
  function normalizeRequestId(id, base) {
18
18
  if (base && id.startsWith(base))
19
19
  id = `/${id.slice(base.length)}`;
20
- return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
20
+ return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^file:/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
21
21
  }
22
22
  const queryRE = /\?.*$/s;
23
23
  const hashRE = /#.*$/s;
@@ -26,7 +26,7 @@ const isInternalRequest = (id) => {
26
26
  return id.startsWith("/@vite/");
27
27
  };
28
28
  function normalizeModuleId(id) {
29
- return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
29
+ return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^file:\//, "/").replace(/^node:/, "").replace(/^\/+/, "/");
30
30
  }
31
31
  function isPrimitive(v) {
32
32
  return v !== Object(v);
@@ -44,7 +44,7 @@ function toFilePath(id, root) {
44
44
  })();
45
45
  if (absolute.startsWith("//"))
46
46
  absolute = absolute.slice(1);
47
- return isWindows && absolute.startsWith("/") ? slash(url.fileURLToPath(url.pathToFileURL(absolute.slice(1)).href)) : absolute;
47
+ return isWindows && absolute.startsWith("/") ? slash(node_url.fileURLToPath(node_url.pathToFileURL(absolute.slice(1)).href)) : absolute;
48
48
  }
49
49
  function toArray(array) {
50
50
  if (array === null || array === void 0)
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as Nullable, A as Arrayable } from './types-aaf02e1c.js';
1
+ import { N as Nullable, A as Arrayable } from './types-57a192bf.js';
2
2
 
3
3
  declare const isWindows: boolean;
4
4
  declare function slash(str: string): string;
package/dist/utils.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { fileURLToPath, pathToFileURL } from 'url';
2
- import { existsSync } from 'fs';
1
+ import { fileURLToPath, pathToFileURL } from 'node:url';
2
+ import { existsSync } from 'node:fs';
3
3
  import { resolve } from 'pathe';
4
4
 
5
5
  const isWindows = process.platform === "win32";
@@ -13,7 +13,7 @@ const VALID_ID_PREFIX = "/@id/";
13
13
  function normalizeRequestId(id, base) {
14
14
  if (base && id.startsWith(base))
15
15
  id = `/${id.slice(base.length)}`;
16
- return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
16
+ return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^file:/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
17
17
  }
18
18
  const queryRE = /\?.*$/s;
19
19
  const hashRE = /#.*$/s;
@@ -22,7 +22,7 @@ const isInternalRequest = (id) => {
22
22
  return id.startsWith("/@vite/");
23
23
  };
24
24
  function normalizeModuleId(id) {
25
- return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
25
+ return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^file:\//, "/").replace(/^node:/, "").replace(/^\/+/, "/");
26
26
  }
27
27
  function isPrimitive(v) {
28
28
  return v !== Object(v);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-node",
3
- "version": "0.26.0",
3
+ "version": "0.26.1",
4
4
  "description": "Vite as Node.js runtime",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",