vite-node 1.0.0-beta.1 → 1.0.0-beta.2
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 +2 -1
- package/dist/cli.d.ts +3 -3
- package/dist/cli.mjs +2 -1
- package/dist/client.d.ts +2 -2
- package/dist/hmr.d.ts +3 -3
- package/dist/{index-6fb787b2.d.ts → index-e4206afe.d.ts} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/server.cjs +6 -0
- package/dist/server.d.ts +3 -2
- package/dist/server.mjs +6 -0
- package/dist/source-map.d.ts +1 -1
- package/dist/{trace-mapping.d-e677e8f4.d.ts → trace-mapping.d-cf594fd7.d.ts} +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -10,6 +10,7 @@ var sourceMap = require('./source-map.cjs');
|
|
|
10
10
|
var hmr = require('./hmr.cjs');
|
|
11
11
|
require('perf_hooks');
|
|
12
12
|
require('fs');
|
|
13
|
+
require('assert');
|
|
13
14
|
require('pathe');
|
|
14
15
|
require('debug');
|
|
15
16
|
require('mlly');
|
|
@@ -20,7 +21,7 @@ require('node:url');
|
|
|
20
21
|
require('node:vm');
|
|
21
22
|
require('node:events');
|
|
22
23
|
|
|
23
|
-
var version = "1.0.0-beta.
|
|
24
|
+
var version = "1.0.0-beta.2";
|
|
24
25
|
|
|
25
26
|
const cli = cac("vite-node");
|
|
26
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-
|
|
2
|
-
import './trace-mapping.d-
|
|
1
|
+
import { V as ViteNodeServerOptions } from './index-e4206afe.js';
|
|
2
|
+
import './trace-mapping.d-cf594fd7.js';
|
|
3
3
|
|
|
4
4
|
interface CliOptions {
|
|
5
5
|
root?: string;
|
|
@@ -18,4 +18,4 @@ type ComputeViteNodeServerOptionsCLI<T extends Record<string, any>> = {
|
|
|
18
18
|
};
|
|
19
19
|
type ViteNodeServerOptionsCLI = ComputeViteNodeServerOptionsCLI<ViteNodeServerOptions>;
|
|
20
20
|
|
|
21
|
-
export { CliOptions, ViteNodeServerOptionsCLI };
|
|
21
|
+
export type { CliOptions, ViteNodeServerOptionsCLI };
|
package/dist/cli.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { installSourcemapsSupport } from './source-map.mjs';
|
|
|
8
8
|
import { viteNodeHmrPlugin, createHotContext, handleMessage } from './hmr.mjs';
|
|
9
9
|
import 'node:perf_hooks';
|
|
10
10
|
import 'node:fs';
|
|
11
|
+
import 'node:assert';
|
|
11
12
|
import 'pathe';
|
|
12
13
|
import 'debug';
|
|
13
14
|
import 'mlly';
|
|
@@ -18,7 +19,7 @@ import 'node:url';
|
|
|
18
19
|
import 'node:vm';
|
|
19
20
|
import 'node:events';
|
|
20
21
|
|
|
21
|
-
var version = "1.0.0-beta.
|
|
22
|
+
var version = "1.0.0-beta.2";
|
|
22
23
|
|
|
23
24
|
const cli = cac("vite-node");
|
|
24
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.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './trace-mapping.d-
|
|
2
|
-
export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-
|
|
1
|
+
import './trace-mapping.d-cf594fd7.js';
|
|
2
|
+
export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-e4206afe.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-e4206afe.js';
|
|
4
|
+
import './trace-mapping.d-cf594fd7.js';
|
|
5
5
|
|
|
6
6
|
type EventType = string | symbol;
|
|
7
7
|
type Handler<T = unknown> = (event: T) => void;
|
|
@@ -52,4 +52,4 @@ declare function reload(runner: ViteNodeRunner, files: string[]): Promise<any[]>
|
|
|
52
52
|
declare function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], payload: HMRPayload$1): Promise<void>;
|
|
53
53
|
declare function createHotContext(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], ownerPath: string): HotContext;
|
|
54
54
|
|
|
55
|
-
export { Emitter, EventType, HMREmitter, Handler, HotCallback, HotModule, InferCustomEventPayload, ModuleNamespace, createHmrEmitter, createHotContext, getCache, handleMessage, reload, sendMessageBuffer, viteNodeHmrPlugin };
|
|
55
|
+
export { type Emitter, type EventType, type HMREmitter, type Handler, type HotCallback, type HotModule, type InferCustomEventPayload, type ModuleNamespace, createHmrEmitter, createHotContext, getCache, handleMessage, reload, sendMessageBuffer, viteNodeHmrPlugin };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-
|
|
1
|
+
import { E as EncodedSourceMap } from './trace-mapping.d-cf594fd7.js';
|
|
2
2
|
|
|
3
3
|
type HMRPayload =
|
|
4
4
|
| ConnectedPayload
|
|
@@ -295,4 +295,4 @@ interface DebuggerOptions {
|
|
|
295
295
|
loadDumppedModules?: boolean;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
export { Arrayable as A, CustomEventMap as C, DebuggerOptions as D, FetchResult as F, HMRPayload as H, ModuleCacheMap as M, Nullable as N, RawSourceMap as R, StartOfSourceMap as S, ViteNodeServerOptions as V, ViteNodeRunner as a, HotContext as b, DepsHandlingOptions as c, ViteNodeResolveId as d, DEFAULT_REQUEST_STUBS as e, Awaitable as f, FetchFunction as g, ResolveIdFunction as h, CreateHotContextFunction as i, ModuleCache as j, ViteNodeRunnerOptions as k };
|
|
298
|
+
export { type Arrayable as A, type CustomEventMap as C, type DebuggerOptions as D, type FetchResult as F, type HMRPayload as H, ModuleCacheMap as M, type Nullable as N, type RawSourceMap as R, type StartOfSourceMap as S, type ViteNodeServerOptions as V, ViteNodeRunner as a, type HotContext as b, type DepsHandlingOptions as c, type ViteNodeResolveId as d, DEFAULT_REQUEST_STUBS as e, type Awaitable as f, type FetchFunction as g, type ResolveIdFunction as h, type CreateHotContextFunction as i, type ModuleCache as j, type ViteNodeRunnerOptions as k };
|
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-e4206afe.js';
|
|
2
|
+
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-cf594fd7.js';
|
package/dist/server.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var perf_hooks = require('perf_hooks');
|
|
4
4
|
var fs = require('fs');
|
|
5
|
+
var assert = require('assert');
|
|
5
6
|
var pathe = require('pathe');
|
|
6
7
|
var createDebug = require('debug');
|
|
7
8
|
var mlly = require('mlly');
|
|
@@ -265,9 +266,13 @@ class ViteNodeServer {
|
|
|
265
266
|
const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? void 0 : _b.ssrTransformResult;
|
|
266
267
|
return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
|
|
267
268
|
}
|
|
269
|
+
assertMode(mode) {
|
|
270
|
+
assert(mode === "web" || mode === "ssr", `"transformMode" can only be "web" or "ssr", received "${mode}".`);
|
|
271
|
+
}
|
|
268
272
|
async fetchModule(id, transformMode) {
|
|
269
273
|
const moduleId = utils.normalizeModuleId(id);
|
|
270
274
|
const mode = transformMode || this.getTransformMode(id);
|
|
275
|
+
this.assertMode(mode);
|
|
271
276
|
const promiseMap = this.fetchPromiseMap[mode];
|
|
272
277
|
if (!promiseMap.has(moduleId)) {
|
|
273
278
|
promiseMap.set(
|
|
@@ -283,6 +288,7 @@ class ViteNodeServer {
|
|
|
283
288
|
}
|
|
284
289
|
async transformRequest(id, filepath = id, transformMode) {
|
|
285
290
|
const mode = transformMode || this.getTransformMode(id);
|
|
291
|
+
this.assertMode(mode);
|
|
286
292
|
const promiseMap = this.transformPromiseMap[mode];
|
|
287
293
|
if (!promiseMap.has(id)) {
|
|
288
294
|
promiseMap.set(
|
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-e4206afe.js';
|
|
3
|
+
import { E as EncodedSourceMap } from './trace-mapping.d-cf594fd7.js';
|
|
4
4
|
|
|
5
5
|
declare class Debugger {
|
|
6
6
|
options: DebuggerOptions;
|
|
@@ -42,6 +42,7 @@ declare class ViteNodeServer {
|
|
|
42
42
|
private ensureExists;
|
|
43
43
|
resolveId(id: string, importer?: string, transformMode?: 'web' | 'ssr'): Promise<ViteNodeResolveId | null>;
|
|
44
44
|
getSourceMap(source: string): EncodedSourceMap | null;
|
|
45
|
+
private assertMode;
|
|
45
46
|
fetchModule(id: string, transformMode?: 'web' | 'ssr'): Promise<FetchResult>;
|
|
46
47
|
transformRequest(id: string, filepath?: string, transformMode?: 'web' | 'ssr'): Promise<TransformResult | null | undefined>;
|
|
47
48
|
transformModule(id: string, transformMode?: 'web' | 'ssr'): Promise<{
|
package/dist/server.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import { existsSync, promises } from 'node:fs';
|
|
3
|
+
import assert from 'node:assert';
|
|
3
4
|
import { join, resolve, relative, normalize } from 'pathe';
|
|
4
5
|
import createDebug from 'debug';
|
|
5
6
|
import { isValidNodeImport } from 'mlly';
|
|
@@ -263,9 +264,13 @@ class ViteNodeServer {
|
|
|
263
264
|
const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? void 0 : _b.ssrTransformResult;
|
|
264
265
|
return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
|
|
265
266
|
}
|
|
267
|
+
assertMode(mode) {
|
|
268
|
+
assert(mode === "web" || mode === "ssr", `"transformMode" can only be "web" or "ssr", received "${mode}".`);
|
|
269
|
+
}
|
|
266
270
|
async fetchModule(id, transformMode) {
|
|
267
271
|
const moduleId = normalizeModuleId(id);
|
|
268
272
|
const mode = transformMode || this.getTransformMode(id);
|
|
273
|
+
this.assertMode(mode);
|
|
269
274
|
const promiseMap = this.fetchPromiseMap[mode];
|
|
270
275
|
if (!promiseMap.has(moduleId)) {
|
|
271
276
|
promiseMap.set(
|
|
@@ -281,6 +286,7 @@ class ViteNodeServer {
|
|
|
281
286
|
}
|
|
282
287
|
async transformRequest(id, filepath = id, transformMode) {
|
|
283
288
|
const mode = transformMode || this.getTransformMode(id);
|
|
289
|
+
this.assertMode(mode);
|
|
284
290
|
const promiseMap = this.transformPromiseMap[mode];
|
|
285
291
|
if (!promiseMap.has(id)) {
|
|
286
292
|
promiseMap.set(
|
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-cf594fd7.js';
|
|
3
3
|
|
|
4
4
|
interface InstallSourceMapSupportOptions {
|
|
5
5
|
getSourceMap: (source: string) => EncodedSourceMap | null | undefined;
|
|
@@ -51,4 +51,4 @@ declare class TraceMap implements SourceMap {
|
|
|
51
51
|
constructor(map: SourceMapInput, mapUrl?: string | null);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export { DecodedSourceMap as D, EncodedSourceMap as E, SourceMapInput as S };
|
|
54
|
+
export type { DecodedSourceMap as D, EncodedSourceMap as E, SourceMapInput as S };
|
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-e4206afe.js';
|
|
2
|
+
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-cf594fd7.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-e4206afe.js';
|
|
2
|
+
import './trace-mapping.d-cf594fd7.js';
|
|
3
3
|
|
|
4
4
|
declare const isWindows: boolean;
|
|
5
5
|
declare function slash(str: string): string;
|