vite-node 1.5.3 → 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 +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.mjs +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/hmr.d.ts +2 -2
- package/dist/{index-O2IrwHKf.d.ts → index-C38RQo3J.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/server.cjs +21 -4
- package/dist/server.d.ts +5 -2
- package/dist/server.mjs +21 -4
- package/dist/source-map.cjs +43 -38
- package/dist/source-map.d.ts +1 -1
- package/dist/source-map.mjs +43 -38
- package/dist/{trace-mapping.d-xyIfZtPm.d.ts → trace-mapping.d-DLVdEqOp.d.ts} +9 -6
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +3 -3
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 = "
|
|
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
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 = "
|
|
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-
|
|
2
|
-
import './trace-mapping.d-
|
|
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-
|
|
4
|
-
import './trace-mapping.d-
|
|
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;
|
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-
|
|
2
|
-
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-
|
|
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.cjs
CHANGED
|
@@ -243,6 +243,10 @@ class ViteNodeServer {
|
|
|
243
243
|
ssr: /* @__PURE__ */ new Map(),
|
|
244
244
|
web: /* @__PURE__ */ new Map()
|
|
245
245
|
};
|
|
246
|
+
durations = {
|
|
247
|
+
ssr: /* @__PURE__ */ new Map(),
|
|
248
|
+
web: /* @__PURE__ */ new Map()
|
|
249
|
+
};
|
|
246
250
|
existingOptimizedDeps = /* @__PURE__ */ new Set();
|
|
247
251
|
fetchCaches = {
|
|
248
252
|
ssr: /* @__PURE__ */ new Map(),
|
|
@@ -254,6 +258,11 @@ class ViteNodeServer {
|
|
|
254
258
|
shouldExternalize(id) {
|
|
255
259
|
return shouldExternalize(id, this.options.deps, this.externalizeCache);
|
|
256
260
|
}
|
|
261
|
+
getTotalDuration() {
|
|
262
|
+
const ssrDurations = [...this.durations.ssr.values()].flat();
|
|
263
|
+
const webDurations = [...this.durations.web.values()].flat();
|
|
264
|
+
return [...ssrDurations, ...webDurations].reduce((a, b) => a + b, 0);
|
|
265
|
+
}
|
|
257
266
|
async ensureExists(id) {
|
|
258
267
|
if (this.existingOptimizedDeps.has(id))
|
|
259
268
|
return true;
|
|
@@ -287,14 +296,17 @@ class ViteNodeServer {
|
|
|
287
296
|
assert(mode === "web" || mode === "ssr", `"transformMode" can only be "web" or "ssr", received "${mode}".`);
|
|
288
297
|
}
|
|
289
298
|
async fetchModule(id, transformMode) {
|
|
290
|
-
const moduleId = utils.normalizeModuleId(id);
|
|
291
299
|
const mode = transformMode || this.getTransformMode(id);
|
|
300
|
+
return this.fetchResult(id, mode).then((r) => {
|
|
301
|
+
return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
async fetchResult(id, mode) {
|
|
305
|
+
const moduleId = utils.normalizeModuleId(id);
|
|
292
306
|
this.assertMode(mode);
|
|
293
307
|
const promiseMap = this.fetchPromiseMap[mode];
|
|
294
308
|
if (!promiseMap.has(moduleId)) {
|
|
295
|
-
promiseMap.set(moduleId, this._fetchModule(moduleId, mode).
|
|
296
|
-
return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
|
|
297
|
-
}).finally(() => {
|
|
309
|
+
promiseMap.set(moduleId, this._fetchModule(moduleId, mode).finally(() => {
|
|
298
310
|
promiseMap.delete(moduleId);
|
|
299
311
|
}));
|
|
300
312
|
}
|
|
@@ -387,6 +399,11 @@ class ViteNodeServer {
|
|
|
387
399
|
timestamp: time,
|
|
388
400
|
result
|
|
389
401
|
};
|
|
402
|
+
const durations = this.durations[transformMode].get(filePath) || [];
|
|
403
|
+
this.durations[transformMode].set(
|
|
404
|
+
filePath,
|
|
405
|
+
[...durations, duration ?? 0]
|
|
406
|
+
);
|
|
390
407
|
this.fetchCaches[transformMode].set(filePath, cacheEntry);
|
|
391
408
|
this.fetchCache.set(filePath, cacheEntry);
|
|
392
409
|
return result;
|
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-
|
|
3
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-
|
|
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;
|
|
@@ -29,6 +29,7 @@ declare class ViteNodeServer {
|
|
|
29
29
|
options: ViteNodeServerOptions;
|
|
30
30
|
private fetchPromiseMap;
|
|
31
31
|
private transformPromiseMap;
|
|
32
|
+
private durations;
|
|
32
33
|
private existingOptimizedDeps;
|
|
33
34
|
fetchCaches: {
|
|
34
35
|
ssr: Map<string, FetchCache>;
|
|
@@ -39,11 +40,13 @@ declare class ViteNodeServer {
|
|
|
39
40
|
debugger?: Debugger;
|
|
40
41
|
constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
|
|
41
42
|
shouldExternalize(id: string): Promise<string | false>;
|
|
43
|
+
getTotalDuration(): number;
|
|
42
44
|
private ensureExists;
|
|
43
45
|
resolveId(id: string, importer?: string, transformMode?: 'web' | 'ssr'): Promise<ViteNodeResolveId | null>;
|
|
44
46
|
getSourceMap(source: string): EncodedSourceMap | null;
|
|
45
47
|
private assertMode;
|
|
46
48
|
fetchModule(id: string, transformMode?: 'web' | 'ssr'): Promise<FetchResult>;
|
|
49
|
+
fetchResult(id: string, mode: 'web' | 'ssr'): Promise<FetchResult>;
|
|
47
50
|
transformRequest(id: string, filepath?: string, transformMode?: 'web' | 'ssr'): Promise<TransformResult | null | undefined>;
|
|
48
51
|
transformModule(id: string, transformMode?: 'web' | 'ssr'): Promise<{
|
|
49
52
|
code: string | undefined;
|
package/dist/server.mjs
CHANGED
|
@@ -241,6 +241,10 @@ class ViteNodeServer {
|
|
|
241
241
|
ssr: /* @__PURE__ */ new Map(),
|
|
242
242
|
web: /* @__PURE__ */ new Map()
|
|
243
243
|
};
|
|
244
|
+
durations = {
|
|
245
|
+
ssr: /* @__PURE__ */ new Map(),
|
|
246
|
+
web: /* @__PURE__ */ new Map()
|
|
247
|
+
};
|
|
244
248
|
existingOptimizedDeps = /* @__PURE__ */ new Set();
|
|
245
249
|
fetchCaches = {
|
|
246
250
|
ssr: /* @__PURE__ */ new Map(),
|
|
@@ -252,6 +256,11 @@ class ViteNodeServer {
|
|
|
252
256
|
shouldExternalize(id) {
|
|
253
257
|
return shouldExternalize(id, this.options.deps, this.externalizeCache);
|
|
254
258
|
}
|
|
259
|
+
getTotalDuration() {
|
|
260
|
+
const ssrDurations = [...this.durations.ssr.values()].flat();
|
|
261
|
+
const webDurations = [...this.durations.web.values()].flat();
|
|
262
|
+
return [...ssrDurations, ...webDurations].reduce((a, b) => a + b, 0);
|
|
263
|
+
}
|
|
255
264
|
async ensureExists(id) {
|
|
256
265
|
if (this.existingOptimizedDeps.has(id))
|
|
257
266
|
return true;
|
|
@@ -285,14 +294,17 @@ class ViteNodeServer {
|
|
|
285
294
|
assert(mode === "web" || mode === "ssr", `"transformMode" can only be "web" or "ssr", received "${mode}".`);
|
|
286
295
|
}
|
|
287
296
|
async fetchModule(id, transformMode) {
|
|
288
|
-
const moduleId = normalizeModuleId(id);
|
|
289
297
|
const mode = transformMode || this.getTransformMode(id);
|
|
298
|
+
return this.fetchResult(id, mode).then((r) => {
|
|
299
|
+
return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
async fetchResult(id, mode) {
|
|
303
|
+
const moduleId = normalizeModuleId(id);
|
|
290
304
|
this.assertMode(mode);
|
|
291
305
|
const promiseMap = this.fetchPromiseMap[mode];
|
|
292
306
|
if (!promiseMap.has(moduleId)) {
|
|
293
|
-
promiseMap.set(moduleId, this._fetchModule(moduleId, mode).
|
|
294
|
-
return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
|
|
295
|
-
}).finally(() => {
|
|
307
|
+
promiseMap.set(moduleId, this._fetchModule(moduleId, mode).finally(() => {
|
|
296
308
|
promiseMap.delete(moduleId);
|
|
297
309
|
}));
|
|
298
310
|
}
|
|
@@ -385,6 +397,11 @@ class ViteNodeServer {
|
|
|
385
397
|
timestamp: time,
|
|
386
398
|
result
|
|
387
399
|
};
|
|
400
|
+
const durations = this.durations[transformMode].get(filePath) || [];
|
|
401
|
+
this.durations[transformMode].set(
|
|
402
|
+
filePath,
|
|
403
|
+
[...durations, duration ?? 0]
|
|
404
|
+
);
|
|
388
405
|
this.fetchCaches[transformMode].set(filePath, cacheEntry);
|
|
389
406
|
this.fetchCache.set(filePath, cacheEntry);
|
|
390
407
|
return result;
|
package/dist/source-map.cjs
CHANGED
|
@@ -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
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
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];
|
package/dist/source-map.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult } from 'vite';
|
|
2
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-
|
|
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;
|
package/dist/source-map.mjs
CHANGED
|
@@ -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
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
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
|
|
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-
|
|
2
|
-
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-
|
|
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-
|
|
2
|
-
import './trace-mapping.d-
|
|
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": "
|
|
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.
|
|
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.
|
|
87
|
+
"@jridgewell/trace-mapping": "^0.3.25",
|
|
88
88
|
"@types/debug": "^4.1.12"
|
|
89
89
|
},
|
|
90
90
|
"scripts": {
|