vite-node 1.0.0-beta.2 → 1.0.0-beta.4

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
@@ -8,20 +8,20 @@ var client = require('./client.cjs');
8
8
  var utils = require('./utils.cjs');
9
9
  var sourceMap = require('./source-map.cjs');
10
10
  var hmr = require('./hmr.cjs');
11
- require('perf_hooks');
12
- require('fs');
13
- require('assert');
11
+ require('node:perf_hooks');
12
+ require('node:fs');
13
+ require('node:assert');
14
14
  require('pathe');
15
15
  require('debug');
16
16
  require('mlly');
17
17
  require('./constants.cjs');
18
- require('module');
19
- require('path');
18
+ require('node:module');
19
+ require('node:path');
20
20
  require('node:url');
21
21
  require('node:vm');
22
22
  require('node:events');
23
23
 
24
- var version = "1.0.0-beta.2";
24
+ var version = "1.0.0-beta.4";
25
25
 
26
26
  const cli = cac("vite-node");
27
27
  cli.option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command");
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { V as ViteNodeServerOptions } from './index-e4206afe.js';
1
+ import { V as ViteNodeServerOptions } from './index-ba8284b7.js';
2
2
  import './trace-mapping.d-cf594fd7.js';
3
3
 
4
4
  interface CliOptions {
package/dist/cli.mjs CHANGED
@@ -19,7 +19,7 @@ import 'node:url';
19
19
  import 'node:vm';
20
20
  import 'node:events';
21
21
 
22
- var version = "1.0.0-beta.2";
22
+ var version = "1.0.0-beta.4";
23
23
 
24
24
  const cli = cac("vite-node");
25
25
  cli.option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-m, --mode <mode>", "Set env mode").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--script", "Use vite-node as a script runner").option("--options <options>", "Use specified Vite server options").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command");
package/dist/client.cjs CHANGED
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var module$1 = require('module');
4
- var path = require('path');
3
+ var node_module = require('node:module');
4
+ var path = require('node:path');
5
5
  var node_url = require('node:url');
6
6
  var vm = require('node:vm');
7
7
  var pathe = require('pathe');
8
8
  var createDebug = require('debug');
9
9
  var utils = require('./utils.cjs');
10
10
  var sourceMap = require('./source-map.cjs');
11
- require('fs');
11
+ require('node:fs');
12
12
 
13
13
  const { setTimeout, clearTimeout } = globalThis;
14
14
  const debugExecute = createDebug("vite-node:client:execute");
