vite-node 4.0.0-beta.2 → 4.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/README.md CHANGED
@@ -91,10 +91,12 @@ import { installSourcemapsSupport } from 'vite-node/source-map'
91
91
  const server = await createServer({
92
92
  optimizeDeps: {
93
93
  // It's recommended to disable deps optimization
94
- disabled: true,
94
+ noDiscovery: true,
95
+ include: undefined,
95
96
  },
96
97
  })
97
- // For old Vite, this is need to initialize the plugins.
98
+
99
+ // For old Vite, this is needed to initialize the plugins.
98
100
  if (Number(viteVersion.split('.')[0]) < 6) {
99
101
  await server.pluginContainer.buildStart({})
100
102
  }
package/dist/cli.cjs CHANGED
@@ -21,7 +21,7 @@ require('node:perf_hooks');
21
21
  require('es-module-lexer');
22
22
  require('./constants.cjs');
23
23
 
24
- var version = "4.0.0-beta.2";
24
+ var version = "4.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,5 +1,5 @@
1
- import { V as ViteNodeServerOptions } from './index.d-DGmxD2U7.js';
2
- import './trace-mapping.d-DLVdEqOp.js';
1
+ import { V as ViteNodeServerOptions } from './index.d-CvIJUDRh.js';
2
+ import './trace-mapping.d-BWFx6tPc.js';
3
3
 
