vite-node 5.3.0 → 6.0.0

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,13 +1,12 @@
1
- import { _ as withTrailingSlash } from "./utils-ExLpYVUV.mjs";
1
+ import { withTrailingSlash } from "./utils.mjs";
2
2
  import fs from "node:fs";
3
3
  import process from "node:process";
4
4
  import { dirname, isAbsolute, relative, resolve } from "pathe";
5
5
  import { Buffer as Buffer$1 } from "node:buffer";
6
6
  import path from "node:path";
7
-
8
7
  //#region node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
9
8
  var comma = ",".charCodeAt(0);
10
- var semicolon = ";".charCodeAt(0);
9
+ ";".charCodeAt(0);
11
10
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
12
11
  var intToChar = new Uint8Array(64);
13
12
  var charToInt = new Uint8Array(128);
@@ -16,7 +15,7 @@ for (let i = 0; i < chars.length; i++) {
16
15
  intToChar[i] = c;
17
16
  charToInt[c] = i;
18
17
  }
19
- function decodeInteger(reader, relative$1) {
18
+ function decodeInteger(reader, relative) {
20
19
  let value = 0;
21
20
  let shift = 0;
22
21
  let integer = 0;
@@ -28,13 +27,12 @@ function decodeInteger(reader, relative$1) {
28
27
  const shouldNegate = value & 1;
29
28
  value >>>= 1;
30
29
  if (shouldNegate) value = -2147483648 | -value;
31
- return relative$1 + value;
30
+ return relative + value;
32
31
  }
33
32
  function hasMoreVlq(reader, max) {
34
33
  if (reader.pos >= max) return false;
35
34
  return reader.peek() !== comma;
36
35
  }
37
- var bufLength = 1024 * 16;
38
36
  var StringReader = class {
39
37
  constructor(buffer) {
40
38
  this.pos = 0;
@@ -107,7 +105,6 @@ function sort(line) {
107
105
  function sortComparator$1(a, b) {
108
106
  return a[0] - b[0];
109
107
  }
110
-
111
108
  //#endregion
112
109
  //#region node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
113
110
  const schemeRegex = /^[\w+.-]+:\/\//;
@@ -153,16 +150,16 @@ function parseAbsoluteUrl(input) {
153
150
  }
154
151
  function parseFileUrl(input) {
155
152
  const match = fileRegex.exec(input);
156
- const path$1 = match[2];
157
- return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path$1) ? path$1 : "/" + path$1, match[3] || "", match[4] || "");
153
+ const path = match[2];
154
+ return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || "");
158
155
  }
159
- function makeUrl(scheme, user, host, port, path$1, query, hash) {
156
+ function makeUrl(scheme, user, host, port, path, query, hash) {
160
157
  return {
161
158
  scheme,
162
159
  user,
163
160
  host,
164
161
  port,
165
- path: path$1,
162
+ path,
166
163
  query,
167
164
  hash,
168
165
  type: 7
@@ -170,17 +167,17 @@ function makeUrl(scheme, user, host, port, path$1, query, hash) {
170
167
  }
171
168
  function parseUrl(input) {
172
169
  if (isSchemeRelativeUrl(input)) {
173
- const url$1 = parseAbsoluteUrl("http:" + input);
174
- url$1.scheme = "";
175
- url$1.type = 6;
176
- return url$1;
170
+ const url = parseAbsoluteUrl("http:" + input);
171
+ url.scheme = "";
172
+ url.type = 6;
173
+ return url;
177
174
  }
178
175
  if (isAbsolutePath(input)) {
179
- const url$1 = parseAbsoluteUrl("http://foo.com" + input);
180
- url$1.scheme = "";
181
- url$1.host = "";
182
- url$1.type = 5;
183
- return url$1;
176
+ const url = parseAbsoluteUrl("http://foo.com" + input);
177
+ url.scheme = "";
178
+ url.host = "";
179
+ url.type = 5;
180
+ return url;
184
181
  }
185
182
  if (isFileUrl(input)) return parseFileUrl(input);
186
183
  if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);
@@ -190,10 +187,10 @@ function parseUrl(input) {
190
187
  url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
191
188
  return url;
192
189
  }
193
- function stripPathFilename(path$1) {
194
- if (path$1.endsWith("/..")) return path$1;
195
- const index = path$1.lastIndexOf("/");
196
- return path$1.slice(0, index + 1);
190
+ function stripPathFilename(path) {
191
+ if (path.endsWith("/..")) return path;
192
+ const index = path.lastIndexOf("/");
193
+ return path.slice(0, index + 1);
197
194
  }
198
195
  function mergePaths(url, base) {
199
196
  normalizePath(base, base.type);
@@ -229,10 +226,10 @@ function normalizePath(url, type) {
229
226
  pieces[pointer++] = piece;
230
227
  positive++;
231
228
  }
232
- let path$1 = "";
233
- for (let i = 1; i < pointer; i++) path$1 += "/" + pieces[i];
234
- if (!path$1 || addTrailingSlash && !path$1.endsWith("/..")) path$1 += "/";
235
- url.path = path$1;
229
+ let path = "";
230
+ for (let i = 1; i < pointer; i++) path += "/" + pieces[i];
231
+ if (!path || addTrailingSlash && !path.endsWith("/..")) path += "/";
232
+ url.path = path;
236
233
  }
237
234
  /**
238
235
  * Attempts to resolve `input` URL/path relative to `base`.
@@ -263,22 +260,21 @@ function resolve$2(input, base) {
263
260
  case 2:
264
261
  case 3: return queryHash;
265
262
  case 4: {
266
- const path$1 = url.path.slice(1);
267
- if (!path$1) return queryHash || ".";
268
- if (isRelative(base || input) && !isRelative(path$1)) return "./" + path$1 + queryHash;
269
- return path$1 + queryHash;
263
+ const path = url.path.slice(1);
264
+ if (!path) return queryHash || ".";
265
+ if (isRelative(base || input) && !isRelative(path)) return "./" + path + queryHash;
266
+ return path + queryHash;
270
267
  }
271
268
  case 5: return url.path + queryHash;
272
269
  default: return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
273
270
  }
274
271
  }
275
-
276
272
  //#endregion
277
273
  //#region node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
278
- function stripFilename(path$1) {
279
- if (!path$1) return "";
280
- const index = path$1.lastIndexOf("/");
281
- return path$1.slice(0, index + 1);
274
+ function stripFilename(path) {
275
+ if (!path) return "";
276
+ const index = path.lastIndexOf("/");
277
+ return path.slice(0, index + 1);
282
278
  }
283
279
  function resolver(mapUrl, sourceRoot) {
284
280
  const from = stripFilename(mapUrl);
@@ -363,8 +359,6 @@ function parse(map) {
363
359
  }
364
360
  var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
365
361
  var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
366
- var LEAST_UPPER_BOUND = -1;
367
- var GREATEST_LOWER_BOUND = 1;
368
362
  var TraceMap = class {
369
363
  constructor(map, mapUrl) {
370
364
  const isString = typeof map === "string";
@@ -378,8 +372,8 @@ var TraceMap = class {
378
372
  this.sources = sources;
379
373
  this.sourcesContent = sourcesContent;
380
374
  this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
381
- const resolve$3 = resolver(mapUrl, sourceRoot);
382
- this.resolvedSources = sources.map(resolve$3);
375
+ const resolve = resolver(mapUrl, sourceRoot);
376
+ this.resolvedSources = sources.map(resolve);
383
377
  const { mappings } = parsed;
384
378
  if (typeof mappings === "string") {
385
379
  this._encoded = mappings;
@@ -409,7 +403,7 @@ function originalPositionFor(map, needle) {
409
403
  const decoded = decodedMappings(map);
410
404
  if (line >= decoded.length) return OMapping(null, null, null, null);
411
405
  const segments = decoded[line];
412
- const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
406
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || 1);
413
407
  if (index === -1) return OMapping(null, null, null, null);
414
408
  const segment = segments[index];
415
409
  if (segment.length === 1) return OMapping(null, null, null, null);
@@ -426,12 +420,11 @@ function OMapping(source, line, column, name) {
426
420
  }
427
421
  function traceSegmentInternal(segments, memo, line, column, bias) {
428
422
  let index = memoizedBinarySearch(segments, column, memo, line);
429
- if (found) index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
430
- else if (bias === LEAST_UPPER_BOUND) index++;
423
+ if (found) index = (bias === -1 ? upperBound : lowerBound)(segments, column, index);
424
+ else if (bias === -1) index++;
431
425
  if (index === -1 || index === segments.length) return -1;
432
426
  return index;
433
427
  }
434
-
435
428
  //#endregion
436
429
  //#region src/source-map-handler.ts
437
430
  let errorFormatterInstalled = false;
@@ -454,17 +447,17 @@ function handlerExec(list) {
454
447
  };
455
448
  }
456
449
  let retrieveFile = handlerExec(retrieveFileHandlers);
457
- retrieveFileHandlers.push((path$1) => {
458
- path$1 = path$1.trim();
459
- if (path$1.startsWith("file:")) path$1 = path$1.replace(/file:\/\/\/(\w:)?/, (protocol, drive) => {
450
+ retrieveFileHandlers.push((path) => {
451
+ path = path.trim();
452
+ if (path.startsWith("file:")) path = path.replace(/file:\/\/\/(\w:)?/, (protocol, drive) => {
460
453
  return drive ? "" : "/";
461
454
  });
462
- if (path$1 in fileContentsCache) return fileContentsCache[path$1];
455
+ if (path in fileContentsCache) return fileContentsCache[path];
463
456
  let contents = "";
464
457
  try {
465
- if (fs.existsSync(path$1)) contents = fs.readFileSync(path$1, "utf8");
458
+ if (fs.existsSync(path)) contents = fs.readFileSync(path, "utf8");
466
459
  } catch {}
467
- return fileContentsCache[path$1] = contents;
460
+ return fileContentsCache[path] = contents;
468
461
  });
469
462
  function supportRelativeURL(file, url) {
470
463
  if (!file) return url;
@@ -672,8 +665,8 @@ function prepareStackTrace(error, stack) {
672
665
  state.curPosition = state.nextPosition = null;
673
666
  return errorString + processedStack.reverse().join("");
674
667
  }
675
- const originalRetrieveFileHandlers = retrieveFileHandlers.slice(0);
676
- const originalRetrieveMapHandlers = retrieveMapHandlers.slice(0);
668
+ retrieveFileHandlers.slice(0);
669
+ retrieveMapHandlers.slice(0);
677
670
  function install(options) {
678
671
  options = options || {};
679
672
  if (options.retrieveFile) {
@@ -689,7 +682,6 @@ function install(options) {
689
682
  Error.prepareStackTrace = prepareStackTrace;
690
683
  }
691
684
  }
692
-
693
685
  //#endregion
694
686
  //#region src/source-map.ts
695
687
  let SOURCEMAPPING_URL = "sourceMa";
@@ -732,6 +724,5 @@ function installSourcemapsSupport(options) {
732
724
  return null;
733
725
  } });
734
726
  }
735
-
736
727
  //#endregion
737
- export { originalPositionFor as a, TraceMap as i, installSourcemapsSupport as n, withInlineSourcemap as r, extractSourceMap as t };
728
+ export { originalPositionFor as a, TraceMap as i, installSourcemapsSupport as n, withInlineSourcemap as r, extractSourceMap as t };
@@ -1,4 +1,4 @@
1
- import { s as EncodedSourceMap } from "./types-EZz9rsDw.mjs";
1
+ import { w as EncodedSourceMap } from "./types-Bl6mw_Ii.mjs";
2
2
  import { TransformResult } from "vite";
3
3
 
4
4
  //#region src/source-map.d.ts
@@ -1,4 +1,2 @@
1
- import "./utils-ExLpYVUV.mjs";
2
- import { n as installSourcemapsSupport, r as withInlineSourcemap, t as extractSourceMap } from "./source-map-CysB5F9m.mjs";
3
-
4
- export { extractSourceMap, installSourcemapsSupport, withInlineSourcemap };
1
+ import { n as installSourcemapsSupport, r as withInlineSourcemap, t as extractSourceMap } from "./source-map-BFKsz_pY.mjs";
2
+ export { extractSourceMap, installSourcemapsSupport, withInlineSourcemap };
@@ -1,7 +1,67 @@
1
- import * as _jridgewell_trace_mapping0 from "@jridgewell/trace-mapping";
2
- import { DecodedSourceMap, EncodedSourceMap, EncodedSourceMap as EncodedSourceMap$1, SourceMapInput } from "@jridgewell/trace-mapping";
3
1
  import { ViteHotContext } from "vite/types/hot.js";
4
2
 
3
+ //#region node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts
4
+ type GeneratedColumn = number;
5
+ type SourcesIndex = number;
6
+ type SourceLine = number;
7
+ type SourceColumn = number;
8
+ type NamesIndex = number;
9
+ type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];
10
+ //#endregion
11
+ //#region node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/types/types.d.mts
12
+ interface SourceMapV3 {
13
+ file?: string | null;
14
+ names: string[];
15
+ sourceRoot?: string;
16
+ sources: (string | null)[];
17
+ sourcesContent?: (string | null)[];
18
+ version: 3;
19
+ ignoreList?: number[];
20
+ }
21
+ interface EncodedSourceMap extends SourceMapV3 {
22
+ mappings: string;
23
+ }
24
+ interface DecodedSourceMap extends SourceMapV3 {
25
+ mappings: SourceMapSegment[][];
26
+ }
27
+ type XInput = {
28
+ x_google_ignoreList?: SourceMapV3['ignoreList'];
29
+ };
30
+ type EncodedSourceMapXInput = EncodedSourceMap & XInput;
31
+ type DecodedSourceMapXInput = DecodedSourceMap & XInput;
32
+ type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap;
33
+ declare abstract class SourceMap {
34
+ version: SourceMapV3['version'];
35
+ file: SourceMapV3['file'];
36
+ names: SourceMapV3['names'];
37
+ sourceRoot: SourceMapV3['sourceRoot'];
38
+ sources: SourceMapV3['sources'];
39
+ sourcesContent: SourceMapV3['sourcesContent'];
40
+ resolvedSources: SourceMapV3['sources'];
41
+ ignoreList: SourceMapV3['ignoreList'];
42
+ }
43
+ type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
44
+ type RoArray<T> = Ro<T>[];
45
+ type RoObject<T> = { [K in keyof T]: T[K] | Ro<T[K]> };
46
+ //#endregion
47
+ //#region node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts
48
+ declare class TraceMap implements SourceMap {
49
+ version: SourceMapV3['version'];
50
+ file: SourceMapV3['file'];
51
+ names: SourceMapV3['names'];
52
+ sourceRoot: SourceMapV3['sourceRoot'];
53
+ sources: SourceMapV3['sources'];
54
+ sourcesContent: SourceMapV3['sourcesContent'];
55
+ ignoreList: SourceMapV3['ignoreList'];
56
+ resolvedSources: string[];
57
+ private _encoded;
58
+ private _decoded;
59
+ private _decodedMemo;
60
+ private _bySources;
61
+ private _bySourceMemos;
62
+ constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
63
+ }
64
+ //#endregion
5
65
  //#region src/client.d.ts
6
66
  declare const DEFAULT_REQUEST_STUBS: Record<string, Record<string, unknown>>;
7
67
  declare class ModuleCacheMap extends Map<string, ModuleCache> {
@@ -28,7 +88,7 @@ declare class ModuleCacheMap extends Map<string, ModuleCache> {
28
88
  /**
29
89
  * Return parsed source map based on inlined source map of the module
30
90
  */
31
- getSourceMap(id: string): _jridgewell_trace_mapping0.EncodedSourceMap | null;
91
+ getSourceMap(id: string): EncodedSourceMap | null;
32
92
  }
33
93
  type ModuleExecutionInfo = Map<string, ModuleExecutionInfoEntry>;
34
94
  interface ModuleExecutionInfoEntry {
@@ -214,4 +274,4 @@ interface DebuggerOptions {
214
274
  loadDumppedModules?: boolean;
215
275
  }
216
276
  //#endregion
217
- export { ModuleExecutionInfo as C, ModuleCacheMap as S, ViteNodeRunner as T, ViteNodeResolveId as _, DecodedSourceMap as a, ViteNodeServerOptions as b, FetchFunction as c, ModuleCache as d, Nullable as f, StartOfSourceMap as g, SourceMapInput as h, DebuggerOptions as i, FetchResult as l, ResolveIdFunction as m, Awaitable as n, DepsHandlingOptions as o, RawSourceMap as p, CreateHotContextFunction as r, EncodedSourceMap$1 as s, Arrayable as t, HotContext as u, ViteNodeResolveModule as v, ModuleExecutionInfoEntry as w, DEFAULT_REQUEST_STUBS as x, ViteNodeRunnerOptions as y };
277
+ export { DecodedSourceMap as C, ViteNodeRunner as S, SourceMapInput as T, ViteNodeServerOptions as _, DepsHandlingOptions as a, ModuleExecutionInfo as b, HotContext as c, RawSourceMap as d, ResolveIdFunction as f, ViteNodeRunnerOptions as g, ViteNodeResolveModule as h, DebuggerOptions as i, ModuleCache as l, ViteNodeResolveId as m, Awaitable as n, FetchFunction as o, StartOfSourceMap as p, CreateHotContextFunction as r, FetchResult as s, Arrayable as t, Nullable as u, DEFAULT_REQUEST_STUBS as v, EncodedSourceMap as w, ModuleExecutionInfoEntry as x, ModuleCacheMap as y };
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as ModuleExecutionInfo, S as ModuleCacheMap, _ as ViteNodeResolveId, a as DecodedSourceMap, b as ViteNodeServerOptions, c as FetchFunction, d as ModuleCache, f as Nullable, g as StartOfSourceMap, h as SourceMapInput, i as DebuggerOptions, l as FetchResult, m as ResolveIdFunction, n as Awaitable, o as DepsHandlingOptions, p as RawSourceMap, r as CreateHotContextFunction, s as EncodedSourceMap, t as Arrayable, u as HotContext, v as ViteNodeResolveModule, y as ViteNodeRunnerOptions } from "./types-EZz9rsDw.mjs";
1
+ import { C as DecodedSourceMap, T as SourceMapInput, _ as ViteNodeServerOptions, a as DepsHandlingOptions, b as ModuleExecutionInfo, c as HotContext, d as RawSourceMap, f as ResolveIdFunction, g as ViteNodeRunnerOptions, h as ViteNodeResolveModule, i as DebuggerOptions, l as ModuleCache, m as ViteNodeResolveId, n as Awaitable, o as FetchFunction, p as StartOfSourceMap, r as CreateHotContextFunction, s as FetchResult, t as Arrayable, u as Nullable, w as EncodedSourceMap, y as ModuleCacheMap } from "./types-Bl6mw_Ii.mjs";
2
2
  export { Arrayable, Awaitable, CreateHotContextFunction, DebuggerOptions, DecodedSourceMap, DepsHandlingOptions, EncodedSourceMap, FetchFunction, FetchResult, HotContext, ModuleCache, ModuleCacheMap, ModuleExecutionInfo, Nullable, RawSourceMap, ResolveIdFunction, SourceMapInput, StartOfSourceMap, ViteNodeResolveId, ViteNodeResolveModule, ViteNodeRunnerOptions, ViteNodeServerOptions };
package/dist/types.mjs CHANGED
@@ -1,3 +1 @@
1
- import "./types-55T_-8KG.mjs";
2
-
3
- export { };
1
+ export {};
package/dist/utils.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { f as Nullable, t as Arrayable } from "./types-EZz9rsDw.mjs";
1
+ import { t as Arrayable, u as Nullable } from "./types-Bl6mw_Ii.mjs";
2
2
 
3
3
  //#region src/utils.d.ts
4
4
  declare const isWindows: boolean;
package/dist/utils.mjs CHANGED
@@ -1,3 +1,188 @@
1
- import { _ as withTrailingSlash, a as getCachedData, c as isNodeBuiltin, d as normalizeModuleId, f as normalizeRequestId, g as toFilePath, h as toArray, i as findNearestPackageData, l as isPrimitive, m as slash, n as cleanUrl, o as isBareImport, p as setCacheData, r as createImportMetaEnvProxy, s as isInternalRequest, t as VALID_ID_PREFIX, u as isWindows } from "./utils-ExLpYVUV.mjs";
2
-
3
- export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, findNearestPackageData, getCachedData, isBareImport, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
1
+ import { builtinModules } from "node:module";
2
+ import { existsSync, promises } from "node:fs";
3
+ import process from "node:process";
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import { dirname, join, resolve } from "pathe";
6
+ //#region src/utils.ts
7
+ const isWindows = process.platform === "win32";
8
+ const drive = isWindows ? process.cwd()[0] : null;
9
+ const driveOpposite = drive ? drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase() : null;
10
+ const driveRegexp = drive ? new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
11
+ const driveOppositeRegext = driveOpposite ? new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
12
+ function slash(str) {
13
+ return str.replace(/\\/g, "/");
14
+ }
15
+ const bareImportRE = /^(?![a-z]:)[\w@](?!.*:\/\/)/i;
16
+ function isBareImport(id) {
17
+ return bareImportRE.test(id);
18
+ }
19
+ const VALID_ID_PREFIX = "/@id/";
20
+ function normalizeRequestId(id, base) {
21
+ if (base && id.startsWith(withTrailingSlash(base))) id = `/${id.slice(base.length)}`;
22
+ if (driveRegexp && !driveRegexp?.test(id) && driveOppositeRegext?.test(id)) id = id.replace(driveOppositeRegext, `${drive}$1`);
23
+ if (id.startsWith("file://")) {
24
+ const { file, postfix } = splitFileAndPostfix(id);
25
+ return fileURLToPath(file) + postfix;
26
+ }
27
+ return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
28
+ }
29
+ const postfixRE = /[?#].*$/;
30
+ function cleanUrl(url) {
31
+ return url.replace(postfixRE, "");
32
+ }
33
+ function splitFileAndPostfix(path) {
34
+ const file = cleanUrl(path);
35
+ return {
36
+ file,
37
+ postfix: path.slice(file.length)
38
+ };
39
+ }
40
+ const internalRequestRegexp = new RegExp(`^/?(?:${["@vite/client", "@vite/env"].join("|")})$`);
41
+ function isInternalRequest(id) {
42
+ return internalRequestRegexp.test(id);
43
+ }
44
+ const prefixedBuiltins = new Set([
45
+ "node:sea",
46
+ "node:sqlite",
47
+ "node:test",
48
+ "node:test/reporters"
49
+ ]);
50
+ const builtins = new Set([
51
+ ...builtinModules,
52
+ "assert/strict",
53
+ "diagnostics_channel",
54
+ "dns/promises",
55
+ "fs/promises",
56
+ "path/posix",
57
+ "path/win32",
58
+ "readline/promises",
59
+ "stream/consumers",
60
+ "stream/promises",
61
+ "stream/web",
62
+ "timers/promises",
63
+ "util/types",
64
+ "wasi"
65
+ ]);
66
+ function normalizeModuleId(id) {
67
+ if (prefixedBuiltins.has(id)) return id;
68
+ if (id.startsWith("file://")) return fileURLToPath(id);
69
+ return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
70
+ }
71
+ function isPrimitive(v) {
72
+ return v !== Object(v);
73
+ }
74
+ function toFilePath(id, root) {
75
+ let { absolute, exists } = (() => {
76
+ if (id.startsWith("/@fs/")) return {
77
+ absolute: id.slice(4),
78
+ exists: true
79
+ };
80
+ if (!id.startsWith(withTrailingSlash(root)) && id.startsWith("/")) {
81
+ const resolved = resolve(root, id.slice(1));
82
+ if (existsSync(cleanUrl(resolved))) return {
83
+ absolute: resolved,
84
+ exists: true
85
+ };
86
+ } else if (id.startsWith(withTrailingSlash(root)) && existsSync(cleanUrl(id))) return {
87
+ absolute: id,
88
+ exists: true
89
+ };
90
+ return {
91
+ absolute: id,
92
+ exists: false
93
+ };
94
+ })();
95
+ if (absolute.startsWith("//")) absolute = absolute.slice(1);
96
+ return {
97
+ path: isWindows && absolute.startsWith("/") ? slash(fileURLToPath(pathToFileURL(absolute.slice(1)).href)) : absolute,
98
+ exists
99
+ };
100
+ }
101
+ const NODE_BUILTIN_NAMESPACE = "node:";
102
+ function isNodeBuiltin(id) {
103
+ if (prefixedBuiltins.has(id)) return true;
104
+ return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
105
+ }
106
+ /**
107
+ * Convert `Arrayable<T>` to `Array<T>`
108
+ *
109
+ * @category Array
110
+ */
111
+ function toArray(array) {
112
+ array ??= [];
113
+ if (Array.isArray(array)) return array;
114
+ return [array];
115
+ }
116
+ function getCachedData(cache, basedir, originalBasedir) {
117
+ const pkgData = cache.get(getFnpdCacheKey(basedir));
118
+ if (pkgData) {
119
+ traverseBetweenDirs(originalBasedir, basedir, (dir) => {
120
+ cache.set(getFnpdCacheKey(dir), pkgData);
121
+ });
122
+ return pkgData;
123
+ }
124
+ }
125
+ function setCacheData(cache, data, basedir, originalBasedir) {
126
+ cache.set(getFnpdCacheKey(basedir), data);
127
+ traverseBetweenDirs(originalBasedir, basedir, (dir) => {
128
+ cache.set(getFnpdCacheKey(dir), data);
129
+ });
130
+ }
131
+ function getFnpdCacheKey(basedir) {
132
+ return `fnpd_${basedir}`;
133
+ }
134
+ /**
135
+ * Traverse between `longerDir` (inclusive) and `shorterDir` (exclusive) and call `cb` for each dir.
136
+ * @param longerDir Longer dir path, e.g. `/User/foo/bar/baz`
137
+ * @param shorterDir Shorter dir path, e.g. `/User/foo`
138
+ */
139
+ function traverseBetweenDirs(longerDir, shorterDir, cb) {
140
+ while (longerDir !== shorterDir) {
141
+ cb(longerDir);
142
+ longerDir = dirname(longerDir);
143
+ }
144
+ }
145
+ function withTrailingSlash(path) {
146
+ if (path.at(-1) !== "/") return `${path}/`;
147
+ return path;
148
+ }
149
+ function createImportMetaEnvProxy() {
150
+ const booleanKeys = [
151
+ "DEV",
152
+ "PROD",
153
+ "SSR"
154
+ ];
155
+ return new Proxy(process.env, {
156
+ get(_, key) {
157
+ if (typeof key !== "string") return;
158
+ if (booleanKeys.includes(key)) return !!process.env[key];
159
+ return process.env[key];
160
+ },
161
+ set(_, key, value) {
162
+ if (typeof key !== "string") return true;
163
+ if (booleanKeys.includes(key)) process.env[key] = value ? "1" : "";
164
+ else process.env[key] = value;
165
+ return true;
166
+ }
167
+ });
168
+ }
169
+ const packageCache = /* @__PURE__ */ new Map();
170
+ async function findNearestPackageData(basedir) {
171
+ const originalBasedir = basedir;
172
+ while (basedir) {
173
+ const cached = getCachedData(packageCache, basedir, originalBasedir);
174
+ if (cached) return cached;
175
+ const pkgPath = join(basedir, "package.json");
176
+ if ((await promises.stat(pkgPath).catch(() => {}))?.isFile()) {
177
+ const pkgData = JSON.parse(await promises.readFile(pkgPath, "utf8"));
178
+ if (packageCache) setCacheData(packageCache, pkgData, basedir, originalBasedir);
179
+ return pkgData;
180
+ }
181
+ const nextBasedir = dirname(basedir);
182
+ if (nextBasedir === basedir) break;
183
+ basedir = nextBasedir;
184
+ }
185
+ return {};
186
+ }
187
+ //#endregion
188
+ export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, findNearestPackageData, getCachedData, isBareImport, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-node",
3
3
  "type": "module",
4
- "version": "5.3.0",
4
+ "version": "6.0.0",
5
5
  "description": "Vite as Node.js runtime",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -27,9 +27,6 @@
27
27
  "./utils": "./dist/utils.mjs",
28
28
  "./package.json": "./package.json"
29
29
  },
30
- "main": "./dist/index.mjs",
31
- "module": "./dist/index.mjs",
32
- "types": "./dist/index.d.mts",
33
30
  "bin": {
34
31
  "vite-node": "./dist/cli.mjs"
35
32
  },
@@ -39,25 +36,31 @@
39
36
  "engines": {
40
37
  "node": "^20.19.0 || >=22.12.0"
41
38
  },
39
+ "inlinedDependencies": {
40
+ "tinyrainbow": "3.1.0",
41
+ "@jridgewell/sourcemap-codec": "1.5.5",
42
+ "@jridgewell/resolve-uri": "3.1.2",
43
+ "@jridgewell/trace-mapping": "0.3.31"
44
+ },
42
45
  "dependencies": {
43
- "cac": "^6.7.14",
46
+ "cac": "^7.0.0",
44
47
  "es-module-lexer": "^2.0.0",
45
48
  "obug": "^2.1.1",
46
49
  "pathe": "^2.0.3",
47
- "vite": "^7.3.1"
50
+ "vite": "^8.0.0"
48
51
  },
49
52
  "devDependencies": {
50
- "@antfu/eslint-config": "^7.0.1",
53
+ "@antfu/eslint-config": "^7.7.2",
51
54
  "@jridgewell/trace-mapping": "^0.3.31",
52
- "@types/node": "^25.0.9",
53
- "bumpp": "^10.4.0",
54
- "eslint": "^9.39.2",
55
- "inquirer": "^13.2.0",
55
+ "@types/node": "^25.4.0",
56
+ "bumpp": "^10.4.1",
57
+ "eslint": "^10.0.3",
58
+ "inquirer": "^13.3.0",
56
59
  "tinyexec": "^1.0.2",
57
- "tinyrainbow": "^3.0.3",
58
- "tsdown": "^0.16.8",
60
+ "tinyrainbow": "^3.1.0",
61
+ "tsdown": "^0.21.2",
59
62
  "typescript": "^5.9.3",
60
- "vitest": "^4.0.17"
63
+ "vitest": "^4.1.0"
61
64
  },
62
65
  "scripts": {
63
66
  "lint": "eslint",