vite-node 3.0.5 → 3.0.7

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.
@@ -50,8 +50,8 @@ function a(n) {
50
50
  a.open = "";
51
51
  a.close = "";
52
52
  function C(n = false) {
53
- let e = typeof process != "undefined" ? process : undefined, i = (e == null ? undefined : e.env) || {}, g = (e == null ? undefined : e.argv) || [];
54
- return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || (e == null ? undefined : e.platform) === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window != "undefined" && !!window.chrome;
53
+ let e = typeof process != "undefined" ? process : void 0, i = (e == null ? void 0 : e.env) || {}, g = (e == null ? void 0 : e.argv) || [];
54
+ return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window != "undefined" && !!window.chrome;
55
55
  }
56
56
  function p(n = false) {
57
57
  let e = C(n), i = (r, t, c, o) => {
@@ -48,8 +48,8 @@ function a(n) {
48
48
  a.open = "";
49
49
  a.close = "";
50
50
  function C(n = false) {
51
- let e = typeof process != "undefined" ? process : undefined, i = (e == null ? undefined : e.env) || {}, g = (e == null ? undefined : e.argv) || [];
52
- return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || (e == null ? undefined : e.platform) === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window != "undefined" && !!window.chrome;
51
+ let e = typeof process != "undefined" ? process : void 0, i = (e == null ? void 0 : e.env) || {}, g = (e == null ? void 0 : e.argv) || [];
52
+ return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window != "undefined" && !!window.chrome;
53
53
  }
54
54
  function p(n = false) {
55
55
  let e = C(n), i = (r, t, c, o) => {
@@ -111,7 +111,7 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
111
111
  }
112
112
  return () => {
113
113
  for (const { deps, fn } of qualifiedCallbacks) {
114
- fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : undefined));
114
+ fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
115
115
  }
116
116
  const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
117
117
  console.log(`${browser.s.cyan("[vite-node]")} hot updated: ${loggedPath}`);
@@ -224,7 +224,7 @@ function createHotContext(runner, emitter, files, ownerPath) {
224
224
  invalidate() {
225
225
  notifyListeners(runner, "vite:invalidate", {
226
226
  path: ownerPath,
227
- message: undefined
227
+ message: void 0
228
228
  });
229
229
  return reload(runner, files);
230
230
  },
@@ -240,7 +240,7 @@ function createHotContext(runner, emitter, files, ownerPath) {
240
240
  off(event, cb) {
241
241
  const removeFromMap = (map) => {
242
242
  const existing = map.get(event);
243
- if (existing === undefined) {
243
+ if (existing === void 0) {
244
244
  return;
245
245
  }
246
246
  const pruned = existing.filter((l) => l !== cb);
@@ -109,7 +109,7 @@ async function fetchUpdate(runner, { path, acceptedPath }) {
109
109
  }
110
110
  return () => {
111
111
  for (const { deps, fn } of qualifiedCallbacks) {
112
- fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : undefined));
112
+ fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
113
113
  }
114
114
  const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
115
115
  console.log(`${s.cyan("[vite-node]")} hot updated: ${loggedPath}`);
@@ -222,7 +222,7 @@ function createHotContext(runner, emitter, files, ownerPath) {
222
222
  invalidate() {
223
223
  notifyListeners(runner, "vite:invalidate", {
224
224
  path: ownerPath,
225
- message: undefined
225
+ message: void 0
226
226
  });
227
227
  return reload(runner, files);
228
228
  },
@@ -238,7 +238,7 @@ function createHotContext(runner, emitter, files, ownerPath) {
238
238
  off(event, cb) {
239
239
  const removeFromMap = (map) => {
240
240
  const existing = map.get(event);
241
- if (existing === undefined) {
241
+ if (existing === void 0) {
242
242
  return;
243
243
  }
244
244
  const pruned = existing.filter((l) => l !== cb);
package/dist/cli.cjs CHANGED
@@ -5,23 +5,23 @@ var cac = require('cac');
5
5
  var browser = require('./chunk-browser.cjs');
6
6
  var vite = require('vite');
7
7
  var client = require('./client.cjs');
8
+ var hmr = require('./chunk-hmr.cjs');
8
9
  var server = require('./server.cjs');
9
10
  var sourceMap = require('./source-map.cjs');
10
11
  var utils = require('./utils.cjs');
11
- var hmr = require('./chunk-hmr.cjs');
12
12
  require('node:module');
13
13
  require('node:url');
14
14
  require('node:vm');
15
15
  require('debug');
16
16
  require('pathe');
17
17
  require('node:fs');
18
+ require('node:events');
18
19
  require('node:assert');
19
20
  require('node:perf_hooks');
20
21
  require('es-module-lexer');
21
22
  require('./constants.cjs');
22
- require('node:events');
23
23
 
24
- var version = "3.0.5";
24
+ var version = "3.0.7";
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");
@@ -70,7 +70,7 @@ async function run(files, options = {}) {
70
70
  mode: options.mode,
71
71
  server: {
72
72
  hmr: !!options.watch,
73
- watch: options.watch ? undefined : null
73
+ watch: options.watch ? void 0 : null
74
74
  },
75
75
  plugins: [options.watch && hmr.viteNodeHmrPlugin()]
76
76
  });
@@ -103,7 +103,7 @@ async function run(files, options = {}) {
103
103
  if (!options.watch) {
104
104
  await server$1.close();
105
105
  }
106
- (_b = server$1.emitter) == null ? undefined : _b.on("message", (payload) => {
106
+ (_b = server$1.emitter) == null ? void 0 : _b.on("message", (payload) => {
107
107
  hmr.handleMessage(runner, server$1.emitter, files, payload);
108
108
  });
109
109
  if (options.watch) {
@@ -114,26 +114,26 @@ async function run(files, options = {}) {
114
114
  }
115
115
  function parseServerOptions(serverOptions) {
116
116
  var _a, _b, _c, _d, _e, _f, _g, _h;
117
- const inlineOptions = ((_a = serverOptions.deps) == null ? undefined : _a.inline) === true ? true : utils.toArray((_b = serverOptions.deps) == null ? undefined : _b.inline);
117
+ const inlineOptions = ((_a = serverOptions.deps) == null ? void 0 : _a.inline) === true ? true : utils.toArray((_b = serverOptions.deps) == null ? void 0 : _b.inline);
118
118
  return {
119
119
  ...serverOptions,
120
120
  deps: {
121
121
  ...serverOptions.deps,
122
- inlineFiles: utils.toArray((_c = serverOptions.deps) == null ? undefined : _c.inlineFiles),
122
+ inlineFiles: utils.toArray((_c = serverOptions.deps) == null ? void 0 : _c.inlineFiles),
123
123
  inline: inlineOptions !== true ? inlineOptions.map((dep) => {
124
124
  return dep.startsWith("/") && dep.endsWith("/") ? new RegExp(dep) : dep;
125
125
  }) : true,
126
- external: utils.toArray((_d = serverOptions.deps) == null ? undefined : _d.external).map((dep) => {
126
+ external: utils.toArray((_d = serverOptions.deps) == null ? void 0 : _d.external).map((dep) => {
127
127
  return dep.startsWith("/") && dep.endsWith("/") ? new RegExp(dep) : dep;
128
128
  }),
129
- moduleDirectories: ((_e = serverOptions.deps) == null ? undefined : _e.moduleDirectories) ? utils.toArray((_f = serverOptions.deps) == null ? undefined : _f.moduleDirectories) : undefined
129
+ moduleDirectories: ((_e = serverOptions.deps) == null ? void 0 : _e.moduleDirectories) ? utils.toArray((_f = serverOptions.deps) == null ? void 0 : _f.moduleDirectories) : void 0
130
130
  },
131
131
  transformMode: {
132
132
  ...serverOptions.transformMode,
133
- ssr: utils.toArray((_g = serverOptions.transformMode) == null ? undefined : _g.ssr).map(
133
+ ssr: utils.toArray((_g = serverOptions.transformMode) == null ? void 0 : _g.ssr).map(
134
134
  (dep) => new RegExp(dep)
135
135
  ),
136
- web: utils.toArray((_h = serverOptions.transformMode) == null ? undefined : _h.web).map(
136
+ web: utils.toArray((_h = serverOptions.transformMode) == null ? void 0 : _h.web).map(
137
137
  (dep) => new RegExp(dep)
138
138
  )
139
139
  }
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { V as ViteNodeServerOptions } from './index-BmdeEDlf.js';
1
+ import { V as ViteNodeServerOptions } from './index-LQxw79Gm.js';
2
2
  import './trace-mapping.d-DLVdEqOp.js';
3
3
 
4
4
  interface CliOptions {
package/dist/cli.mjs CHANGED
@@ -19,7 +19,7 @@ import 'es-module-lexer';
19
19
  import './constants.mjs';
20
20
  import 'node:events';
21
21
 
22
- var version = "3.0.5";
22
+ var version = "3.0.7";
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");
@@ -68,7 +68,7 @@ async function run(files, options = {}) {
68
68
  mode: options.mode,
69
69
  server: {
70
70
  hmr: !!options.watch,
71
- watch: options.watch ? undefined : null
71
+ watch: options.watch ? void 0 : null
72
72
  },
73
73
  plugins: [options.watch && viteNodeHmrPlugin()]
74
74
  });
@@ -101,7 +101,7 @@ async function run(files, options = {}) {
101
101
  if (!options.watch) {
102
102
  await server.close();
103
103
  }
104
- (_b = server.emitter) == null ? undefined : _b.on("message", (payload) => {
104
+ (_b = server.emitter) == null ? void 0 : _b.on("message", (payload) => {
105
105
  handleMessage(runner, server.emitter, files, payload);
106
106
  });
107
107
  if (options.watch) {
@@ -112,26 +112,26 @@ async function run(files, options = {}) {
112
112
  }
113
113
  function parseServerOptions(serverOptions) {
114
114
  var _a, _b, _c, _d, _e, _f, _g, _h;
115
- const inlineOptions = ((_a = serverOptions.deps) == null ? undefined : _a.inline) === true ? true : toArray((_b = serverOptions.deps) == null ? undefined : _b.inline);
115
+ const inlineOptions = ((_a = serverOptions.deps) == null ? void 0 : _a.inline) === true ? true : toArray((_b = serverOptions.deps) == null ? void 0 : _b.inline);
116
116
  return {
117
117
  ...serverOptions,
118
118
  deps: {
119
119
  ...serverOptions.deps,
120
- inlineFiles: toArray((_c = serverOptions.deps) == null ? undefined : _c.inlineFiles),
120
+ inlineFiles: toArray((_c = serverOptions.deps) == null ? void 0 : _c.inlineFiles),
121
121
  inline: inlineOptions !== true ? inlineOptions.map((dep) => {
122
122
  return dep.startsWith("/") && dep.endsWith("/") ? new RegExp(dep) : dep;
123
123
  }) : true,
124
- external: toArray((_d = serverOptions.deps) == null ? undefined : _d.external).map((dep) => {
124
+ external: toArray((_d = serverOptions.deps) == null ? void 0 : _d.external).map((dep) => {
125
125
  return dep.startsWith("/") && dep.endsWith("/") ? new RegExp(dep) : dep;
126
126
  }),
127
- moduleDirectories: ((_e = serverOptions.deps) == null ? undefined : _e.moduleDirectories) ? toArray((_f = serverOptions.deps) == null ? undefined : _f.moduleDirectories) : undefined
127
+ moduleDirectories: ((_e = serverOptions.deps) == null ? void 0 : _e.moduleDirectories) ? toArray((_f = serverOptions.deps) == null ? void 0 : _f.moduleDirectories) : void 0
128
128
  },
129
129
  transformMode: {
130
130
  ...serverOptions.transformMode,
131
- ssr: toArray((_g = serverOptions.transformMode) == null ? undefined : _g.ssr).map(
131
+ ssr: toArray((_g = serverOptions.transformMode) == null ? void 0 : _g.ssr).map(
132
132
  (dep) => new RegExp(dep)
133
133
  ),
134
- web: toArray((_h = serverOptions.transformMode) == null ? undefined : _h.web).map(
134
+ web: toArray((_h = serverOptions.transformMode) == null ? void 0 : _h.web).map(
135
135
  (dep) => new RegExp(dep)
136
136
  )
137
137
  }
package/dist/client.cjs CHANGED
@@ -93,8 +93,8 @@ class ModuleCacheMap extends Map {
93
93
  delete mod.resolving;
94
94
  delete mod.promise;
95
95
  delete mod.exports;
96
- (_a = mod.importers) == null ? undefined : _a.clear();
97
- (_b = mod.imports) == null ? undefined : _b.clear();
96
+ (_a = mod.importers) == null ? void 0 : _a.clear();
97
+ (_b = mod.imports) == null ? void 0 : _b.clear();
98
98
  return true;
99
99
  }
100
100
  /**
@@ -108,7 +108,7 @@ class ModuleCacheMap extends Map {
108
108
  }
109
109
  invalidated.add(id);
110
110
  const mod = super.get(id);
111
- if (mod == null ? undefined : mod.importers) {
111
+ if (mod == null ? void 0 : mod.importers) {
112
112
  this.invalidateDepTree(mod.importers, invalidated);
113
113
  }
114
114
  super.delete(id);
@@ -127,7 +127,7 @@ class ModuleCacheMap extends Map {
127
127
  invalidated.add(id);
128
128
  const subIds = Array.from(super.entries()).filter(([, mod]) => {
129
129
  var _a;
130
- return (_a = mod.importers) == null ? undefined : _a.has(id);
130
+ return (_a = mod.importers) == null ? void 0 : _a.has(id);
131
131
  }).map(([key]) => key);
132
132
  if (subIds.length) {
133
133
  this.invalidateSubDepTree(subIds, invalidated);
@@ -227,7 +227,7 @@ ${getStack()}`
227
227
  return [dep, path];
228
228
  }
229
229
  const resolved = await this.options.resolveId(dep, importer);
230
- if ((_b = (_a = resolved == null ? undefined : resolved.meta) == null ? undefined : _a["vite:alias"]) == null ? undefined : _b.noResolved) {
230
+ if ((_b = (_a = resolved == null ? void 0 : resolved.meta) == null ? void 0 : _a["vite:alias"]) == null ? void 0 : _b.noResolved) {
231
231
  const error = new Error(
232
232
  `Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
233
233
 
@@ -325,7 +325,7 @@ ${getStack()}`
325
325
  exports.default = {};
326
326
  }
327
327
  if (moduleExports !== SYMBOL_NOT_DEFINED && utils.isPrimitive(moduleExports)) {
328
- defineExport(exports, p, () => undefined);
328
+ defineExport(exports, p, () => void 0);
329
329
  return true;
330
330
  }
331
331
  if (!utils.isPrimitive(exports.default)) {
@@ -354,7 +354,7 @@ ${getStack()}`
354
354
  enumerable: true,
355
355
  get: () => {
356
356
  var _a, _b;
357
- hotContext || (hotContext = (_b = (_a = this.options).createHotContext) == null ? undefined : _b.call(_a, this, moduleId));
357
+ hotContext || (hotContext = (_b = (_a = this.options).createHotContext) == null ? void 0 : _b.call(_a, this, moduleId));
358
358
  return hotContext;
359
359
  },
360
360
  set: (value) => {
@@ -387,6 +387,7 @@ ${getStack()}`
387
387
  return { Object, Reflect, Symbol };
388
388
  }
389
389
  async runModule(context, transformed) {
390
+ var _a;
390
391
  const codeDefinition = `'use strict';async (${Object.keys(context).join(
391
392
  ","
392
393
  )})=>{{`;
@@ -397,6 +398,7 @@ ${getStack()}`
397
398
  lineOffset: 0,
398
399
  columnOffset: -codeDefinition.length
399
400
  };
401
+ (_a = this.options.moduleExecutionInfo) == null ? void 0 : _a.set(options.filename, { startOffset: codeDefinition.length });
400
402
  const fn = vm.runInThisContext(code, options);
401
403
  await fn(...Object.values(context));
402
404
  }
@@ -430,11 +432,11 @@ ${getStack()}`
430
432
  if (prop === "default") {
431
433
  return defaultExport;
432
434
  }
433
- return mod2[prop] ?? (defaultExport == null ? undefined : defaultExport[prop]);
435
+ return mod2[prop] ?? (defaultExport == null ? void 0 : defaultExport[prop]);
434
436
  },
435
437
  has(mod2, prop) {
436
438
  if (prop === "default") {
437
- return defaultExport !== undefined;
439
+ return defaultExport !== void 0;
438
440
  }
439
441
  return prop in mod2 || defaultExport && prop in defaultExport;
440
442
  },
@@ -443,7 +445,7 @@ ${getStack()}`
443
445
  if (descriptor) {
444
446
  return descriptor;
445
447
  }
446
- if (prop === "default" && defaultExport !== undefined) {
448
+ if (prop === "default" && defaultExport !== void 0) {
447
449
  return {
448
450
  value: defaultExport,
449
451
  enumerable: true,
package/dist/client.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import './trace-mapping.d-DLVdEqOp.js';
2
- export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-BmdeEDlf.js';
2
+ export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, f as ModuleExecutionInfo, a as ViteNodeRunner } from './index-LQxw79Gm.js';
package/dist/client.mjs CHANGED
@@ -4,7 +4,7 @@ import { pathToFileURL, fileURLToPath } from 'node:url';
4
4
  import vm from 'node:vm';
5
5
  import createDebug from 'debug';
6
6
  import { extractSourceMap } from './source-map.mjs';
7
- import { createImportMetaEnvProxy, normalizeModuleId, slash, isInternalRequest, isNodeBuiltin, normalizeRequestId, toFilePath, cleanUrl, isPrimitive } from './utils.mjs';
7
+ import { createImportMetaEnvProxy, slash, isInternalRequest, isNodeBuiltin, normalizeRequestId, toFilePath, normalizeModuleId, cleanUrl, isPrimitive } from './utils.mjs';
8
8
  import 'pathe';
9
9
  import 'node:fs';
10
10
 
@@ -91,8 +91,8 @@ class ModuleCacheMap extends Map {
91
91
  delete mod.resolving;
92
92
  delete mod.promise;
93
93
  delete mod.exports;
94
- (_a = mod.importers) == null ? undefined : _a.clear();
95
- (_b = mod.imports) == null ? undefined : _b.clear();
94
+ (_a = mod.importers) == null ? void 0 : _a.clear();
95
+ (_b = mod.imports) == null ? void 0 : _b.clear();
96
96
  return true;
97
97
  }
98
98
  /**
@@ -106,7 +106,7 @@ class ModuleCacheMap extends Map {
106
106
  }
107
107
  invalidated.add(id);
108
108
  const mod = super.get(id);
109
- if (mod == null ? undefined : mod.importers) {
109
+ if (mod == null ? void 0 : mod.importers) {
110
110
  this.invalidateDepTree(mod.importers, invalidated);
111
111
  }
112
112
  super.delete(id);
@@ -125,7 +125,7 @@ class ModuleCacheMap extends Map {
125
125
  invalidated.add(id);
126
126
  const subIds = Array.from(super.entries()).filter(([, mod]) => {
127
127
  var _a;
128
- return (_a = mod.importers) == null ? undefined : _a.has(id);
128
+ return (_a = mod.importers) == null ? void 0 : _a.has(id);
129
129
  }).map(([key]) => key);
130
130
  if (subIds.length) {
131
131
  this.invalidateSubDepTree(subIds, invalidated);
@@ -225,7 +225,7 @@ ${getStack()}`
225
225
  return [dep, path];
226
226
  }
227
227
  const resolved = await this.options.resolveId(dep, importer);
228
- if ((_b = (_a = resolved == null ? undefined : resolved.meta) == null ? undefined : _a["vite:alias"]) == null ? undefined : _b.noResolved) {
228
+ if ((_b = (_a = resolved == null ? void 0 : resolved.meta) == null ? void 0 : _a["vite:alias"]) == null ? void 0 : _b.noResolved) {
229
229
  const error = new Error(
230
230
  `Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
231
231
 
@@ -323,7 +323,7 @@ ${getStack()}`
323
323
  exports.default = {};
324
324
  }
325
325
  if (moduleExports !== SYMBOL_NOT_DEFINED && isPrimitive(moduleExports)) {
326
- defineExport(exports, p, () => undefined);
326
+ defineExport(exports, p, () => void 0);
327
327
  return true;
328
328
  }
329
329
  if (!isPrimitive(exports.default)) {
@@ -352,7 +352,7 @@ ${getStack()}`
352
352
  enumerable: true,
353
353
  get: () => {
354
354
  var _a, _b;
355
- hotContext || (hotContext = (_b = (_a = this.options).createHotContext) == null ? undefined : _b.call(_a, this, moduleId));
355
+ hotContext || (hotContext = (_b = (_a = this.options).createHotContext) == null ? void 0 : _b.call(_a, this, moduleId));
356
356
  return hotContext;
357
357
  },
358
358
  set: (value) => {
@@ -385,6 +385,7 @@ ${getStack()}`
385
385
  return { Object, Reflect, Symbol };
386
386
  }
387
387
  async runModule(context, transformed) {
388
+ var _a;
388
389
  const codeDefinition = `'use strict';async (${Object.keys(context).join(
389
390
  ","
390
391
  )})=>{{`;
@@ -395,6 +396,7 @@ ${getStack()}`
395
396
  lineOffset: 0,
396
397
  columnOffset: -codeDefinition.length
397
398
  };
399
+ (_a = this.options.moduleExecutionInfo) == null ? void 0 : _a.set(options.filename, { startOffset: codeDefinition.length });
398
400
  const fn = vm.runInThisContext(code, options);
399
401
  await fn(...Object.values(context));
400
402
  }
@@ -428,11 +430,11 @@ ${getStack()}`
428
430
  if (prop === "default") {
429
431
  return defaultExport;
430
432
  }
431
- return mod2[prop] ?? (defaultExport == null ? undefined : defaultExport[prop]);
433
+ return mod2[prop] ?? (defaultExport == null ? void 0 : defaultExport[prop]);
432
434
  },
433
435
  has(mod2, prop) {
434
436
  if (prop === "default") {
435
- return defaultExport !== undefined;
437
+ return defaultExport !== void 0;
436
438
  }
437
439
  return prop in mod2 || defaultExport && prop in defaultExport;
438
440
  },
@@ -441,7 +443,7 @@ ${getStack()}`
441
443
  if (descriptor) {
442
444
  return descriptor;
443
445
  }
444
- if (prop === "default" && defaultExport !== undefined) {
446
+ if (prop === "default" && defaultExport !== void 0) {
445
447
  return {
446
448
  value: defaultExport,
447
449
  enumerable: true,
package/dist/hmr.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { HMRPayload, Plugin } from 'vite';
2
2
  import { EventEmitter } from 'node:events';
3
- import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index-BmdeEDlf.js';
3
+ import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index-LQxw79Gm.js';
4
4
  import './trace-mapping.d-DLVdEqOp.js';
5
5
 
6
6
  type EventType = string | symbol;
@@ -1,7 +1,10 @@
1
1
  import { E as EncodedSourceMap } from './trace-mapping.d-DLVdEqOp.js';
2
2
 
3
- type HMRPayload =
3
+ /** @deprecated use HotPayload */
4
+ type HMRPayload = HotPayload
5
+ type HotPayload =
4
6
  | ConnectedPayload
7
+ | PingPayload
5
8
  | UpdatePayload
6
9
  | FullReloadPayload
7
10
  | CustomPayload
@@ -12,6 +15,10 @@ interface ConnectedPayload {
12
15
  type: 'connected'
13
16
  }
14
17
 
18
+ interface PingPayload {
19
+ type: 'ping'
20
+ }
21
+
15
22
  interface UpdatePayload {
16
23
  type: 'update'
17
24
  updates: Update[]
@@ -27,7 +34,7 @@ interface Update {
27
34
  /** @internal */
28
35
  isWithinCircularImport?: boolean
29
36
  /** @internal */
30
- ssrInvalidates?: string[]
37
+ invalidates?: string[]
31
38
  }
32
39
 
33
40
  interface PrunePayload {
@@ -144,7 +151,7 @@ declare class ModuleCacheMap extends Map<string, ModuleCache> {
144
151
  setByModuleId(modulePath: string, mod: ModuleCache): this;
145
152
  set(fsPath: string, mod: ModuleCache): this;
146
153
  getByModuleId(modulePath: string): ModuleCache & Required<Pick<ModuleCache, "imports" | "importers">>;
147
- get(fsPath: string): ModuleCache & Required<Pick<ModuleCache, "imports" | "importers">>;
154
+ get(fsPath: string): ModuleCache & Required<Pick<ModuleCache, 'importers' | 'imports'>>;
148
155
  deleteByModuleId(modulePath: string): boolean;
149
156
  delete(fsPath: string): boolean;
150
157
  invalidateModule(mod: ModuleCache): boolean;
@@ -161,6 +168,9 @@ declare class ModuleCacheMap extends Map<string, ModuleCache> {
161
168
  */
162
169
  getSourceMap(id: string): EncodedSourceMap | null;
163
170
  }
171
+ type ModuleExecutionInfo = Map<string, {
172
+ startOffset: number;
173
+ }>;
164
174
  declare class ViteNodeRunner {
165
175
  options: ViteNodeRunnerOptions;
166
176
  root: string;
@@ -259,6 +269,7 @@ interface ViteNodeRunnerOptions {
259
269
  createHotContext?: CreateHotContextFunction;
260
270
  base?: string;
261
271
  moduleCache?: ModuleCacheMap;
272
+ moduleExecutionInfo?: ModuleExecutionInfo;
262
273
  interopDefault?: boolean;
263
274
  requestStubs?: Record<string, any>;
264
275
  debug?: boolean;
@@ -307,4 +318,4 @@ interface DebuggerOptions {
307
318
  loadDumppedModules?: boolean;
308
319
  }
309
320
 
310
- export { type Arrayable as A, type CustomEventMap as C, type DebuggerOptions as D, type FetchResult as F, type HMRPayload as H, ModuleCacheMap as M, type Nullable as N, type RawSourceMap as R, type StartOfSourceMap as S, type ViteNodeServerOptions as V, ViteNodeRunner as a, type HotContext as b, type DepsHandlingOptions as c, type ViteNodeResolveId as d, DEFAULT_REQUEST_STUBS as e, type Awaitable as f, type FetchFunction as g, type ResolveIdFunction as h, type CreateHotContextFunction as i, type ModuleCache as j, type ViteNodeRunnerOptions as k, type ViteNodeResolveModule as l };
321
+ export { type Arrayable as A, type CustomEventMap as C, type DebuggerOptions as D, type FetchResult as F, type HMRPayload as H, ModuleCacheMap as M, type Nullable as N, type RawSourceMap as R, type StartOfSourceMap as S, type ViteNodeServerOptions as V, ViteNodeRunner as a, type HotContext as b, type DepsHandlingOptions as c, type ViteNodeResolveId as d, DEFAULT_REQUEST_STUBS as e, type ModuleExecutionInfo as f, type Awaitable as g, type FetchFunction as h, type ResolveIdFunction as i, type CreateHotContextFunction as j, type ModuleCache as k, type ViteNodeRunnerOptions as l, type ViteNodeResolveModule as m };
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, l as ViteNodeResolveModule, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-BmdeEDlf.js';
1
+ export { A as Arrayable, g as Awaitable, j as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, h as FetchFunction, F as FetchResult, b as HotContext, k as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, i as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, m as ViteNodeResolveModule, l as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-LQxw79Gm.js';
2
2
  export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-DLVdEqOp.js';
package/dist/server.cjs CHANGED
@@ -6,6 +6,7 @@ var node_perf_hooks = require('node:perf_hooks');
6
6
  var node_url = require('node:url');
7
7
  var createDebug = require('debug');
8
8
  var pathe = require('pathe');
9
+ var vite = require('vite');
9
10
  var browser = require('./chunk-browser.cjs');
10
11
  var esModuleLexer = require('es-module-lexer');
11
12
  var constants = require('./constants.cjs');
@@ -111,7 +112,7 @@ ${result.code}`,
111
112
  const code = await fs.promises.readFile(path, "utf-8");
112
113
  return {
113
114
  code: code.replace(/^\/\/.*\n/, ""),
114
- map: undefined
115
+ map: void 0
115
116
  };
116
117
  }
117
118
  async writeInfo() {
@@ -211,21 +212,21 @@ async function _shouldExternalize(id, options) {
211
212
  return id;
212
213
  }
213
214
  id = patchWindowsImportPath(id);
214
- const moduleDirectories = (options == null ? undefined : options.moduleDirectories) || ["/node_modules/"];
215
- if (matchExternalizePattern(id, moduleDirectories, options == null ? undefined : options.inline)) {
215
+ const moduleDirectories = (options == null ? void 0 : options.moduleDirectories) || ["/node_modules/"];
216
+ if (matchExternalizePattern(id, moduleDirectories, options == null ? void 0 : options.inline)) {
216
217
  return false;
217
218
  }
218
- if ((options == null ? undefined : options.inlineFiles) && (options == null ? undefined : options.inlineFiles.includes(id))) {
219
+ if ((options == null ? void 0 : options.inlineFiles) && (options == null ? void 0 : options.inlineFiles.includes(id))) {
219
220
  return false;
220
221
  }
221
- if (matchExternalizePattern(id, moduleDirectories, options == null ? undefined : options.external)) {
222
+ if (matchExternalizePattern(id, moduleDirectories, options == null ? void 0 : options.external)) {
222
223
  return id;
223
224
  }
224
- if ((options == null ? undefined : options.cacheDir) && id.includes(options.cacheDir)) {
225
+ if ((options == null ? void 0 : options.cacheDir) && id.includes(options.cacheDir)) {
225
226
  return id;
226
227
  }
227
228
  const isLibraryModule = moduleDirectories.some((dir) => id.includes(dir));
228
- const guessCJS = isLibraryModule && (options == null ? undefined : options.fallbackCJS);
229
+ const guessCJS = isLibraryModule && (options == null ? void 0 : options.fallbackCJS);
229
230
  id = guessCJS ? guessCJSversion(id) || id : id;
230
231
  if (matchExternalizePattern(id, moduleDirectories, defaultInline)) {
231
232
  return false;
@@ -316,7 +317,7 @@ class ViteNodeServer {
316
317
  }
317
318
  (_c = options.deps).moduleDirectories ?? (_c.moduleDirectories = []);
318
319
  const envValue = process.env.VITE_NODE_DEPS_MODULE_DIRECTORIES || process.env.npm_config_VITE_NODE_DEPS_MODULE_DIRECTORIES;
319
- const customModuleDirectories = envValue == null ? undefined : envValue.split(",");
320
+ const customModuleDirectories = envValue == null ? void 0 : envValue.split(",");
320
321
  if (customModuleDirectories) {
321
322
  options.deps.moduleDirectories.push(...customModuleDirectories);
322
323
  }
@@ -391,12 +392,12 @@ class ViteNodeServer {
391
392
  getSourceMap(source) {
392
393
  var _a, _b;
393
394
  source = utils.normalizeModuleId(source);
394
- const fetchResult = (_a = this.fetchCache.get(source)) == null ? undefined : _a.result;
395
- if (fetchResult == null ? undefined : fetchResult.map) {
395
+ const fetchResult = (_a = this.fetchCache.get(source)) == null ? void 0 : _a.result;
396
+ if (fetchResult == null ? void 0 : fetchResult.map) {
396
397
  return fetchResult.map;
397
398
  }
398
- const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? undefined : _b.ssrTransformResult;
399
- return (ssrTransformResult == null ? undefined : ssrTransformResult.map) || null;
399
+ const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? void 0 : _b.ssrTransformResult;
400
+ return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
400
401
  }
401
402
  assertMode(mode) {
402
403
  assert(
@@ -407,7 +408,7 @@ class ViteNodeServer {
407
408
  async fetchModule(id, transformMode) {
408
409
  const mode = transformMode || this.getTransformMode(id);
409
410
  return this.fetchResult(id, mode).then((r) => {
410
- return this.options.sourcemap !== true ? { ...r, map: undefined } : r;
411
+ return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
411
412
  });
412
413
  }
413
414
  async fetchResult(id, mode) {
@@ -446,18 +447,18 @@ class ViteNodeServer {
446
447
  }
447
448
  const normalizedId = utils.normalizeModuleId(id);
448
449
  const mod = this.server.moduleGraph.getModuleById(normalizedId);
449
- const result = (mod == null ? undefined : mod.transformResult) || await this.server.transformRequest(normalizedId);
450
+ const result = (mod == null ? void 0 : mod.transformResult) || await this.server.transformRequest(normalizedId);
450
451
  return {
451
- code: result == null ? undefined : result.code
452
+ code: result == null ? void 0 : result.code
452
453
  };
453
454
  }
454
455
  getTransformMode(id) {
455
456
  var _a, _b, _c, _d;
456
457
  const withoutQuery = id.split("?")[0];
457
- if ((_b = (_a = this.options.transformMode) == null ? undefined : _a.web) == null ? undefined : _b.some((r) => withoutQuery.match(r))) {
458
+ if ((_b = (_a = this.options.transformMode) == null ? void 0 : _a.web) == null ? void 0 : _b.some((r) => withoutQuery.match(r))) {
458
459
  return "web";
459
460
  }
460
- if ((_d = (_c = this.options.transformMode) == null ? undefined : _c.ssr) == null ? undefined : _d.some((r) => withoutQuery.match(r))) {
461
+ if ((_d = (_c = this.options.transformMode) == null ? void 0 : _c.ssr) == null ? void 0 : _d.some((r) => withoutQuery.match(r))) {
461
462
  return "ssr";
462
463
  }
463
464
  if (withoutQuery.match(/\.([cm]?[jt]sx?|json)$/)) {
@@ -492,7 +493,7 @@ class ViteNodeServer {
492
493
  async _fetchModule(id, transformMode) {
493
494
  var _a, _b;
494
495
  let result;
495
- const cacheDir = (_a = this.options.deps) == null ? undefined : _a.cacheDir;
496
+ const cacheDir = (_a = this.options.deps) == null ? void 0 : _a.cacheDir;
496
497
  if (cacheDir && id.includes(cacheDir)) {
497
498
  if (!id.startsWith(utils.withTrailingSlash(this.server.config.root))) {
498
499
  id = pathe.join(this.server.config.root, id);
@@ -520,12 +521,12 @@ class ViteNodeServer {
520
521
  let duration;
521
522
  if (externalize) {
522
523
  result = { externalize };
523
- (_b = this.debugger) == null ? undefined : _b.recordExternalize(id, externalize);
524
+ (_b = this.debugger) == null ? void 0 : _b.recordExternalize(id, externalize);
524
525
  } else {
525
526
  const start = node_perf_hooks.performance.now();
526
527
  const r = await this._transformRequest(id, filePath, transformMode);
527
528
  duration = node_perf_hooks.performance.now() - start;
528
- result = { code: r == null ? undefined : r.code, map: r == null ? undefined : r.map };
529
+ result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
529
530
  }
530
531
  const cacheEntry = {
531
532
  duration,
@@ -541,16 +542,17 @@ class ViteNodeServer {
541
542
  async processTransformResult(filepath, result) {
542
543
  const mod = this.server.moduleGraph.getModuleById(filepath);
543
544
  return sourceMap.withInlineSourcemap(result, {
544
- filepath: (mod == null ? undefined : mod.file) || filepath,
545
- root: this.server.config.root
545
+ filepath: (mod == null ? void 0 : mod.file) || filepath,
546
+ root: this.server.config.root,
547
+ noFirstLineMapping: Number(vite.version.split(".")[0]) >= 6
546
548
  });
547
549
  }
548
550
  async _transformRequest(id, filepath, transformMode) {
549
551
  var _a, _b, _c, _d;
550
552
  debugRequest(id);
551
553
  let result = null;
552
- if ((_a = this.options.debug) == null ? undefined : _a.loadDumppedModules) {
553
- result = await ((_b = this.debugger) == null ? undefined : _b.loadDump(id)) ?? null;
554
+ if ((_a = this.options.debug) == null ? void 0 : _a.loadDumppedModules) {
555
+ result = await ((_b = this.debugger) == null ? void 0 : _b.loadDump(id)) ?? null;
554
556
  if (result) {
555
557
  return result;
556
558
  }
@@ -567,8 +569,8 @@ class ViteNodeServer {
567
569
  if (sourcemap === "inline" && result && !id.includes("node_modules")) {
568
570
  result = await this.processTransformResult(filepath, result);
569
571
  }
570
- if ((_c = this.options.debug) == null ? undefined : _c.dumpModules) {
571
- await ((_d = this.debugger) == null ? undefined : _d.dumpFile(id, result));
572
+ if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules) {
573
+ await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
572
574
  }
573
575
  return result;
574
576
  }
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-BmdeEDlf.js';
2
+ import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './index-LQxw79Gm.js';
3
3
  import { E as EncodedSourceMap } from './trace-mapping.d-DLVdEqOp.js';
4
4
 
5
5
  declare class Debugger {
@@ -31,10 +31,7 @@ declare class ViteNodeServer {
31
31
  private transformPromiseMap;
32
32
  private durations;
33
33
  private existingOptimizedDeps;
34
- fetchCaches: {
35
- ssr: Map<string, FetchCache>;
36
- web: Map<string, FetchCache>;
37
- };
34
+ fetchCaches: Record<'ssr' | 'web', Map<string, FetchCache>>;
38
35
  fetchCache: Map<string, FetchCache>;
39
36
  externalizeCache: Map<string, Promise<string | false>>;
40
37
  debugger?: Debugger;
@@ -51,7 +48,7 @@ declare class ViteNodeServer {
51
48
  transformModule(id: string, transformMode?: 'web' | 'ssr'): Promise<{
52
49
  code: string | undefined;
53
50
  }>;
54
- getTransformMode(id: string): "web" | "ssr";
51
+ getTransformMode(id: string): 'ssr' | 'web';
55
52
  private getChangedModule;
56
53
  private _fetchModule;
57
54
  protected processTransformResult(filepath: string, result: TransformResult): Promise<TransformResult>;
package/dist/server.mjs CHANGED
@@ -4,6 +4,7 @@ import { performance } from 'node:perf_hooks';
4
4
  import { pathToFileURL } from 'node:url';
5
5
  import createDebug from 'debug';
6
6
  import { resolve, join, extname, dirname, relative, normalize } from 'pathe';
7
+ import { version } from 'vite';
7
8
  import { s } from './chunk-browser.mjs';
8
9
  import * as esModuleLexer from 'es-module-lexer';
9
10
  import { KNOWN_ASSET_RE } from './constants.mjs';
@@ -90,7 +91,7 @@ ${result.code}`,
90
91
  const code = await promises.readFile(path, "utf-8");
91
92
  return {
92
93
  code: code.replace(/^\/\/.*\n/, ""),
93
- map: undefined
94
+ map: void 0
94
95
  };
95
96
  }
96
97
  async writeInfo() {
@@ -190,21 +191,21 @@ async function _shouldExternalize(id, options) {
190
191
  return id;
191
192
  }
192
193
  id = patchWindowsImportPath(id);
193
- const moduleDirectories = (options == null ? undefined : options.moduleDirectories) || ["/node_modules/"];
194
- if (matchExternalizePattern(id, moduleDirectories, options == null ? undefined : options.inline)) {
194
+ const moduleDirectories = (options == null ? void 0 : options.moduleDirectories) || ["/node_modules/"];
195
+ if (matchExternalizePattern(id, moduleDirectories, options == null ? void 0 : options.inline)) {
195
196
  return false;
196
197
  }
197
- if ((options == null ? undefined : options.inlineFiles) && (options == null ? undefined : options.inlineFiles.includes(id))) {
198
+ if ((options == null ? void 0 : options.inlineFiles) && (options == null ? void 0 : options.inlineFiles.includes(id))) {
198
199
  return false;
199
200
  }
200
- if (matchExternalizePattern(id, moduleDirectories, options == null ? undefined : options.external)) {
201
+ if (matchExternalizePattern(id, moduleDirectories, options == null ? void 0 : options.external)) {
201
202
  return id;
202
203
  }
203
- if ((options == null ? undefined : options.cacheDir) && id.includes(options.cacheDir)) {
204
+ if ((options == null ? void 0 : options.cacheDir) && id.includes(options.cacheDir)) {
204
205
  return id;
205
206
  }
206
207
  const isLibraryModule = moduleDirectories.some((dir) => id.includes(dir));
207
- const guessCJS = isLibraryModule && (options == null ? undefined : options.fallbackCJS);
208
+ const guessCJS = isLibraryModule && (options == null ? void 0 : options.fallbackCJS);
208
209
  id = guessCJS ? guessCJSversion(id) || id : id;
209
210
  if (matchExternalizePattern(id, moduleDirectories, defaultInline)) {
210
211
  return false;
@@ -295,7 +296,7 @@ class ViteNodeServer {
295
296
  }
296
297
  (_c = options.deps).moduleDirectories ?? (_c.moduleDirectories = []);
297
298
  const envValue = process.env.VITE_NODE_DEPS_MODULE_DIRECTORIES || process.env.npm_config_VITE_NODE_DEPS_MODULE_DIRECTORIES;
298
- const customModuleDirectories = envValue == null ? undefined : envValue.split(",");
299
+ const customModuleDirectories = envValue == null ? void 0 : envValue.split(",");
299
300
  if (customModuleDirectories) {
300
301
  options.deps.moduleDirectories.push(...customModuleDirectories);
301
302
  }
@@ -370,12 +371,12 @@ class ViteNodeServer {
370
371
  getSourceMap(source) {
371
372
  var _a, _b;
372
373
  source = normalizeModuleId(source);
373
- const fetchResult = (_a = this.fetchCache.get(source)) == null ? undefined : _a.result;
374
- if (fetchResult == null ? undefined : fetchResult.map) {
374
+ const fetchResult = (_a = this.fetchCache.get(source)) == null ? void 0 : _a.result;
375
+ if (fetchResult == null ? void 0 : fetchResult.map) {
375
376
  return fetchResult.map;
376
377
  }
377
- const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? undefined : _b.ssrTransformResult;
378
- return (ssrTransformResult == null ? undefined : ssrTransformResult.map) || null;
378
+ const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? void 0 : _b.ssrTransformResult;
379
+ return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
379
380
  }
380
381
  assertMode(mode) {
381
382
  assert(
@@ -386,7 +387,7 @@ class ViteNodeServer {
386
387
  async fetchModule(id, transformMode) {
387
388
  const mode = transformMode || this.getTransformMode(id);
388
389
  return this.fetchResult(id, mode).then((r) => {
389
- return this.options.sourcemap !== true ? { ...r, map: undefined } : r;
390
+ return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
390
391
  });
391
392
  }
392
393
  async fetchResult(id, mode) {
@@ -425,18 +426,18 @@ class ViteNodeServer {
425
426
  }
426
427
  const normalizedId = normalizeModuleId(id);
427
428
  const mod = this.server.moduleGraph.getModuleById(normalizedId);
428
- const result = (mod == null ? undefined : mod.transformResult) || await this.server.transformRequest(normalizedId);
429
+ const result = (mod == null ? void 0 : mod.transformResult) || await this.server.transformRequest(normalizedId);
429
430
  return {
430
- code: result == null ? undefined : result.code
431
+ code: result == null ? void 0 : result.code
431
432
  };
432
433
  }
433
434
  getTransformMode(id) {
434
435
  var _a, _b, _c, _d;
435
436
  const withoutQuery = id.split("?")[0];
436
- if ((_b = (_a = this.options.transformMode) == null ? undefined : _a.web) == null ? undefined : _b.some((r) => withoutQuery.match(r))) {
437
+ if ((_b = (_a = this.options.transformMode) == null ? void 0 : _a.web) == null ? void 0 : _b.some((r) => withoutQuery.match(r))) {
437
438
  return "web";
438
439
  }
439
- if ((_d = (_c = this.options.transformMode) == null ? undefined : _c.ssr) == null ? undefined : _d.some((r) => withoutQuery.match(r))) {
440
+ if ((_d = (_c = this.options.transformMode) == null ? void 0 : _c.ssr) == null ? void 0 : _d.some((r) => withoutQuery.match(r))) {
440
441
  return "ssr";
441
442
  }
442
443
  if (withoutQuery.match(/\.([cm]?[jt]sx?|json)$/)) {
@@ -471,7 +472,7 @@ class ViteNodeServer {
471
472
  async _fetchModule(id, transformMode) {
472
473
  var _a, _b;
473
474
  let result;
474
- const cacheDir = (_a = this.options.deps) == null ? undefined : _a.cacheDir;
475
+ const cacheDir = (_a = this.options.deps) == null ? void 0 : _a.cacheDir;
475
476
  if (cacheDir && id.includes(cacheDir)) {
476
477
  if (!id.startsWith(withTrailingSlash(this.server.config.root))) {
477
478
  id = join(this.server.config.root, id);
@@ -499,12 +500,12 @@ class ViteNodeServer {
499
500
  let duration;
500
501
  if (externalize) {
501
502
  result = { externalize };
502
- (_b = this.debugger) == null ? undefined : _b.recordExternalize(id, externalize);
503
+ (_b = this.debugger) == null ? void 0 : _b.recordExternalize(id, externalize);
503
504
  } else {
504
505
  const start = performance.now();
505
506
  const r = await this._transformRequest(id, filePath, transformMode);
506
507
  duration = performance.now() - start;
507
- result = { code: r == null ? undefined : r.code, map: r == null ? undefined : r.map };
508
+ result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
508
509
  }
509
510
  const cacheEntry = {
510
511
  duration,
@@ -520,16 +521,17 @@ class ViteNodeServer {
520
521
  async processTransformResult(filepath, result) {
521
522
  const mod = this.server.moduleGraph.getModuleById(filepath);
522
523
  return withInlineSourcemap(result, {
523
- filepath: (mod == null ? undefined : mod.file) || filepath,
524
- root: this.server.config.root
524
+ filepath: (mod == null ? void 0 : mod.file) || filepath,
525
+ root: this.server.config.root,
526
+ noFirstLineMapping: Number(version.split(".")[0]) >= 6
525
527
  });
526
528
  }
527
529
  async _transformRequest(id, filepath, transformMode) {
528
530
  var _a, _b, _c, _d;
529
531
  debugRequest(id);
530
532
  let result = null;
531
- if ((_a = this.options.debug) == null ? undefined : _a.loadDumppedModules) {
532
- result = await ((_b = this.debugger) == null ? undefined : _b.loadDump(id)) ?? null;
533
+ if ((_a = this.options.debug) == null ? void 0 : _a.loadDumppedModules) {
534
+ result = await ((_b = this.debugger) == null ? void 0 : _b.loadDump(id)) ?? null;
533
535
  if (result) {
534
536
  return result;
535
537
  }
@@ -546,8 +548,8 @@ class ViteNodeServer {
546
548
  if (sourcemap === "inline" && result && !id.includes("node_modules")) {
547
549
  result = await this.processTransformResult(filepath, result);
548
550
  }
549
- if ((_c = this.options.debug) == null ? undefined : _c.dumpModules) {
550
- await ((_d = this.debugger) == null ? undefined : _d.dumpFile(id, result));
551
+ if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules) {
552
+ await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
551
553
  }
552
554
  return result;
553
555
  }
@@ -692,10 +692,10 @@ function mapSourcePosition(position) {
692
692
  url: urlAndMap.url,
693
693
  map: new TraceMap(urlAndMap.map)
694
694
  };
695
- if ((_a = sourceMap.map) == null ? undefined : _a.sourcesContent) {
695
+ if ((_a = sourceMap.map) == null ? void 0 : _a.sourcesContent) {
696
696
  sourceMap.map.sources.forEach((source, i) => {
697
697
  var _a2, _b;
698
- const contents = (_b = (_a2 = sourceMap.map) == null ? undefined : _a2.sourcesContent) == null ? undefined : _b[i];
698
+ const contents = (_b = (_a2 = sourceMap.map) == null ? void 0 : _a2.sourcesContent) == null ? void 0 : _b[i];
699
699
  if (contents && source && sourceMap.url) {
700
700
  const url = supportRelativeURL(sourceMap.url, source);
701
701
  fileContentsCache[url] = contents;
@@ -810,7 +810,7 @@ function cloneCallSite(frame) {
810
810
  return object;
811
811
  }
812
812
  function wrapCallSite(frame, state) {
813
- if (state === undefined) {
813
+ if (state === void 0) {
814
814
  state = { nextPosition: null, curPosition: null };
815
815
  }
816
816
  if (frame.isNative()) {
@@ -842,7 +842,7 @@ function wrapCallSite(frame, state) {
842
842
  return state.nextPosition.name || originalFunctionName();
843
843
  };
844
844
  frame.getFileName = function() {
845
- return position.source ?? undefined;
845
+ return position.source ?? void 0;
846
846
  };
847
847
  frame.getLineNumber = function() {
848
848
  return position.line;
@@ -860,7 +860,7 @@ function wrapCallSite(frame, state) {
860
860
  origin = mapEvalOrigin(origin);
861
861
  frame = cloneCallSite(frame);
862
862
  frame.getEvalOrigin = function() {
863
- return origin || undefined;
863
+ return origin || void 0;
864
864
  };
865
865
  return frame;
866
866
  }
@@ -917,7 +917,7 @@ function withInlineSourcemap(result, options) {
917
917
  return result;
918
918
  }
919
919
  if ("sources" in map) {
920
- map.sources = (_a = map.sources) == null ? undefined : _a.map((source) => {
920
+ map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
921
921
  if (!source) {
922
922
  return source;
923
923
  }
@@ -935,7 +935,7 @@ function withInlineSourcemap(result, options) {
935
935
  while (OTHER_SOURCE_MAP_REGEXP.test(code)) {
936
936
  code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
937
937
  }
938
- if (map.mappings.startsWith(";")) {
938
+ if (!options.noFirstLineMapping && map.mappings.startsWith(";")) {
939
939
  map.mappings = `AAAA,CAAA${map.mappings}`;
940
940
  }
941
941
  const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString(
@@ -950,7 +950,7 @@ ${VITE_NODE_SOURCEMAPPING_SOURCE}
950
950
  }
951
951
  function extractSourceMap(code) {
952
952
  var _a;
953
- const mapString = (_a = code.match(VITE_NODE_SOURCEMAPPING_REGEXP)) == null ? undefined : _a[1];
953
+ const mapString = (_a = code.match(VITE_NODE_SOURCEMAPPING_REGEXP)) == null ? void 0 : _a[1];
954
954
  if (mapString) {
955
955
  return JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
956
956
  }
@@ -7,6 +7,7 @@ interface InstallSourceMapSupportOptions {
7
7
  declare function withInlineSourcemap(result: TransformResult, options: {
8
8
  root: string;
9
9
  filepath: string;
10
+ noFirstLineMapping?: boolean;
10
11
  }): TransformResult;
11
12
  declare function extractSourceMap(code: string): EncodedSourceMap | null;
12
13
  declare function installSourcemapsSupport(options: InstallSourceMapSupportOptions): void;
@@ -690,10 +690,10 @@ function mapSourcePosition(position) {
690
690
  url: urlAndMap.url,
691
691
  map: new TraceMap(urlAndMap.map)
692
692
  };
693
- if ((_a = sourceMap.map) == null ? undefined : _a.sourcesContent) {
693
+ if ((_a = sourceMap.map) == null ? void 0 : _a.sourcesContent) {
694
694
  sourceMap.map.sources.forEach((source, i) => {
695
695
  var _a2, _b;
696
- const contents = (_b = (_a2 = sourceMap.map) == null ? undefined : _a2.sourcesContent) == null ? undefined : _b[i];
696
+ const contents = (_b = (_a2 = sourceMap.map) == null ? void 0 : _a2.sourcesContent) == null ? void 0 : _b[i];
697
697
  if (contents && source && sourceMap.url) {
698
698
  const url = supportRelativeURL(sourceMap.url, source);
699
699
  fileContentsCache[url] = contents;
@@ -808,7 +808,7 @@ function cloneCallSite(frame) {
808
808
  return object;
809
809
  }
810
810
  function wrapCallSite(frame, state) {
811
- if (state === undefined) {
811
+ if (state === void 0) {
812
812
  state = { nextPosition: null, curPosition: null };
813
813
  }
814
814
  if (frame.isNative()) {
@@ -840,7 +840,7 @@ function wrapCallSite(frame, state) {
840
840
  return state.nextPosition.name || originalFunctionName();
841
841
  };
842
842
  frame.getFileName = function() {
843
- return position.source ?? undefined;
843
+ return position.source ?? void 0;
844
844
  };
845
845
  frame.getLineNumber = function() {
846
846
  return position.line;
@@ -858,7 +858,7 @@ function wrapCallSite(frame, state) {
858
858
  origin = mapEvalOrigin(origin);
859
859
  frame = cloneCallSite(frame);
860
860
  frame.getEvalOrigin = function() {
861
- return origin || undefined;
861
+ return origin || void 0;
862
862
  };
863
863
  return frame;
864
864
  }
@@ -915,7 +915,7 @@ function withInlineSourcemap(result, options) {
915
915
  return result;
916
916
  }
917
917
  if ("sources" in map) {
918
- map.sources = (_a = map.sources) == null ? undefined : _a.map((source) => {
918
+ map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
919
919
  if (!source) {
920
920
  return source;
921
921
  }
@@ -933,7 +933,7 @@ function withInlineSourcemap(result, options) {
933
933
  while (OTHER_SOURCE_MAP_REGEXP.test(code)) {
934
934
  code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
935
935
  }
936
- if (map.mappings.startsWith(";")) {
936
+ if (!options.noFirstLineMapping && map.mappings.startsWith(";")) {
937
937
  map.mappings = `AAAA,CAAA${map.mappings}`;
938
938
  }
939
939
  const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString(
@@ -948,7 +948,7 @@ ${VITE_NODE_SOURCEMAPPING_SOURCE}
948
948
  }
949
949
  function extractSourceMap(code) {
950
950
  var _a;
951
- const mapString = (_a = code.match(VITE_NODE_SOURCEMAPPING_REGEXP)) == null ? undefined : _a[1];
951
+ const mapString = (_a = code.match(VITE_NODE_SOURCEMAPPING_REGEXP)) == null ? void 0 : _a[1];
952
952
  if (mapString) {
953
953
  return JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
954
954
  }
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-DLVdEqOp.js';
2
- 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, l as ViteNodeResolveModule, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-BmdeEDlf.js';
2
+ export { A as Arrayable, g as Awaitable, j as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, h as FetchFunction, F as FetchResult, b as HotContext, k as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, i as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, m as ViteNodeResolveModule, l as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-LQxw79Gm.js';
package/dist/utils.cjs CHANGED
@@ -18,7 +18,7 @@ function normalizeRequestId(id, base) {
18
18
  if (base && id.startsWith(withTrailingSlash(base))) {
19
19
  id = `/${id.slice(base.length)}`;
20
20
  }
21
- if (driveRegexp && !(driveRegexp == null ? undefined : driveRegexp.test(id)) && (driveOppositeRegext == null ? undefined : driveOppositeRegext.test(id))) {
21
+ if (driveRegexp && !(driveRegexp == null ? void 0 : driveRegexp.test(id)) && (driveOppositeRegext == null ? void 0 : driveOppositeRegext.test(id))) {
22
22
  id = id.replace(driveOppositeRegext, `${drive}$1`);
23
23
  }
24
24
  if (id.startsWith("file://")) {
@@ -109,7 +109,7 @@ function isNodeBuiltin(id) {
109
109
  );
110
110
  }
111
111
  function toArray(array) {
112
- if (array === null || array === undefined) {
112
+ if (array === null || array === void 0) {
113
113
  array = [];
114
114
  }
115
115
  if (Array.isArray(array)) {
@@ -152,7 +152,7 @@ function createImportMetaEnvProxy() {
152
152
  return new Proxy(process.env, {
153
153
  get(_, key) {
154
154
  if (typeof key !== "string") {
155
- return undefined;
155
+ return void 0;
156
156
  }
157
157
  if (booleanKeys.includes(key)) {
158
158
  return !!process.env[key];
@@ -183,7 +183,7 @@ async function findNearestPackageData(basedir) {
183
183
  }
184
184
  const pkgPath = pathe.join(basedir, "package.json");
185
185
  if ((_a = await fs.promises.stat(pkgPath).catch(() => {
186
- })) == null ? undefined : _a.isFile()) {
186
+ })) == null ? void 0 : _a.isFile()) {
187
187
  const pkgData = JSON.parse(await fs.promises.readFile(pkgPath, "utf8"));
188
188
  if (packageCache) {
189
189
  setCacheData(packageCache, pkgData, basedir, originalBasedir);
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as Nullable, A as Arrayable } from './index-BmdeEDlf.js';
1
+ import { N as Nullable, A as Arrayable } from './index-LQxw79Gm.js';
2
2
  import './trace-mapping.d-DLVdEqOp.js';
3
3
 
4
4
  declare const isWindows: boolean;
package/dist/utils.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { existsSync, promises } from 'node:fs';
2
2
  import { builtinModules } from 'node:module';
3
3
  import { fileURLToPath, pathToFileURL } from 'node:url';
4
- import { resolve, dirname, join } from 'pathe';
4
+ import { resolve, join, dirname } from 'pathe';
5
5
 
6
6
  const isWindows = process.platform === "win32";
7
7
  const drive = isWindows ? process.cwd()[0] : null;
@@ -16,7 +16,7 @@ function normalizeRequestId(id, base) {
16
16
  if (base && id.startsWith(withTrailingSlash(base))) {
17
17
  id = `/${id.slice(base.length)}`;
18
18
  }
19
- if (driveRegexp && !(driveRegexp == null ? undefined : driveRegexp.test(id)) && (driveOppositeRegext == null ? undefined : driveOppositeRegext.test(id))) {
19
+ if (driveRegexp && !(driveRegexp == null ? void 0 : driveRegexp.test(id)) && (driveOppositeRegext == null ? void 0 : driveOppositeRegext.test(id))) {
20
20
  id = id.replace(driveOppositeRegext, `${drive}$1`);
21
21
  }
22
22
  if (id.startsWith("file://")) {
@@ -107,7 +107,7 @@ function isNodeBuiltin(id) {
107
107
  );
108
108
  }
109
109
  function toArray(array) {
110
- if (array === null || array === undefined) {
110
+ if (array === null || array === void 0) {
111
111
  array = [];
112
112
  }
113
113
  if (Array.isArray(array)) {
@@ -150,7 +150,7 @@ function createImportMetaEnvProxy() {
150
150
  return new Proxy(process.env, {
151
151
  get(_, key) {
152
152
  if (typeof key !== "string") {
153
- return undefined;
153
+ return void 0;
154
154
  }
155
155
  if (booleanKeys.includes(key)) {
156
156
  return !!process.env[key];
@@ -181,7 +181,7 @@ async function findNearestPackageData(basedir) {
181
181
  }
182
182
  const pkgPath = join(basedir, "package.json");
183
183
  if ((_a = await promises.stat(pkgPath).catch(() => {
184
- })) == null ? undefined : _a.isFile()) {
184
+ })) == null ? void 0 : _a.isFile()) {
185
185
  const pkgData = JSON.parse(await promises.readFile(pkgPath, "utf8"));
186
186
  if (packageCache) {
187
187
  setCacheData(packageCache, pkgData, basedir, originalBasedir);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-node",
3
3
  "type": "module",
4
- "version": "3.0.5",
4
+ "version": "3.0.7",
5
5
  "description": "Vite as Node.js runtime",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -80,7 +80,7 @@
80
80
  "cac": "^6.7.14",
81
81
  "debug": "^4.4.0",
82
82
  "es-module-lexer": "^1.6.0",
83
- "pathe": "^2.0.2",
83
+ "pathe": "^2.0.3",
84
84
  "vite": "^5.0.0 || ^6.0.0"
85
85
  },
86
86
  "devDependencies": {