4
4
  interface CliOptions {
5
5
  "root"?: string;
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 = "4.0.0-beta.2";
22
+ var version = "4.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
@@ -206,7 +206,7 @@ class ViteNodeRunner {
206
206
  const resolved = await this.options.resolveId(dep, importer);
207
207
  // supported since Vite 5-beta.19
208
208
  if (resolved === null || resolved === void 0 || (_resolved$meta = resolved.meta) === null || _resolved$meta === void 0 || (_resolved$meta = _resolved$meta["vite:alias"]) === null || _resolved$meta === void 0 ? void 0 : _resolved$meta.noResolved) {
209
- const error = new Error(`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
209
+ const error = /* @__PURE__ */ new Error(`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
210
210
 
211
211
  - If you rely on tsconfig.json's "paths" to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution.
212
212
  - Make sure you don't have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors`);
package/dist/client.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import './trace-mapping.d-DLVdEqOp.js';
2
- export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, f as ModuleExecutionInfo, g as ModuleExecutionInfoEntry, a as ViteNodeRunner } from './index.d-DGmxD2U7.js';
1
+ import './trace-mapping.d-BWFx6tPc.js';
2
+ export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, f as ModuleExecutionInfo, g as ModuleExecutionInfoEntry, a as ViteNodeRunner } from './index.d-CvIJUDRh.js';
package/dist/client.mjs CHANGED
@@ -204,7 +204,7 @@ class ViteNodeRunner {
204
204
  const resolved = await this.options.resolveId(dep, importer);
205
205
  // supported since Vite 5-beta.19
206
206
  if (resolved === null || resolved === void 0 || (_resolved$meta = resolved.meta) === null || _resolved$meta === void 0 || (_resolved$meta = _resolved$meta["vite:alias"]) === null || _resolved$meta === void 0 ? void 0 : _resolved$meta.noResolved) {
207
- const error = new Error(`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
207
+ const error = /* @__PURE__ */ new Error(`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
208
208
 
209
209
  - If you rely on tsconfig.json's "paths" to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution.
210
210
  - Make sure you don't have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors`);
@@ -28,7 +28,7 @@ const KNOWN_ASSET_TYPES = [
28
28
  "pdf",
29
29
  "txt"
30
30
  ];
31
- const KNOWN_ASSET_RE = new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
31
+ const KNOWN_ASSET_RE = /* @__PURE__ */ new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
32
32
  const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
33
33
 
34
34
  exports.CSS_LANGS_RE = CSS_LANGS_RE;
@@ -26,7 +26,7 @@ const KNOWN_ASSET_TYPES = [
26
26
  "pdf",
27
27
  "txt"
28
28
  ];
29
- const KNOWN_ASSET_RE = new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
29
+ const KNOWN_ASSET_RE = /* @__PURE__ */ new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
30
30
  const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
31
31
 
32
32
  export { CSS_LANGS_RE, KNOWN_ASSET_RE, KNOWN_ASSET_TYPES };
package/dist/hmr.d.ts CHANGED
@@ -1,7 +1,7 @@
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.d-DGmxD2U7.js';
4
- import './trace-mapping.d-DLVdEqOp.js';
3
+ import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index.d-CvIJUDRh.js';
4
+ import './trace-mapping.d-BWFx6tPc.js';
5
5
 
6
6
  type EventType = string | symbol;
7
7
  type Handler<T = unknown> = (event: T) => void;
@@ -11,7 +11,7 @@ interface Emitter<Events extends Record<EventType, unknown>> {
11
11
  emit: (<Key extends keyof Events>(type: Key, event: Events[Key]) => void) & (<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never) => void);
12
12
  }
13
13
  type HMREmitter = Emitter<{
14
- message: HMRPayload
14
+ message: HMRPayload;
15
15
  }> & EventEmitter;
16
16
  declare module "vite" {
17
17
  interface ViteDevServer {
@@ -24,7 +24,7 @@ declare function viteNodeHmrPlugin(): Plugin;
24
24
  /* eslint-disable no-console */
25
25
 
26
26
  type ModuleNamespace = Record<string, any> & {
27
- [Symbol.toStringTag]: "Module"
27
+ [Symbol.toStringTag]: "Module";
28
28
  };
29
29
  type InferCustomEventPayload<T extends string> = T extends keyof CustomEventMap ? CustomEventMap[T] : any;
30
30
  interface HotModule {
@@ -1,4 +1,4 @@
1
- import { E as EncodedSourceMap } from './trace-mapping.d-DLVdEqOp.js';
1
+ import { E as EncodedSourceMap } from './trace-mapping.d-BWFx6tPc.js';
2
2
 
3
3
  /** @deprecated use HotPayload */
4
4
  type HMRPayload = HotPayload
@@ -223,9 +223,9 @@ declare class ViteNodeRunner {
223
223
  resolveUrl(id: string, importee?: string): Promise<[url: string, fsPath: string]>;
224
224
  private _fetchModule;
225
225
  protected getContextPrimitives(): {
226
- Object: ObjectConstructor
227
- Reflect: typeof Reflect
228
- Symbol: SymbolConstructor
226
+ Object: ObjectConstructor;
227
+ Reflect: typeof Reflect;
228
+ Symbol: SymbolConstructor;
229
229
  };
230
230
  protected runModule(context: Record<string, any>, transformed: string): Promise<void>;
231
231
  /**
@@ -341,8 +341,8 @@ interface ViteNodeServerOptions {
341
341
  * Transform method for modules
342
342
  */
343
343
  transformMode?: {
344
- ssr?: RegExp[]
345
- web?: RegExp[]
344
+ ssr?: RegExp[];
345
+ web?: RegExp[];
346
346
  };
347
347
  debug?: DebuggerOptions;
348
348
  }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-DGmxD2U7.js';
2
- export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-DLVdEqOp.js';
1
+ export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-CvIJUDRh.js';
2
+ export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-BWFx6tPc.js';
package/dist/server.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { TransformResult, ViteDevServer } from 'vite';
2
- import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './index.d-DGmxD2U7.js';
3
- import { E as EncodedSourceMap } from './trace-mapping.d-DLVdEqOp.js';
2
+ import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './index.d-CvIJUDRh.js';
3
+ import { E as EncodedSourceMap } from './trace-mapping.d-BWFx6tPc.js';
4
4
 
5
5
  declare class Debugger {
6
- options: DebuggerOptions;
6
+ options: string;
7
7
  dumpDir: string | undefined;
8
8
  initPromise: Promise<void> | undefined;
9
9
  externalizeMap: Map<string, string>;
@@ -46,7 +46,7 @@ declare class ViteNodeServer {
46
46
  fetchResult(id: string, mode: "web" | "ssr"): Promise<FetchResult>;
47
47
  transformRequest(id: string, filepath?: string, transformMode?: "web" | "ssr"): Promise<TransformResult | null | undefined>;
48
48
  transformModule(id: string, transformMode?: "web" | "ssr"): Promise<{
49
- code: string | undefined
49
+ code: string | undefined;
50
50
  }>;
51
51
  getTransformMode(id: string): "ssr" | "web";
52
52
  private getChangedModule;
@@ -289,7 +289,7 @@ function normalizePath(url, type) {
289
289
  /**
290
290
  * Attempts to resolve `input` URL/path relative to `base`.
291
291
  */
292
- function resolve$1(input, base) {
292
+ function resolve(input, base) {
293
293
  if (!input && !base)
294
294
  return '';
295
295
  const url = parseUrl(input);
@@ -349,238 +349,204 @@ function resolve$1(input, base) {
349
349
  }
350
350
  }
351
351
 
352
- function resolve(input, base) {
353
- // The base is always treated as a directory, if it's not empty.
354
- // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
355
- // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
356
- if (base && !base.endsWith('/'))
357
- base += '/';
358
- return resolve$1(input, base);
359
- }
352
+ // src/trace-mapping.ts
360
353
 
361
- /**
362
- * Removes everything after the last "/", but leaves the slash.
363
- */
354
+ // src/strip-filename.ts
364
355
  function stripFilename(path) {
365
- if (!path)
366
- return '';
367
- const index = path.lastIndexOf('/');
368
- return path.slice(0, index + 1);
356
+ if (!path) return "";
357
+ const index = path.lastIndexOf("/");
358
+ return path.slice(0, index + 1);
369
359
  }
370
360
 
371
- const COLUMN = 0;
372
- const SOURCES_INDEX = 1;
373
- const SOURCE_LINE = 2;
374
- const SOURCE_COLUMN = 3;
375
- const NAMES_INDEX = 4;
361
+ // src/resolve.ts
362
+ function resolver(mapUrl, sourceRoot) {
363
+ const from = stripFilename(mapUrl);
364
+ const prefix = sourceRoot ? sourceRoot + "/" : "";
365
+ return (source) => resolve(prefix + (source || ""), from);
366
+ }
376
367
 
368
+ // src/sourcemap-segment.ts
369
+ var COLUMN = 0;
370
+ var SOURCES_INDEX = 1;
371
+ var SOURCE_LINE = 2;
372
+ var SOURCE_COLUMN = 3;
373
+ var NAMES_INDEX = 4;
374
+
375
+ // src/sort.ts
377
376
  function maybeSort(mappings, owned) {
378
- const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
379
- if (unsortedIndex === mappings.length)
380
- return mappings;
381
- // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If
382
- // not, we do not want to modify the consumer's input array.
383
- if (!owned)
384
- mappings = mappings.slice();
385
- for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
386
- mappings[i] = sortSegments(mappings[i], owned);
387
- }
388
- return mappings;
377
+ const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
378
+ if (unsortedIndex === mappings.length) return mappings;
379
+ if (!owned) mappings = mappings.slice();
380
+ for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
381
+ mappings[i] = sortSegments(mappings[i], owned);
382
+ }
383
+ return mappings;
389
384
  }
390
385
  function nextUnsortedSegmentLine(mappings, start) {
391
- for (let i = start; i < mappings.length; i++) {
392
- if (!isSorted(mappings[i]))
393
- return i;
394
- }
395
- return mappings.length;
386
+ for (let i = start; i < mappings.length; i++) {
387
+ if (!isSorted(mappings[i])) return i;
388
+ }
389
+ return mappings.length;
396
390
  }
397
391
  function isSorted(line) {
398
- for (let j = 1; j < line.length; j++) {
399
- if (line[j][COLUMN] < line[j - 1][COLUMN]) {
400
- return false;
401
- }
392
+ for (let j = 1; j < line.length; j++) {
393
+ if (line[j][COLUMN] < line[j - 1][COLUMN]) {
394
+ return false;
402
395
  }
403
- return true;
396
+ }
397
+ return true;
404
398
  }
405
399
  function sortSegments(line, owned) {
406
- if (!owned)
407
- line = line.slice();
408
- return line.sort(sortComparator);
400
+ if (!owned) line = line.slice();
401
+ return line.sort(sortComparator);
409
402
  }
410
403
  function sortComparator(a, b) {
411
- return a[COLUMN] - b[COLUMN];
404
+ return a[COLUMN] - b[COLUMN];
412
405
  }
413
406
 
414
- let found = false;
415
- /**
416
- * A binary search implementation that returns the index if a match is found.
417
- * If no match is found, then the left-index (the index associated with the item that comes just
418
- * before the desired index) is returned. To maintain proper sort order, a splice would happen at
419
- * the next index:
420
- *
421
- * ```js
422
- * const array = [1, 3];
423
- * const needle = 2;
424
- * const index = binarySearch(array, needle, (item, needle) => item - needle);
425
- *
426
- * assert.equal(index, 0);
427
- * array.splice(index + 1, 0, needle);
428
- * assert.deepEqual(array, [1, 2, 3]);
429
- * ```
430
- */
407
+ // src/binary-search.ts
408
+ var found = false;
431
409
  function binarySearch(haystack, needle, low, high) {
432
- while (low <= high) {
433
- const mid = low + ((high - low) >> 1);
434
- const cmp = haystack[mid][COLUMN] - needle;
435
- if (cmp === 0) {
436
- found = true;
437
- return mid;
438
- }
439
- if (cmp < 0) {
440
- low = mid + 1;
441
- }
442
- else {
443
- high = mid - 1;
444
- }
410
+ while (low <= high) {
411
+ const mid = low + (high - low >> 1);
412
+ const cmp = haystack[mid][COLUMN] - needle;
413
+ if (cmp === 0) {
414
+ found = true;
415
+ return mid;
445
416
  }
446
- found = false;
447
- return low - 1;
417
+ if (cmp < 0) {
418
+ low = mid + 1;
419
+ } else {
420
+ high = mid - 1;
421
+ }
422
+ }
423
+ found = false;
424
+ return low - 1;
448
425
  }
449
426
  function upperBound(haystack, needle, index) {
450
- for (let i = index + 1; i < haystack.length; index = i++) {
451
- if (haystack[i][COLUMN] !== needle)
452
- break;
453
- }
454
- return index;
427
+ for (let i = index + 1; i < haystack.length; index = i++) {
428
+ if (haystack[i][COLUMN] !== needle) break;
429
+ }
430
+ return index;
455
431
  }
456
432
  function lowerBound(haystack, needle, index) {
457
- for (let i = index - 1; i >= 0; index = i--) {
458
- if (haystack[i][COLUMN] !== needle)
459
- break;
460
- }
461
- return index;
433
+ for (let i = index - 1; i >= 0; index = i--) {
434
+ if (haystack[i][COLUMN] !== needle) break;
435
+ }
436
+ return index;
462
437
  }
463
438
  function memoizedState() {
464
- return {
465
- lastKey: -1,
466
- lastNeedle: -1,
467
- lastIndex: -1,
468
- };
439
+ return {
440
+ lastKey: -1,
441
+ lastNeedle: -1,
442
+ lastIndex: -1
443
+ };
469
444
  }
470
- /**
471
- * This overly complicated beast is just to record the last tested line/column and the resulting
472
- * index, allowing us to skip a few tests if mappings are monotonically increasing.
473
- */
474
445
  function memoizedBinarySearch(haystack, needle, state, key) {
475
- const { lastKey, lastNeedle, lastIndex } = state;
476
- let low = 0;
477
- let high = haystack.length - 1;
478
- if (key === lastKey) {
479
- if (needle === lastNeedle) {
480
- found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
481
- return lastIndex;
482
- }
483
- if (needle >= lastNeedle) {
484
- // lastIndex may be -1 if the previous needle was not found.
485
- low = lastIndex === -1 ? 0 : lastIndex;
486
- }
487
- else {
488
- high = lastIndex;
489
- }
446
+ const { lastKey, lastNeedle, lastIndex } = state;
447
+ let low = 0;
448
+ let high = haystack.length - 1;
449
+ if (key === lastKey) {
450
+ if (needle === lastNeedle) {
451
+ found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
452
+ return lastIndex;
453
+ }
454
+ if (needle >= lastNeedle) {
455
+ low = lastIndex === -1 ? 0 : lastIndex;
456
+ } else {
457
+ high = lastIndex;
490
458
  }
491
- state.lastKey = key;
492
- state.lastNeedle = needle;
493
- return (state.lastIndex = binarySearch(haystack, needle, low, high));
459
+ }
460
+ state.lastKey = key;
461
+ state.lastNeedle = needle;
462
+ return state.lastIndex = binarySearch(haystack, needle, low, high);
494
463
  }
495
464
 
496
- const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
497
- const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
498
- const LEAST_UPPER_BOUND = -1;
499
- const GREATEST_LOWER_BOUND = 1;
500
- class TraceMap {
501
- constructor(map, mapUrl) {
502
- const isString = typeof map === 'string';
503
- if (!isString && map._decodedMemo)
504
- return map;
505
- const parsed = (isString ? JSON.parse(map) : map);
506
- const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
507
- this.version = version;
508
- this.file = file;
509
- this.names = names || [];
510
- this.sourceRoot = sourceRoot;
511
- this.sources = sources;
512
- this.sourcesContent = sourcesContent;
513
- this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
514
- const from = resolve(sourceRoot || '', stripFilename(mapUrl));
515
- this.resolvedSources = sources.map((s) => resolve(s || '', from));
516
- const { mappings } = parsed;
517
- if (typeof mappings === 'string') {
518
- this._encoded = mappings;
519
- this._decoded = undefined;
520
- }
521
- else {
522
- this._encoded = undefined;
523
- this._decoded = maybeSort(mappings, isString);
524
- }
525
- this._decodedMemo = memoizedState();
526
- this._bySources = undefined;
527
- this._bySourceMemos = undefined;
528
- }
465
+ // src/types.ts
466
+ function parse(map) {
467
+ return typeof map === "string" ? JSON.parse(map) : map;
529
468
  }
530
- /**
531
- * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
532
- * with public access modifiers.
533
- */
469
+
470
+ // src/trace-mapping.ts
471
+ var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
472
+ var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
473
+ var LEAST_UPPER_BOUND = -1;
474
+ var GREATEST_LOWER_BOUND = 1;
475
+ var TraceMap = class {
476
+ constructor(map, mapUrl) {
477
+ const isString = typeof map === "string";
478
+ if (!isString && map._decodedMemo) return map;
479
+ const parsed = parse(map);
480
+ const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
481
+ this.version = version;
482
+ this.file = file;
483
+ this.names = names || [];
484
+ this.sourceRoot = sourceRoot;
485
+ this.sources = sources;
486
+ this.sourcesContent = sourcesContent;
487
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
488
+ const resolve = resolver(mapUrl, sourceRoot);
489
+ this.resolvedSources = sources.map(resolve);
490
+ const { mappings } = parsed;
491
+ if (typeof mappings === "string") {
492
+ this._encoded = mappings;
493
+ this._decoded = void 0;
494
+ } else if (Array.isArray(mappings)) {
495
+ this._encoded = void 0;
496
+ this._decoded = maybeSort(mappings, isString);
497
+ } else if (parsed.sections) {
498
+ throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
499
+ } else {
500
+ throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
501
+ }
502
+ this._decodedMemo = memoizedState();
503
+ this._bySources = void 0;
504
+ this._bySourceMemos = void 0;
505
+ }
506
+ };
534
507
  function cast(map) {
535
- return map;
508
+ return map;
536
509
  }
537
- /**
538
- * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
539
- */
540
510
  function decodedMappings(map) {
541
- var _a;
542
- return ((_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded)));
511
+ var _a;
512
+ return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
543
513
  }
544
- /**
545
- * A higher-level API to find the source/line/column associated with a generated line/column
546
- * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
547
- * `source-map` library.
548
- */
549
514
  function originalPositionFor(map, needle) {
550
- let { line, column, bias } = needle;
551
- line--;
552
- if (line < 0)
553
- throw new Error(LINE_GTR_ZERO);
554
- if (column < 0)
555
- throw new Error(COL_GTR_EQ_ZERO);
556
- const decoded = decodedMappings(map);
557
- // It's common for parent source maps to have pointers to lines that have no
558
- // mapping (like a "//# sourceMappingURL=") at the end of the child file.
559
- if (line >= decoded.length)
560
- return OMapping(null, null, null, null);
561
- const segments = decoded[line];
562
- const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
563
- if (index === -1)
564
- return OMapping(null, null, null, null);
565
- const segment = segments[index];
566
- if (segment.length === 1)
567
- return OMapping(null, null, null, null);
568
- const { names, resolvedSources } = map;
569
- return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
515
+ let { line, column, bias } = needle;
516
+ line--;
517
+ if (line < 0) throw new Error(LINE_GTR_ZERO);
518
+ if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
519
+ const decoded = decodedMappings(map);
520
+ if (line >= decoded.length) return OMapping(null, null, null, null);
521
+ const segments = decoded[line];
522
+ const index = traceSegmentInternal(
523
+ segments,
524
+ cast(map)._decodedMemo,
525
+ line,
526
+ column,
527
+ bias || GREATEST_LOWER_BOUND
528
+ );
529
+ if (index === -1) return OMapping(null, null, null, null);
530
+ const segment = segments[index];
531
+ if (segment.length === 1) return OMapping(null, null, null, null);
532
+ const { names, resolvedSources } = map;
533
+ return OMapping(
534
+ resolvedSources[segment[SOURCES_INDEX]],
535
+ segment[SOURCE_LINE] + 1,
536
+ segment[SOURCE_COLUMN],
537
+ segment.length === 5 ? names[segment[NAMES_INDEX]] : null
538
+ );
570
539
  }
571
540
  function OMapping(source, line, column, name) {
572
- return { source, line, column, name };
541
+ return { source, line, column, name };
573
542
  }
574
543
  function traceSegmentInternal(segments, memo, line, column, bias) {
575
- let index = memoizedBinarySearch(segments, column, memo, line);
576
- if (found) {
577
- index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
578
- }
579
- else if (bias === LEAST_UPPER_BOUND)
580
- index++;
581
- if (index === -1 || index === segments.length)
582
- return -1;
583
- return index;
544
+ let index = memoizedBinarySearch(segments, column, memo, line);
545
+ if (found) {
546
+ index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
547
+ } else if (bias === LEAST_UPPER_BOUND) index++;
548
+ if (index === -1 || index === segments.length) return -1;
549
+ return index;
584
550
  }
585
551
 
586
552
  // Only install once if called multiple times
@@ -1,13 +1,13 @@
1
1
  import { TransformResult } from 'vite';
2
- import { E as EncodedSourceMap } from './trace-mapping.d-DLVdEqOp.js';
2
+ import { E as EncodedSourceMap } from './trace-mapping.d-BWFx6tPc.js';
3
3
 
4
4
  interface InstallSourceMapSupportOptions {
5
5
  getSourceMap: (source: string) => EncodedSourceMap | null | undefined;
6
6
  }
7
7
  declare function withInlineSourcemap(result: TransformResult, options: {
8
- root: string
9
- filepath: string
10
- noFirstLineMapping?: boolean
8
+ root: string;
9
+ filepath: string;
10
+ noFirstLineMapping?: boolean;
11
11
  }): TransformResult;
12
12
  declare function extractSourceMap(code: string): EncodedSourceMap | null;
13
13
  declare function installSourcemapsSupport(options: InstallSourceMapSupportOptions): void;
@@ -1,4 +1,4 @@
1
- import { isAbsolute, resolve as resolve$2, relative, dirname } from 'pathe';
1
+ import { isAbsolute, resolve as resolve$1, relative, dirname } from 'pathe';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { withTrailingSlash } from './utils.mjs';
@@ -287,7 +287,7 @@ function normalizePath(url, type) {
287
287
  /**
288
288
  * Attempts to resolve `input` URL/path relative to `base`.
289
289
  */
290
- function resolve$1(input, base) {
290
+ function resolve(input, base) {
291
291
  if (!input && !base)
292
292
  return '';
293
293
  const url = parseUrl(input);
@@ -347,238 +347,204 @@ function resolve$1(input, base) {
347
347
  }
348
348
  }
349
349
 
350
- function resolve(input, base) {
351
- // The base is always treated as a directory, if it's not empty.
352
- // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
353
- // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
354
- if (base && !base.endsWith('/'))
355
- base += '/';
356
- return resolve$1(input, base);
357
- }
350
+ // src/trace-mapping.ts
358
351
 
359
- /**
360
- * Removes everything after the last "/", but leaves the slash.
361
- */
352
+ // src/strip-filename.ts
362
353
  function stripFilename(path) {
363
- if (!path)
364
- return '';
365
- const index = path.lastIndexOf('/');
366
- return path.slice(0, index + 1);
354
+ if (!path) return "";
355
+ const index = path.lastIndexOf("/");
356
+ return path.slice(0, index + 1);
367
357
  }
368
358
 
369
- const COLUMN = 0;
370
- const SOURCES_INDEX = 1;
371
- const SOURCE_LINE = 2;
372
- const SOURCE_COLUMN = 3;
373
- const NAMES_INDEX = 4;
359
+ // src/resolve.ts
360
+ function resolver(mapUrl, sourceRoot) {
361
+ const from = stripFilename(mapUrl);
362
+ const prefix = sourceRoot ? sourceRoot + "/" : "";
363
+ return (source) => resolve(prefix + (source || ""), from);
364
+ }
374
365
 
366
+ // src/sourcemap-segment.ts
367
+ var COLUMN = 0;
368
+ var SOURCES_INDEX = 1;
369
+ var SOURCE_LINE = 2;
370
+ var SOURCE_COLUMN = 3;
371
+ var NAMES_INDEX = 4;
372
+
373
+ // src/sort.ts
375
374
  function maybeSort(mappings, owned) {
376
- const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
377
- if (unsortedIndex === mappings.length)
378
- return mappings;
379
- // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If
380
- // not, we do not want to modify the consumer's input array.
381
- if (!owned)
382
- mappings = mappings.slice();
383
- for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
384
- mappings[i] = sortSegments(mappings[i], owned);
385
- }
386
- return mappings;
375
+ const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
376
+ if (unsortedIndex === mappings.length) return mappings;
377
+ if (!owned) mappings = mappings.slice();
378
+ for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
379
+ mappings[i] = sortSegments(mappings[i], owned);
380
+ }
381
+ return mappings;
387
382
  }
388
383
  function nextUnsortedSegmentLine(mappings, start) {
389
- for (let i = start; i < mappings.length; i++) {
390
- if (!isSorted(mappings[i]))
391
- return i;
392
- }
393
- return mappings.length;
384
+ for (let i = start; i < mappings.length; i++) {
385
+ if (!isSorted(mappings[i])) return i;
386
+ }
387
+ return mappings.length;
394
388
  }
395
389
  function isSorted(line) {
396
- for (let j = 1; j < line.length; j++) {
397
- if (line[j][COLUMN] < line[j - 1][COLUMN]) {
398
- return false;
399
- }
390
+ for (let j = 1; j < line.length; j++) {
391
+ if (line[j][COLUMN] < line[j - 1][COLUMN]) {
392
+ return false;
400
393
  }
401
- return true;
394
+ }
395
+ return true;
402
396
  }
403
397
  function sortSegments(line, owned) {
404
- if (!owned)
405
- line = line.slice();
406
- return line.sort(sortComparator);
398
+ if (!owned) line = line.slice();
399
+ return line.sort(sortComparator);
407
400
  }
408
401
  function sortComparator(a, b) {
409
- return a[COLUMN] - b[COLUMN];
402
+ return a[COLUMN] - b[COLUMN];
410
403
  }
411
404
 
412
- let found = false;
413
- /**
414
- * A binary search implementation that returns the index if a match is found.
415
- * If no match is found, then the left-index (the index associated with the item that comes just
416
- * before the desired index) is returned. To maintain proper sort order, a splice would happen at
417
- * the next index:
418
- *
419
- * ```js
420
- * const array = [1, 3];
421
- * const needle = 2;
422
- * const index = binarySearch(array, needle, (item, needle) => item - needle);
423
- *
424
- * assert.equal(index, 0);
425
- * array.splice(index + 1, 0, needle);
426
- * assert.deepEqual(array, [1, 2, 3]);
427
- * ```
428
- */
405
+ // src/binary-search.ts
406
+ var found = false;
429
407
  function binarySearch(haystack, needle, low, high) {
430
- while (low <= high) {
431
- const mid = low + ((high - low) >> 1);
432
- const cmp = haystack[mid][COLUMN] - needle;
433
- if (cmp === 0) {
434
- found = true;
435
- return mid;
436
- }
437
- if (cmp < 0) {
438
- low = mid + 1;
439
- }
440
- else {
441
- high = mid - 1;
442
- }
408
+ while (low <= high) {
409
+ const mid = low + (high - low >> 1);
410
+ const cmp = haystack[mid][COLUMN] - needle;
411
+ if (cmp === 0) {
412
+ found = true;
413
+ return mid;
443
414
  }
444
- found = false;
445
- return low - 1;
415
+ if (cmp < 0) {
416
+ low = mid + 1;
417
+ } else {
418
+ high = mid - 1;
419
+ }
420
+ }
421
+ found = false;
422
+ return low - 1;
446
423
  }
447
424
  function upperBound(haystack, needle, index) {
448
- for (let i = index + 1; i < haystack.length; index = i++) {
449
- if (haystack[i][COLUMN] !== needle)
450
- break;
451
- }
452
- return index;
425
+ for (let i = index + 1; i < haystack.length; index = i++) {
426
+ if (haystack[i][COLUMN] !== needle) break;
427
+ }
428
+ return index;
453
429
  }
454
430
  function lowerBound(haystack, needle, index) {
455
- for (let i = index - 1; i >= 0; index = i--) {
456
- if (haystack[i][COLUMN] !== needle)
457
- break;
458
- }
459
- return index;
431
+ for (let i = index - 1; i >= 0; index = i--) {
432
+ if (haystack[i][COLUMN] !== needle) break;
433
+ }
434
+ return index;
460
435
  }
461
436
  function memoizedState() {
462
- return {
463
- lastKey: -1,
464
- lastNeedle: -1,
465
- lastIndex: -1,
466
- };
437
+ return {
438
+ lastKey: -1,
439
+ lastNeedle: -1,
440
+ lastIndex: -1
441
+ };
467
442
  }
468
- /**
469
- * This overly complicated beast is just to record the last tested line/column and the resulting
470
- * index, allowing us to skip a few tests if mappings are monotonically increasing.
471
- */
472
443
  function memoizedBinarySearch(haystack, needle, state, key) {
473
- const { lastKey, lastNeedle, lastIndex } = state;
474
- let low = 0;
475
- let high = haystack.length - 1;
476
- if (key === lastKey) {
477
- if (needle === lastNeedle) {
478
- found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
479
- return lastIndex;
480
- }
481
- if (needle >= lastNeedle) {
482
- // lastIndex may be -1 if the previous needle was not found.
483
- low = lastIndex === -1 ? 0 : lastIndex;
484
- }
485
- else {
486
- high = lastIndex;
487
- }
444
+ const { lastKey, lastNeedle, lastIndex } = state;
445
+ let low = 0;
446
+ let high = haystack.length - 1;
447
+ if (key === lastKey) {
448
+ if (needle === lastNeedle) {
449
+ found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
450
+ return lastIndex;
451
+ }
452
+ if (needle >= lastNeedle) {
453
+ low = lastIndex === -1 ? 0 : lastIndex;
454
+ } else {
455
+ high = lastIndex;
488
456
  }
489
- state.lastKey = key;
490
- state.lastNeedle = needle;
491
- return (state.lastIndex = binarySearch(haystack, needle, low, high));
457
+ }
458
+ state.lastKey = key;
459
+ state.lastNeedle = needle;
460
+ return state.lastIndex = binarySearch(haystack, needle, low, high);
492
461
  }
493
462
 
494
- const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
495
- const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
496
- const LEAST_UPPER_BOUND = -1;
497
- const GREATEST_LOWER_BOUND = 1;
498
- class TraceMap {
499
- constructor(map, mapUrl) {
500
- const isString = typeof map === 'string';
501
- if (!isString && map._decodedMemo)
502
- return map;
503
- const parsed = (isString ? JSON.parse(map) : map);
504
- const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
505
- this.version = version;
506
- this.file = file;
507
- this.names = names || [];
508
- this.sourceRoot = sourceRoot;
509
- this.sources = sources;
510
- this.sourcesContent = sourcesContent;
511
- this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
512
- const from = resolve(sourceRoot || '', stripFilename(mapUrl));
513
- this.resolvedSources = sources.map((s) => resolve(s || '', from));
514
- const { mappings } = parsed;
515
- if (typeof mappings === 'string') {
516
- this._encoded = mappings;
517
- this._decoded = undefined;
518
- }
519
- else {
520
- this._encoded = undefined;
521
- this._decoded = maybeSort(mappings, isString);
522
- }
523
- this._decodedMemo = memoizedState();
524
- this._bySources = undefined;
525
- this._bySourceMemos = undefined;
526
- }
463
+ // src/types.ts
464
+ function parse(map) {
465
+ return typeof map === "string" ? JSON.parse(map) : map;
527
466
  }
528
- /**
529
- * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
530
- * with public access modifiers.
531
- */
467
+
468
+ // src/trace-mapping.ts
469
+ var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
470
+ var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
471
+ var LEAST_UPPER_BOUND = -1;
472
+ var GREATEST_LOWER_BOUND = 1;
473
+ var TraceMap = class {
474
+ constructor(map, mapUrl) {
475
+ const isString = typeof map === "string";
476
+ if (!isString && map._decodedMemo) return map;
477
+ const parsed = parse(map);
478
+ const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
479
+ this.version = version;
480
+ this.file = file;
481
+ this.names = names || [];
482
+ this.sourceRoot = sourceRoot;
483
+ this.sources = sources;
484
+ this.sourcesContent = sourcesContent;
485
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
486
+ const resolve = resolver(mapUrl, sourceRoot);
487
+ this.resolvedSources = sources.map(resolve);
488
+ const { mappings } = parsed;
489
+ if (typeof mappings === "string") {
490
+ this._encoded = mappings;
491
+ this._decoded = void 0;
492
+ } else if (Array.isArray(mappings)) {
493
+ this._encoded = void 0;
494
+ this._decoded = maybeSort(mappings, isString);
495
+ } else if (parsed.sections) {
496
+ throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
497
+ } else {
498
+ throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
499
+ }
500
+ this._decodedMemo = memoizedState();
501
+ this._bySources = void 0;
502
+ this._bySourceMemos = void 0;
503
+ }
504
+ };
532
505
  function cast(map) {
533
- return map;
506
+ return map;
534
507
  }
535
- /**
536
- * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
537
- */
538
508
  function decodedMappings(map) {
539
- var _a;
540
- return ((_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded)));
509
+ var _a;
510
+ return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
541
511
  }
542
- /**
543
- * A higher-level API to find the source/line/column associated with a generated line/column
544
- * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
545
- * `source-map` library.
546
- */
547
512
  function originalPositionFor(map, needle) {
548
- let { line, column, bias } = needle;
549
- line--;
550
- if (line < 0)
551
- throw new Error(LINE_GTR_ZERO);
552
- if (column < 0)
553
- throw new Error(COL_GTR_EQ_ZERO);
554
- const decoded = decodedMappings(map);
555
- // It's common for parent source maps to have pointers to lines that have no
556
- // mapping (like a "//# sourceMappingURL=") at the end of the child file.
557
- if (line >= decoded.length)
558
- return OMapping(null, null, null, null);
559
- const segments = decoded[line];
560
- const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
561
- if (index === -1)
562
- return OMapping(null, null, null, null);
563
- const segment = segments[index];
564
- if (segment.length === 1)
565
- return OMapping(null, null, null, null);
566
- const { names, resolvedSources } = map;
567
- return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
513
+ let { line, column, bias } = needle;
514
+ line--;
515
+ if (line < 0) throw new Error(LINE_GTR_ZERO);
516
+ if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
517
+ const decoded = decodedMappings(map);
518
+ if (line >= decoded.length) return OMapping(null, null, null, null);
519
+ const segments = decoded[line];
520
+ const index = traceSegmentInternal(
521
+ segments,
522
+ cast(map)._decodedMemo,
523
+ line,
524
+ column,
525
+ bias || GREATEST_LOWER_BOUND
526
+ );
527
+ if (index === -1) return OMapping(null, null, null, null);
528
+ const segment = segments[index];
529
+ if (segment.length === 1) return OMapping(null, null, null, null);
530
+ const { names, resolvedSources } = map;
531
+ return OMapping(
532
+ resolvedSources[segment[SOURCES_INDEX]],
533
+ segment[SOURCE_LINE] + 1,
534
+ segment[SOURCE_COLUMN],
535
+ segment.length === 5 ? names[segment[NAMES_INDEX]] : null
536
+ );
568
537
  }
569
538
  function OMapping(source, line, column, name) {
570
- return { source, line, column, name };
539
+ return { source, line, column, name };
571
540
  }
572
541
  function traceSegmentInternal(segments, memo, line, column, bias) {
573
- let index = memoizedBinarySearch(segments, column, memo, line);
574
- if (found) {
575
- index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
576
- }
577
- else if (bias === LEAST_UPPER_BOUND)
578
- index++;
579
- if (index === -1 || index === segments.length)
580
- return -1;
581
- return index;
542
+ let index = memoizedBinarySearch(segments, column, memo, line);
543
+ if (found) {
544
+ index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
545
+ } else if (bias === LEAST_UPPER_BOUND) index++;
546
+ if (index === -1 || index === segments.length) return -1;
547
+ return index;
582
548
  }
583
549
 
584
550
  // Only install once if called multiple times
@@ -932,7 +898,7 @@ function withInlineSourcemap(result, options) {
932
898
  // this is a bug in Vite
933
899
  // all files should be either absolute to the file system or relative to the source map file
934
900
  if (isAbsolute(source)) {
935
- const actualPath = !source.startsWith(withTrailingSlash(options.root)) && source.startsWith("/") ? resolve$2(options.root, source.slice(1)) : source;
901
+ const actualPath = !source.startsWith(withTrailingSlash(options.root)) && source.startsWith("/") ? resolve$1(options.root, source.slice(1)) : source;
936
902
  return relative(dirname(options.filepath), actualPath);
937
903
  }
938
904
  return source;
@@ -36,6 +36,11 @@ declare abstract class SourceMap {
36
36
  resolvedSources: SourceMapV3['sources'];
37
37
  ignoreList: SourceMapV3['ignoreList'];
38
38
  }
39
+ 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;
40
+ type RoArray<T> = Ro<T>[];
41
+ type RoObject<T> = {
42
+ [K in keyof T]: T[K] | Ro<T[K]>;
43
+ };
39
44
 
40
45
  declare class TraceMap implements SourceMap {
41
46
  version: SourceMapV3['version'];
@@ -51,7 +56,7 @@ declare class TraceMap implements SourceMap {
51
56
  private _decodedMemo;
52
57
  private _bySources;
53
58
  private _bySourceMemos;
54
- constructor(map: SourceMapInput, mapUrl?: string | null);
59
+ constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
55
60
  }
56
61
 
57
62
  export type { DecodedSourceMap as D, EncodedSourceMap as E, SourceMapInput as S };
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-DLVdEqOp.js';
2
- export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-DGmxD2U7.js';
1
+ export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-BWFx6tPc.js';
2
+ export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-CvIJUDRh.js';
package/dist/utils.cjs CHANGED
@@ -8,8 +8,8 @@ var pathe = require('pathe');
8
8
  const isWindows = process.platform === "win32";
9
9
  const drive = isWindows ? process.cwd()[0] : null;
10
10
  const driveOpposite = drive ? drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase() : null;
11
- const driveRegexp = drive ? new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
12
- const driveOppositeRegext = driveOpposite ? new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
11
+ const driveRegexp = drive ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
12
+ const driveOppositeRegext = driveOpposite ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
13
13
  function slash(str) {
14
14
  return str.replace(/\\/g, "/");
15
15
  }
@@ -43,7 +43,7 @@ function splitFileAndPostfix(path) {
43
43
  };
44
44
  }
45
45
  const internalRequests = ["@vite/client", "@vite/env"];
46
- const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join("|")})$`);
46
+ const internalRequestRegexp = /* @__PURE__ */ new RegExp(`^/?(?:${internalRequests.join("|")})$`);
47
47
  function isInternalRequest(id) {
48
48
  return internalRequestRegexp.test(id);
49
49
  }
@@ -111,7 +111,7 @@ function toFilePath(id, root) {
111
111
  const NODE_BUILTIN_NAMESPACE = "node:";
112
112
  function isNodeBuiltin(id) {
113
113
  if (prefixedBuiltins.has(id)) return true;
114
- return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(NODE_BUILTIN_NAMESPACE.length) : id);
114
+ return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
115
115
  }
116
116
  /**
117
117
  * Convert `Arrayable<T>` to `Array<T>`
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as Nullable, A as Arrayable } from './index.d-DGmxD2U7.js';
2
- import './trace-mapping.d-DLVdEqOp.js';
1
+ import { N as Nullable, A as Arrayable } from './index.d-CvIJUDRh.js';
2
+ import './trace-mapping.d-BWFx6tPc.js';
3
3
 
4
4
  declare const isWindows: boolean;
5
5
  declare function slash(str: string): string;
@@ -11,8 +11,8 @@ declare function isInternalRequest(id: string): boolean;
11
11
  declare function normalizeModuleId(id: string): string;
12
12
  declare function isPrimitive(v: any): boolean;
13
13
  declare function toFilePath(id: string, root: string): {
14
- path: string
15
- exists: boolean
14
+ path: string;
15
+ exists: boolean;
16
16
  };
17
17
  declare function isNodeBuiltin(id: string): boolean;
18
18
  /**
@@ -26,7 +26,7 @@ declare function setCacheData<T>(cache: Map<string, T>, data: T, basedir: string
26
26
  declare function withTrailingSlash(path: string): string;
27
27
  declare function createImportMetaEnvProxy(): NodeJS.ProcessEnv;
28
28
  declare function findNearestPackageData(basedir: string): Promise<{
29
- type?: "module" | "commonjs"
29
+ type?: "module" | "commonjs";
30
30
  }>;
31
31
 
32
32
  export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, findNearestPackageData, getCachedData, isBareImport, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
package/dist/utils.mjs CHANGED
@@ -6,8 +6,8 @@ import { resolve, join, dirname } from 'pathe';
6
6
  const isWindows = process.platform === "win32";
7
7
  const drive = isWindows ? process.cwd()[0] : null;
8
8
  const driveOpposite = drive ? drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase() : null;
9
- const driveRegexp = drive ? new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
10
- const driveOppositeRegext = driveOpposite ? new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
9
+ const driveRegexp = drive ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
10
+ const driveOppositeRegext = driveOpposite ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
11
11
  function slash(str) {
12
12
  return str.replace(/\\/g, "/");
13
13
  }
@@ -41,7 +41,7 @@ function splitFileAndPostfix(path) {
41
41
  };
42
42
  }
43
43
  const internalRequests = ["@vite/client", "@vite/env"];
44
- const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join("|")})$`);
44
+ const internalRequestRegexp = /* @__PURE__ */ new RegExp(`^/?(?:${internalRequests.join("|")})$`);
45
45
  function isInternalRequest(id) {
46
46
  return internalRequestRegexp.test(id);
47
47
  }
@@ -109,7 +109,7 @@ function toFilePath(id, root) {
109
109
  const NODE_BUILTIN_NAMESPACE = "node:";
110
110
  function isNodeBuiltin(id) {
111
111
  if (prefixedBuiltins.has(id)) return true;
112
- return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(NODE_BUILTIN_NAMESPACE.length) : id);
112
+ return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
113
113
  }
114
114
  /**
115
115
  * Convert `Arrayable<T>` to `Array<T>`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-node",
3
3
  "type": "module",
4
- "version": "4.0.0-beta.2",
4
+ "version": "4.0.0-beta.4",
5
5
  "description": "Vite as Node.js runtime",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -84,7 +84,7 @@
84
84
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0"
85
85
  },
86
86
  "devDependencies": {
87
- "@jridgewell/trace-mapping": "^0.3.25",
87
+ "@jridgewell/trace-mapping": "^0.3.29",
88
88
  "@types/debug": "^4.1.12",
89
89
  "tinyrainbow": "^2.0.0"
90
90
  },