@@ -316,7 +316,7 @@ ${getStack()}`), 2e3);
316
316
  __vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
317
317
  __vite_ssr_import_meta__: meta,
318
318
  // cjs compact
319
- require: module$1.createRequire(href),
319
+ require: node_module.createRequire(href),
320
320
  exports: cjsExports,
321
321
  module: moduleProxy,
322
322
  __filename,
package/dist/client.d.ts CHANGED
@@ -1,2 +1,2 @@
1
+ export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-ba8284b7.js';
1
2
  import './trace-mapping.d-cf594fd7.js';
2
- export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-e4206afe.js';
package/dist/hmr.cjs CHANGED
@@ -5,8 +5,8 @@ var c = require('picocolors');
5
5
  var createDebug = require('debug');
6
6
  var utils = require('./utils.cjs');
7
7
  require('node:url');
8
- require('module');
9
- require('fs');
8
+ require('node:module');
9
+ require('node:fs');
10
10
  require('pathe');
11
11
 
12
12
  function createHmrEmitter() {
@@ -232,6 +232,23 @@ function createHotContext(runner, emitter, files, ownerPath) {
232
232
  addToMap(maps.customListenersMap);
233
233
  addToMap(newListeners);
234
234
  },
235
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
236
+ // @ts-ignore added in vite 5
237
+ off(event, cb) {
238
+ const removeFromMap = (map) => {
239
+ const existing = map.get(event);
240
+ if (existing === void 0)
241
+ return;
242
+ const pruned = existing.filter((l) => l !== cb);
243
+ if (pruned.length === 0) {
244
+ map.delete(event);
245
+ return;
246
+ }
247
+ map.set(event, pruned);
248
+ };
249
+ removeFromMap(maps.customListenersMap);
250
+ removeFromMap(newListeners);
251
+ },
235
252
  send(event, data) {
236
253
  maps.messageBuffer.push(JSON.stringify({ type: "custom", event, data }));
237
254
  sendMessageBuffer(runner, emitter);
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 { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index-e4206afe.js';
3
+ import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index-ba8284b7.js';
4
4
  import './trace-mapping.d-cf594fd7.js';
5
5
 
6
6
  type EventType = string | symbol;
package/dist/hmr.mjs CHANGED
@@ -230,6 +230,23 @@ function createHotContext(runner, emitter, files, ownerPath) {
230
230
  addToMap(maps.customListenersMap);
231
231
  addToMap(newListeners);
232
232
  },
233
+ // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
234
+ // @ts-ignore added in vite 5
235
+ off(event, cb) {
236
+ const removeFromMap = (map) => {
237
+ const existing = map.get(event);
238
+ if (existing === void 0)
239
+ return;
240
+ const pruned = existing.filter((l) => l !== cb);
241
+ if (pruned.length === 0) {
242
+ map.delete(event);
243
+ return;
244
+ }
245
+ map.set(event, pruned);
246
+ };
247
+ removeFromMap(maps.customListenersMap);
248
+ removeFromMap(newListeners);
249
+ },
233
250
  send(event, data) {
234
251
  maps.messageBuffer.push(JSON.stringify({ type: "custom", event, data }));
235
252
  sendMessageBuffer(runner, emitter);
@@ -217,10 +217,10 @@ interface StartOfSourceMap {
217
217
  }
218
218
 
219
219
  interface RawSourceMap extends StartOfSourceMap {
220
- version: string;
220
+ version: number;
221
221
  sources: string[];
222
222
  names: string[];
223
- sourcesContent?: string[];
223
+ sourcesContent?: (string | null)[];
224
224
  mappings: string;
225
225
  }
226
226
  interface FetchResult {
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-e4206afe.js';
1
+ export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-ba8284b7.js';
2
2
  export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-cf594fd7.js';
package/dist/server.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var perf_hooks = require('perf_hooks');
4
- var fs = require('fs');
5
- var assert = require('assert');
3
+ var node_perf_hooks = require('node:perf_hooks');
4
+ var fs = require('node:fs');
5
+ var assert = require('node:assert');
6
6
  var pathe = require('pathe');
7
7
  var createDebug = require('debug');
8
8
  var mlly = require('mlly');
@@ -11,8 +11,8 @@ var constants = require('./constants.cjs');
11
11
  var c = require('picocolors');
12
12
  var sourceMap = require('./source-map.cjs');
13
13
  require('node:url');
14
- require('module');
15
- require('path');
14
+ require('node:module');
15
+ require('node:path');
16
16
 
17
17
  const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/;
18
18
  const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/;
@@ -347,9 +347,9 @@ class ViteNodeServer {
347
347
  result = { externalize };
348
348
  (_b = this.debugger) == null ? void 0 : _b.recordExternalize(id, externalize);
349
349
  } else {
350
- const start = perf_hooks.performance.now();
350
+ const start = node_perf_hooks.performance.now();
351
351
  const r = await this._transformRequest(id, filePath, transformMode);
352
- duration = perf_hooks.performance.now() - start;
352
+ duration = node_perf_hooks.performance.now() - start;
353
353
  result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
354
354
  }
355
355
  const cacheEntry = {
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TransformResult, ViteDevServer } from 'vite';
2
- import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, d as ViteNodeResolveId, F as FetchResult } from './index-e4206afe.js';
2
+ import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, d as ViteNodeResolveId, F as FetchResult } from './index-ba8284b7.js';
3
3
  import { E as EncodedSourceMap } from './trace-mapping.d-cf594fd7.js';
4
4
 
5
5
  declare class Debugger {
@@ -2,10 +2,10 @@
2
2
 
3
3
  var pathe = require('pathe');
4
4
  var utils = require('./utils.cjs');
5
- var path = require('path');
6
- var fs = require('fs');
5
+ var path = require('node:path');
6
+ var fs = require('node:fs');
7
7
  require('node:url');
8
- require('module');
8
+ require('node:module');
9
9
 
10
10
  const comma = ','.charCodeAt(0);
11
11
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-e4206afe.js';
1
+ export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-ba8284b7.js';
2
2
  export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-cf594fd7.js';
package/dist/utils.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var node_url = require('node:url');
4
- var module$1 = require('module');
5
- var fs = require('fs');
4
+ var node_module = require('node:module');
5
+ var fs = require('node:fs');
6
6
  var pathe = require('pathe');
7
7
 
8
8
  const isWindows = process.platform === "win32";
@@ -38,7 +38,7 @@ const prefixedBuiltins = /* @__PURE__ */ new Set([
38
38
  "node:test"
39
39
  ]);
40
40
  const builtins = /* @__PURE__ */ new Set([
41
- ...module$1.builtinModules,
41
+ ...node_module.builtinModules,
42
42
  "assert/strict",
43
43
  "diagnostics_channel",
44
44
  "dns/promises",
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as Nullable, A as Arrayable } from './index-e4206afe.js';
1
+ import { N as Nullable, A as Arrayable } from './index-ba8284b7.js';
2
2
  import './trace-mapping.d-cf594fd7.js';
3
3
 
4
4
  declare const isWindows: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-node",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.2",
4
+ "version": "1.0.0-beta.4",
5
5
  "description": "Vite as Node.js runtime",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -74,7 +74,7 @@
74
74
  "*.mjs"
75
75
  ],
76
76
  "engines": {
77
- "node": ">=v14.18.0"
77
+ "node": "^18.0.0 || >=20.0.0"
78
78
  },
79
79
  "dependencies": {
80
80
  "cac": "^6.7.14",