vite-node 1.6.0 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -20,7 +20,7 @@ require('node:url');
20
20
  require('node:vm');
21
21
  require('node:events');
22
22
 
23
- var version = "1.6.0";
23
+ var version = "2.0.0-beta.1";
24
24
 
25
25
  const cli = cac("vite-node");
26
26
  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-O2IrwHKf.js';
2
- import './trace-mapping.d-xyIfZtPm.js';
1
+ import { V as ViteNodeServerOptions } from './index-C38RQo3J.js';
2
+ import './trace-mapping.d-DLVdEqOp.js';
3
3
 
4
4
  interface CliOptions {
5
5
  'root'?: string;
package/dist/cli.mjs CHANGED
@@ -18,7 +18,7 @@ import 'node:url';
18
18
  import 'node:vm';
19
19
  import 'node:events';
20
20
 
21
- var version = "1.6.0";
21
+ var version = "2.0.0-beta.1";
22
22
 
23
23
  const cli = cac("vite-node");
24
24
  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.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-O2IrwHKf.js';
2
- import './trace-mapping.d-xyIfZtPm.js';
1
+ export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-C38RQo3J.js';
2
+ import './trace-mapping.d-DLVdEqOp.js';
package/dist/hmr.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
  import { HMRPayload, Plugin } from 'vite';
3
- import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index-O2IrwHKf.js';
4
- import './trace-mapping.d-xyIfZtPm.js';
3
+ import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index-C38RQo3J.js';
4
+ import './trace-mapping.d-DLVdEqOp.js';
5
5
 
6
6
  type EventType = string | symbol;
7
7
  type Handler<T = unknown> = (event: T) => void;
@@ -1,4 +1,4 @@
1
- import { E as EncodedSourceMap } from './trace-mapping.d-xyIfZtPm.js';
1
+ import { E as EncodedSourceMap } from './trace-mapping.d-DLVdEqOp.js';
2
2
 
3
3
  type HMRPayload =
4
4
  | ConnectedPayload
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-O2IrwHKf.js';
2
- export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-xyIfZtPm.js';
1
+ export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-C38RQo3J.js';
2
+ export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-DLVdEqOp.js';
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
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-O2IrwHKf.js';
3
- import { E as EncodedSourceMap } from './trace-mapping.d-xyIfZtPm.js';
2
+ import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, d as ViteNodeResolveId, F as FetchResult } from './index-C38RQo3J.js';
3
+ import { E as EncodedSourceMap } from './trace-mapping.d-DLVdEqOp.js';
4
4
 
5
5
  declare class Debugger {
6
6
  options: DebuggerOptions;
@@ -479,16 +479,6 @@ const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
479
479
  const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
480
480
  const LEAST_UPPER_BOUND = -1;
481
481
  const GREATEST_LOWER_BOUND = 1;
482
- /**
483
- * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
484
- */
485
- let decodedMappings;
486
- /**
487
- * A higher-level API to find the source/line/column associated with a generated line/column
488
- * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
489
- * `source-map` library.
490
- */
491
- let originalPositionFor;
492
482
  class TraceMap {
493
483
  constructor(map, mapUrl) {
494
484
  const isString = typeof map === 'string';
@@ -502,6 +492,7 @@ class TraceMap {
502
492
  this.sourceRoot = sourceRoot;
503
493
  this.sources = sources;
504
494
  this.sourcesContent = sourcesContent;
495
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
505
496
  const from = resolve(sourceRoot || '', stripFilename(mapUrl));
506
497
  this.resolvedSources = sources.map((s) => resolve(s || '', from));
507
498
  const { mappings } = parsed;
@@ -518,32 +509,47 @@ class TraceMap {
518
509
  this._bySourceMemos = undefined;
519
510
  }
520
511
  }
521
- (() => {
522
- decodedMappings = (map) => {
523
- return (map._decoded || (map._decoded = decode(map._encoded)));
524
- };
525
- originalPositionFor = (map, { line, column, bias }) => {
526
- line--;
527
- if (line < 0)
528
- throw new Error(LINE_GTR_ZERO);
529
- if (column < 0)
530
- throw new Error(COL_GTR_EQ_ZERO);
531
- const decoded = decodedMappings(map);
532
- // It's common for parent source maps to have pointers to lines that have no
533
- // mapping (like a "//# sourceMappingURL=") at the end of the child file.
534
- if (line >= decoded.length)
535
- return OMapping(null, null, null, null);
536
- const segments = decoded[line];
537
- const index = traceSegmentInternal(segments, map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
538
- if (index === -1)
539
- return OMapping(null, null, null, null);
540
- const segment = segments[index];
541
- if (segment.length === 1)
542
- return OMapping(null, null, null, null);
543
- const { names, resolvedSources } = map;
544
- return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
545
- };
546
- })();
512
+ /**
513
+ * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
514
+ * with public access modifiers.
515
+ */
516
+ function cast(map) {
517
+ return map;
518
+ }
519
+ /**
520
+ * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
521
+ */
522
+ function decodedMappings(map) {
523
+ var _a;
524
+ return ((_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded)));
525
+ }
526
+ /**
527
+ * A higher-level API to find the source/line/column associated with a generated line/column
528
+ * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
529
+ * `source-map` library.
530
+ */
531
+ function originalPositionFor(map, needle) {
532
+ let { line, column, bias } = needle;
533
+ line--;
534
+ if (line < 0)
535
+ throw new Error(LINE_GTR_ZERO);
536
+ if (column < 0)
537
+ throw new Error(COL_GTR_EQ_ZERO);
538
+ const decoded = decodedMappings(map);
539
+ // It's common for parent source maps to have pointers to lines that have no
540
+ // mapping (like a "//# sourceMappingURL=") at the end of the child file.
541
+ if (line >= decoded.length)
542
+ return OMapping(null, null, null, null);
543
+ const segments = decoded[line];
544
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
545
+ if (index === -1)
546
+ return OMapping(null, null, null, null);
547
+ const segment = segments[index];
548
+ if (segment.length === 1)
549
+ return OMapping(null, null, null, null);
550
+ const { names, resolvedSources } = map;
551
+ return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
552
+ }
547
553
  function OMapping(source, line, column, name) {
548
554
  return { source, line, column, name };
549
555
  }
@@ -618,8 +624,7 @@ function retrieveSourceMapURL(source) {
618
624
  return null;
619
625
  const re = /(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg;
620
626
  let lastMatch, match;
621
- while (match = re.exec(fileData))
622
- lastMatch = match;
627
+ while (match = re.exec(fileData)) lastMatch = match;
623
628
  if (!lastMatch)
624
629
  return null;
625
630
  return lastMatch[1];
@@ -1,5 +1,5 @@
1
1
  import { TransformResult } from 'vite';
2
- import { E as EncodedSourceMap } from './trace-mapping.d-xyIfZtPm.js';
2
+ import { E as EncodedSourceMap } from './trace-mapping.d-DLVdEqOp.js';
3
3
 
4
4
  interface InstallSourceMapSupportOptions {
5
5
  getSourceMap: (source: string) => EncodedSourceMap | null | undefined;
@@ -477,16 +477,6 @@ const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
477
477
  const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
478
478
  const LEAST_UPPER_BOUND = -1;
479
479
  const GREATEST_LOWER_BOUND = 1;
480
- /**
481
- * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
482
- */
483
- let decodedMappings;
484
- /**
485
- * A higher-level API to find the source/line/column associated with a generated line/column
486
- * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
487
- * `source-map` library.
488
- */
489
- let originalPositionFor;
490
480
  class TraceMap {
491
481
  constructor(map, mapUrl) {
492
482
  const isString = typeof map === 'string';
@@ -500,6 +490,7 @@ class TraceMap {
500
490
  this.sourceRoot = sourceRoot;
501
491
  this.sources = sources;
502
492
  this.sourcesContent = sourcesContent;
493
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
503
494
  const from = resolve(sourceRoot || '', stripFilename(mapUrl));
504
495
  this.resolvedSources = sources.map((s) => resolve(s || '', from));
505
496
  const { mappings } = parsed;
@@ -516,32 +507,47 @@ class TraceMap {
516
507
  this._bySourceMemos = undefined;
517
508
  }
518
509
  }
519
- (() => {
520
- decodedMappings = (map) => {
521
- return (map._decoded || (map._decoded = decode(map._encoded)));
522
- };
523
- originalPositionFor = (map, { line, column, bias }) => {
524
- line--;
525
- if (line < 0)
526
- throw new Error(LINE_GTR_ZERO);
527
- if (column < 0)
528
- throw new Error(COL_GTR_EQ_ZERO);
529
- const decoded = decodedMappings(map);
530
- // It's common for parent source maps to have pointers to lines that have no
531
- // mapping (like a "//# sourceMappingURL=") at the end of the child file.
532
- if (line >= decoded.length)
533
- return OMapping(null, null, null, null);
534
- const segments = decoded[line];
535
- const index = traceSegmentInternal(segments, map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
536
- if (index === -1)
537
- return OMapping(null, null, null, null);
538
- const segment = segments[index];
539
- if (segment.length === 1)
540
- return OMapping(null, null, null, null);
541
- const { names, resolvedSources } = map;
542
- return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
543
- };
544
- })();
510
+ /**
511
+ * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
512
+ * with public access modifiers.
513
+ */
514
+ function cast(map) {
515
+ return map;
516
+ }
517
+ /**
518
+ * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
519
+ */
520
+ function decodedMappings(map) {
521
+ var _a;
522
+ return ((_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded)));
523
+ }
524
+ /**
525
+ * A higher-level API to find the source/line/column associated with a generated line/column
526
+ * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
527
+ * `source-map` library.
528
+ */
529
+ function originalPositionFor(map, needle) {
530
+ let { line, column, bias } = needle;
531
+ line--;
532
+ if (line < 0)
533
+ throw new Error(LINE_GTR_ZERO);
534
+ if (column < 0)
535
+ throw new Error(COL_GTR_EQ_ZERO);
536
+ const decoded = decodedMappings(map);
537
+ // It's common for parent source maps to have pointers to lines that have no
538
+ // mapping (like a "//# sourceMappingURL=") at the end of the child file.
539
+ if (line >= decoded.length)
540
+ return OMapping(null, null, null, null);
541
+ const segments = decoded[line];
542
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
543
+ if (index === -1)
544
+ return OMapping(null, null, null, null);
545
+ const segment = segments[index];
546
+ if (segment.length === 1)
547
+ return OMapping(null, null, null, null);
548
+ const { names, resolvedSources } = map;
549
+ return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
550
+ }
545
551
  function OMapping(source, line, column, name) {
546
552
  return { source, line, column, name };
547
553
  }
@@ -616,8 +622,7 @@ function retrieveSourceMapURL(source) {
616
622
  return null;
617
623
  const re = /(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg;
618
624
  let lastMatch, match;
619
- while (match = re.exec(fileData))
620
- lastMatch = match;
625
+ while (match = re.exec(fileData)) lastMatch = match;
621
626
  if (!lastMatch)
622
627
  return null;
623
628
  return lastMatch[1];
@@ -12,6 +12,7 @@ interface SourceMapV3 {
12
12
  sources: (string | null)[];
13
13
  sourcesContent?: (string | null)[];
14
14
  version: 3;
15
+ ignoreList?: number[];
15
16
  }
16
17
  interface EncodedSourceMap extends SourceMapV3 {
17
18
  mappings: string;
@@ -19,7 +20,12 @@ interface EncodedSourceMap extends SourceMapV3 {
19
20
  interface DecodedSourceMap extends SourceMapV3 {
20
21
  mappings: SourceMapSegment[][];
21
22
  }
22
- type SourceMapInput = string | Ro<EncodedSourceMap> | Ro<DecodedSourceMap> | TraceMap;
23
+ type XInput = {
24
+ x_google_ignoreList?: SourceMapV3['ignoreList'];
25
+ };
26
+ type EncodedSourceMapXInput = EncodedSourceMap & XInput;
27
+ type DecodedSourceMapXInput = DecodedSourceMap & XInput;
28
+ type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap;
23
29
  declare abstract class SourceMap {
24
30
  version: SourceMapV3['version'];
25
31
  file: SourceMapV3['file'];
@@ -28,12 +34,8 @@ declare abstract class SourceMap {
28
34
  sources: SourceMapV3['sources'];
29
35
  sourcesContent: SourceMapV3['sourcesContent'];
30
36
  resolvedSources: SourceMapV3['sources'];
37
+ ignoreList: SourceMapV3['ignoreList'];
31
38
  }
32
- 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;
33
- type RoArray<T> = Ro<T>[];
34
- type RoObject<T> = {
35
- [K in keyof T]: T[K] | Ro<T[K]>;
36
- };
37
39
 
38
40
  declare class TraceMap implements SourceMap {
39
41
  version: SourceMapV3['version'];
@@ -42,6 +44,7 @@ declare class TraceMap implements SourceMap {
42
44
  sourceRoot: SourceMapV3['sourceRoot'];
43
45
  sources: SourceMapV3['sources'];
44
46
  sourcesContent: SourceMapV3['sourcesContent'];
47
+ ignoreList: SourceMapV3['ignoreList'];
45
48
  resolvedSources: string[];
46
49
  private _encoded;
47
50
  private _decoded;
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-O2IrwHKf.js';
2
- export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-xyIfZtPm.js';
1
+ export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-C38RQo3J.js';
2
+ export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-DLVdEqOp.js';
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as Nullable, A as Arrayable } from './index-O2IrwHKf.js';
2
- import './trace-mapping.d-xyIfZtPm.js';
1
+ import { N as Nullable, A as Arrayable } from './index-C38RQo3J.js';
2
+ import './trace-mapping.d-DLVdEqOp.js';
3
3
 
4
4
  declare const isWindows: boolean;
5
5
  declare function slash(str: string): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-node",
3
3
  "type": "module",
4
- "version": "1.6.0",
4
+ "version": "2.0.0-beta.1",
5
5
  "description": "Vite as Node.js runtime",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -79,12 +79,12 @@
79
79
  "dependencies": {
80
80
  "cac": "^6.7.14",
81
81
  "debug": "^4.3.4",
82
- "pathe": "^1.1.1",
82
+ "pathe": "^1.1.2",
83
83
  "picocolors": "^1.0.0",
84
84
  "vite": "^5.0.0"
85
85
  },
86
86
  "devDependencies": {
87
- "@jridgewell/trace-mapping": "^0.3.22",
87
+ "@jridgewell/trace-mapping": "^0.3.25",
88
88
  "@types/debug": "^4.1.12"
89
89
  },
90
90
  "scripts": {