vite-node 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.mts +21 -0
- package/dist/cli.mjs +145 -0
- package/dist/{client.js → client-CyS7w_FB.mjs} +54 -87
- package/dist/client.d.mts +2 -0
- package/dist/client.mjs +5 -0
- package/dist/{constants.js → constants-DRkacFwN.mjs} +3 -1
- package/dist/{constants.d.ts → constants.d.mts} +3 -2
- package/dist/constants.mjs +3 -0
- package/dist/dist-B2ebky9O.mjs +85 -0
- package/dist/{chunk-hmr.js → hmr-qEG3qSgW.mjs} +17 -29
- package/dist/hmr.d.mts +57 -0
- package/dist/hmr.mjs +5 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +3 -0
- package/dist/{server.js → server-BWywEVuB.mjs} +52 -87
- package/dist/server.d.mts +60 -0
- package/dist/server.mjs +7 -0
- package/dist/source-map-DQLD3K8K.mjs +737 -0
- package/dist/{source-map.d.ts → source-map.d.mts} +9 -8
- package/dist/source-map.mjs +4 -0
- package/dist/types-55T_-8KG.mjs +1 -0
- package/dist/types-Dtew7m7O.d.mts +212 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +3 -0
- package/dist/{utils.js → utils-ExLpYVUV.mjs} +10 -18
- package/dist/{utils.d.ts → utils.d.mts} +7 -7
- package/dist/utils.mjs +3 -0
- package/package.json +25 -32
- package/dist/chunk-index.js +0 -82
- package/dist/cli.d.ts +0 -19
- package/dist/cli.js +0 -156
- package/dist/client.d.ts +0 -2
- package/dist/hmr.d.ts +0 -55
- package/dist/hmr.js +0 -10
- package/dist/index.d-D6Pqey3g.d.ts +0 -367
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -1
- package/dist/server.d.ts +0 -58
- package/dist/source-map.js +0 -919
- package/dist/trace-mapping.d-BWFx6tPc.d.ts +0 -62
- package/dist/types.d.ts +0 -2
- package/dist/types.js +0 -1
- package/vite-node.js +0 -2
package/dist/cli.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
|
-
import process from 'node:process';
|
|
3
|
-
import cac from 'cac';
|
|
4
|
-
import { C } from './chunk-index.js';
|
|
5
|
-
import { createServer, version as version$1, loadEnv } from 'vite';
|
|
6
|
-
import { ViteNodeRunner } from './client.js';
|
|
7
|
-
import { ViteNodeServer } from './server.js';
|
|
8
|
-
import { installSourcemapsSupport } from './source-map.js';
|
|
9
|
-
import { toArray } from './utils.js';
|
|
10
|
-
import { v as viteNodeHmrPlugin, a as createHotContext, h as handleMessage } from './chunk-hmr.js';
|
|
11
|
-
import 'node:module';
|
|
12
|
-
import 'node:url';
|
|
13
|
-
import 'node:vm';
|
|
14
|
-
import 'debug';
|
|
15
|
-
import 'node:buffer';
|
|
16
|
-
import 'pathe';
|
|
17
|
-
import 'node:fs';
|
|
18
|
-
import 'node:assert';
|
|
19
|
-
import 'node:perf_hooks';
|
|
20
|
-
import 'es-module-lexer';
|
|
21
|
-
import './constants.js';
|
|
22
|
-
import 'node:events';
|
|
23
|
-
|
|
24
|
-
var version = "5.0.0";
|
|
25
|
-
|
|
26
|
-
const cli = cac("vite-node");
|
|
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");
|
|
28
|
-
cli.command("[...files]").allowUnknownOptions().action(run);
|
|
29
|
-
cli.parse(process.argv, { run: false });
|
|
30
|
-
if (cli.args.length === 0) cli.runMatchedCommand();
|
|
31
|
-
else {
|
|
32
|
-
const i = cli.rawArgs.indexOf(cli.args[0]) + 1;
|
|
33
|
-
const scriptArgs = cli.rawArgs.slice(i).filter((it) => it !== "--");
|
|
34
|
-
const executeArgs = [
|
|
35
|
-
...cli.rawArgs.slice(0, i),
|
|
36
|
-
"--",
|
|
37
|
-
...scriptArgs
|
|
38
|
-
];
|
|
39
|
-
cli.parse(executeArgs);
|
|
40
|
-
}
|
|
41
|
-
async function run(files, options = {}) {
|
|
42
|
-
var _server$emitter;
|
|
43
|
-
if (options.script) {
|
|
44
|
-
files = [files[0]];
|
|
45
|
-
options = {};
|
|
46
|
-
process.argv = [
|
|
47
|
-
process.argv[0],
|
|
48
|
-
resolve(files[0]),
|
|
49
|
-
...process.argv.slice(2).filter((arg) => arg !== "--script" && arg !== files[0])
|
|
50
|
-
];
|
|
51
|
-
} else process.argv = [...process.argv.slice(0, 2), ...options["--"] || []];
|
|
52
|
-
if (options.version) {
|
|
53
|
-
cli.version(version);
|
|
54
|
-
cli.outputVersion();
|
|
55
|
-
process.exit(0);
|
|
56
|
-
}
|
|
57
|
-
if (options.help) {
|
|
58
|
-
cli.version(version).outputHelp();
|
|
59
|
-
process.exit(0);
|
|
60
|
-
}
|
|
61
|
-
if (!files.length) {
|
|
62
|
-
console.error(C.red("No files specified."));
|
|
63
|
-
cli.version(version).outputHelp();
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
const serverOptions = options.options ? parseServerOptions(options.options) : {};
|
|
67
|
-
const server = await createServer({
|
|
68
|
-
logLevel: "error",
|
|
69
|
-
configFile: options.config,
|
|
70
|
-
root: options.root,
|
|
71
|
-
mode: options.mode,
|
|
72
|
-
server: {
|
|
73
|
-
hmr: !!options.watch,
|
|
74
|
-
watch: options.watch ? void 0 : null
|
|
75
|
-
},
|
|
76
|
-
plugins: [options.watch && viteNodeHmrPlugin()]
|
|
77
|
-
});
|
|
78
|
-
if (Number(version$1.split(".")[0]) < 6) await server.pluginContainer.buildStart({});
|
|
79
|
-
else
|
|
80
|
-
// directly access client plugin container until https://github.com/vitejs/vite/issues/19607
|
|
81
|
-
await server.environments.client.pluginContainer.buildStart({});
|
|
82
|
-
const env = loadEnv(server.config.mode, server.config.envDir, "");
|
|
83
|
-
for (const key in env) {
|
|
84
|
-
var _process$env;
|
|
85
|
-
(_process$env = process.env)[key] ?? (_process$env[key] = env[key]);
|
|
86
|
-
}
|
|
87
|
-
const node = new ViteNodeServer(server, serverOptions);
|
|
88
|
-
installSourcemapsSupport({ getSourceMap: (source) => node.getSourceMap(source) });
|
|
89
|
-
const runner = new ViteNodeRunner({
|
|
90
|
-
root: server.config.root,
|
|
91
|
-
base: server.config.base,
|
|
92
|
-
fetchModule(id) {
|
|
93
|
-
return node.fetchModule(id);
|
|
94
|
-
},
|
|
95
|
-
resolveId(id, importer) {
|
|
96
|
-
return node.resolveId(id, importer);
|
|
97
|
-
},
|
|
98
|
-
createHotContext(runner, url) {
|
|
99
|
-
return createHotContext(runner, server.emitter, files, url);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
// provide the vite define variable in this context
|
|
103
|
-
await runner.executeId("/@vite/env");
|
|
104
|
-
for (const file of files) await runner.executeFile(file);
|
|
105
|
-
if (!options.watch) await server.close();
|
|
106
|
-
(_server$emitter = server.emitter) === null || _server$emitter === void 0 || _server$emitter.on("message", (payload) => {
|
|
107
|
-
handleMessage(runner, server.emitter, files, payload);
|
|
108
|
-
});
|
|
109
|
-
if (options.watch) {
|
|
110
|
-
process.on("uncaughtException", (err) => {
|
|
111
|
-
console.error(C.red("[vite-node] Failed to execute file: \n"), err);
|
|
112
|
-
});
|
|
113
|
-
if (process.env.VITE_TEST_WATCHER_DEBUG) {
|
|
114
|
-
// manually check `watcher.getWatched()` to make sure entry files are ready
|
|
115
|
-
// since watcher.on('ready', ...) event is not reliable since 5.1.
|
|
116
|
-
// https://github.com/vitejs/vite/blob/63a39c244b08cf1f2299bc2c3cfddcb82070d05b/playground/hmr-ssr/__tests__/hmr.spec.ts#L1065
|
|
117
|
-
const nodePath = await import('node:path');
|
|
118
|
-
async function waitForWatched(files) {
|
|
119
|
-
while (!files.every((file) => isWatched(file))) await new Promise((resolve) => setTimeout(resolve, 20));
|
|
120
|
-
}
|
|
121
|
-
function isWatched(file) {
|
|
122
|
-
var _watched$dir;
|
|
123
|
-
const watched = server.watcher.getWatched();
|
|
124
|
-
const resolved = nodePath.resolve(file);
|
|
125
|
-
const dir = nodePath.dirname(resolved);
|
|
126
|
-
const base = nodePath.basename(resolved);
|
|
127
|
-
return (_watched$dir = watched[dir]) === null || _watched$dir === void 0 ? void 0 : _watched$dir.includes(base);
|
|
128
|
-
}
|
|
129
|
-
await waitForWatched(files);
|
|
130
|
-
console.log("[debug] watcher is ready");
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function parseServerOptions(serverOptions) {
|
|
135
|
-
var _serverOptions$deps, _serverOptions$deps2, _serverOptions$deps3, _serverOptions$deps4, _serverOptions$deps5, _serverOptions$deps6, _serverOptions$transf, _serverOptions$transf2;
|
|
136
|
-
const inlineOptions = ((_serverOptions$deps = serverOptions.deps) === null || _serverOptions$deps === void 0 ? void 0 : _serverOptions$deps.inline) === true ? true : toArray((_serverOptions$deps2 = serverOptions.deps) === null || _serverOptions$deps2 === void 0 ? void 0 : _serverOptions$deps2.inline);
|
|
137
|
-
return {
|
|
138
|
-
...serverOptions,
|
|
139
|
-
deps: {
|
|
140
|
-
...serverOptions.deps,
|
|
141
|
-
inlineFiles: toArray((_serverOptions$deps3 = serverOptions.deps) === null || _serverOptions$deps3 === void 0 ? void 0 : _serverOptions$deps3.inlineFiles),
|
|
142
|
-
inline: inlineOptions !== true ? inlineOptions.map((dep) => {
|
|
143
|
-
return dep.startsWith("/") && dep.endsWith("/") ? new RegExp(dep) : dep;
|
|
144
|
-
}) : true,
|
|
145
|
-
external: toArray((_serverOptions$deps4 = serverOptions.deps) === null || _serverOptions$deps4 === void 0 ? void 0 : _serverOptions$deps4.external).map((dep) => {
|
|
146
|
-
return dep.startsWith("/") && dep.endsWith("/") ? new RegExp(dep) : dep;
|
|
147
|
-
}),
|
|
148
|
-
moduleDirectories: ((_serverOptions$deps5 = serverOptions.deps) === null || _serverOptions$deps5 === void 0 ? void 0 : _serverOptions$deps5.moduleDirectories) ? toArray((_serverOptions$deps6 = serverOptions.deps) === null || _serverOptions$deps6 === void 0 ? void 0 : _serverOptions$deps6.moduleDirectories) : void 0
|
|
149
|
-
},
|
|
150
|
-
transformMode: {
|
|
151
|
-
...serverOptions.transformMode,
|
|
152
|
-
ssr: toArray((_serverOptions$transf = serverOptions.transformMode) === null || _serverOptions$transf === void 0 ? void 0 : _serverOptions$transf.ssr).map((dep) => new RegExp(dep)),
|
|
153
|
-
web: toArray((_serverOptions$transf2 = serverOptions.transformMode) === null || _serverOptions$transf2 === void 0 ? void 0 : _serverOptions$transf2.web).map((dep) => new RegExp(dep))
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
}
|
package/dist/client.d.ts
DELETED
package/dist/hmr.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { HMRPayload, Plugin } from 'vite';
|
|
2
|
-
import { EventEmitter } from 'node:events';
|
|
3
|
-
import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index.d-D6Pqey3g.js';
|
|
4
|
-
import './trace-mapping.d-BWFx6tPc.js';
|
|
5
|
-
|
|
6
|
-
type EventType = string | symbol;
|
|
7
|
-
type Handler<T = unknown> = (event: T) => void;
|
|
8
|
-
interface Emitter<Events extends Record<EventType, unknown>> {
|
|
9
|
-
on: <Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>) => void;
|
|
10
|
-
off: <Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>) => void;
|
|
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
|
-
}
|
|
13
|
-
type HMREmitter = Emitter<{
|
|
14
|
-
message: HMRPayload;
|
|
15
|
-
}> & EventEmitter;
|
|
16
|
-
declare module "vite" {
|
|
17
|
-
interface ViteDevServer {
|
|
18
|
-
emitter: HMREmitter;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
declare function createHmrEmitter(): HMREmitter;
|
|
22
|
-
declare function viteNodeHmrPlugin(): Plugin;
|
|
23
|
-
|
|
24
|
-
type ModuleNamespace = Record<string, any> & {
|
|
25
|
-
[Symbol.toStringTag]: "Module";
|
|
26
|
-
};
|
|
27
|
-
type InferCustomEventPayload<T extends string> = T extends keyof CustomEventMap ? CustomEventMap[T] : any;
|
|
28
|
-
interface HotModule {
|
|
29
|
-
id: string;
|
|
30
|
-
callbacks: HotCallback[];
|
|
31
|
-
}
|
|
32
|
-
interface HotCallback {
|
|
33
|
-
deps: string[];
|
|
34
|
-
fn: (modules: (ModuleNamespace | undefined)[]) => void;
|
|
35
|
-
}
|
|
36
|
-
interface CacheData {
|
|
37
|
-
hotModulesMap: Map<string, HotModule>;
|
|
38
|
-
dataMap: Map<string, any>;
|
|
39
|
-
disposeMap: Map<string, (data: any) => void | Promise<void>>;
|
|
40
|
-
pruneMap: Map<string, (data: any) => void | Promise<void>>;
|
|
41
|
-
customListenersMap: Map<string, ((data: any) => void)[]>;
|
|
42
|
-
ctxToListenersMap: Map<string, Map<string, ((data: any) => void)[]>>;
|
|
43
|
-
messageBuffer: string[];
|
|
44
|
-
isFirstUpdate: boolean;
|
|
45
|
-
pending: boolean;
|
|
46
|
-
queued: Promise<(() => void) | undefined>[];
|
|
47
|
-
}
|
|
48
|
-
declare function getCache(runner: ViteNodeRunner): CacheData;
|
|
49
|
-
declare function sendMessageBuffer(runner: ViteNodeRunner, emitter: HMREmitter): void;
|
|
50
|
-
declare function reload(runner: ViteNodeRunner, files: string[]): Promise<any[]>;
|
|
51
|
-
declare function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], payload: HMRPayload$1): Promise<void>;
|
|
52
|
-
declare function createHotContext(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], ownerPath: string): HotContext;
|
|
53
|
-
|
|
54
|
-
export { createHmrEmitter, createHotContext, getCache, handleMessage, reload, sendMessageBuffer, viteNodeHmrPlugin };
|
|
55
|
-
export type { Emitter, EventType, HMREmitter, Handler, HotCallback, HotModule, InferCustomEventPayload, ModuleNamespace };
|
package/dist/hmr.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { c as createHmrEmitter, a as createHotContext, g as getCache, h as handleMessage, r as reload, s as sendMessageBuffer, v as viteNodeHmrPlugin } from './chunk-hmr.js';
|
|
2
|
-
import 'node:events';
|
|
3
|
-
import 'node:process';
|
|
4
|
-
import 'debug';
|
|
5
|
-
import './chunk-index.js';
|
|
6
|
-
import './utils.js';
|
|
7
|
-
import 'node:fs';
|
|
8
|
-
import 'node:module';
|
|
9
|
-
import 'node:url';
|
|
10
|
-
import 'pathe';
|
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-BWFx6tPc.js';
|
|
2
|
-
|
|
3
|
-
/** @deprecated use HotPayload */
|
|
4
|
-
type HMRPayload = HotPayload
|
|
5
|
-
type HotPayload =
|
|
6
|
-
| ConnectedPayload
|
|
7
|
-
| PingPayload
|
|
8
|
-
| UpdatePayload
|
|
9
|
-
| FullReloadPayload
|
|
10
|
-
| CustomPayload
|
|
11
|
-
| ErrorPayload
|
|
12
|
-
| PrunePayload
|
|
13
|
-
|
|
14
|
-
interface ConnectedPayload {
|
|
15
|
-
type: 'connected'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface PingPayload {
|
|
19
|
-
type: 'ping'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface UpdatePayload {
|
|
23
|
-
type: 'update'
|
|
24
|
-
updates: Update[]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface Update {
|
|
28
|
-
type: 'js-update' | 'css-update'
|
|
29
|
-
path: string
|
|
30
|
-
acceptedPath: string
|
|
31
|
-
timestamp: number
|
|
32
|
-
/** @internal */
|
|
33
|
-
explicitImportRequired?: boolean
|
|
34
|
-
/** @internal */
|
|
35
|
-
isWithinCircularImport?: boolean
|
|
36
|
-
/** @internal */
|
|
37
|
-
firstInvalidatedBy?: string
|
|
38
|
-
/** @internal */
|
|
39
|
-
invalidates?: string[]
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface PrunePayload {
|
|
43
|
-
type: 'prune'
|
|
44
|
-
paths: string[]
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface FullReloadPayload {
|
|
48
|
-
type: 'full-reload'
|
|
49
|
-
path?: string
|
|
50
|
-
/** @internal */
|
|
51
|
-
triggeredBy?: string
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface CustomPayload {
|
|
55
|
-
type: 'custom'
|
|
56
|
-
event: string
|
|
57
|
-
data?: any
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface ErrorPayload {
|
|
61
|
-
type: 'error'
|
|
62
|
-
err: {
|
|
63
|
-
[name: string]: any
|
|
64
|
-
message: string
|
|
65
|
-
stack: string
|
|
66
|
-
id?: string
|
|
67
|
-
frame?: string
|
|
68
|
-
plugin?: string
|
|
69
|
-
pluginCode?: string
|
|
70
|
-
loc?: {
|
|
71
|
-
file?: string
|
|
72
|
-
line: number
|
|
73
|
-
column: number
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
interface CustomEventMap {
|
|
79
|
-
// client events
|
|
80
|
-
'vite:beforeUpdate': UpdatePayload
|
|
81
|
-
'vite:afterUpdate': UpdatePayload
|
|
82
|
-
'vite:beforePrune': PrunePayload
|
|
83
|
-
'vite:beforeFullReload': FullReloadPayload
|
|
84
|
-
'vite:error': ErrorPayload
|
|
85
|
-
'vite:invalidate': InvalidatePayload
|
|
86
|
-
'vite:ws:connect': WebSocketConnectionPayload
|
|
87
|
-
'vite:ws:disconnect': WebSocketConnectionPayload
|
|
88
|
-
|
|
89
|
-
// server events
|
|
90
|
-
'vite:client:connect': undefined
|
|
91
|
-
'vite:client:disconnect': undefined
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
interface WebSocketConnectionPayload {
|
|
95
|
-
/**
|
|
96
|
-
* @experimental
|
|
97
|
-
* We expose this instance experimentally to see potential usage.
|
|
98
|
-
* This might be removed in the future if we didn't find reasonable use cases.
|
|
99
|
-
* If you find this useful, please open an issue with details so we can discuss and make it stable API.
|
|
100
|
-
*/
|
|
101
|
-
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
102
|
-
webSocket: WebSocket
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
interface InvalidatePayload {
|
|
106
|
-
path: string
|
|
107
|
-
message: string | undefined
|
|
108
|
-
firstInvalidatedBy: string
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* provides types for payloads of built-in Vite events
|
|
113
|
-
*/
|
|
114
|
-
type InferCustomEventPayload<T extends string> =
|
|
115
|
-
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* provides types for names of built-in Vite events
|
|
119
|
-
*/
|
|
120
|
-
type CustomEventName = keyof CustomEventMap | (string & {})
|
|
121
|
-
|
|
122
|
-
type ModuleNamespace = Record<string, any> & {
|
|
123
|
-
[Symbol.toStringTag]: 'Module'
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
interface ViteHotContext {
|
|
127
|
-
readonly data: any
|
|
128
|
-
|
|
129
|
-
accept(): void
|
|
130
|
-
accept(cb: (mod: ModuleNamespace | undefined) => void): void
|
|
131
|
-
accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
|
|
132
|
-
accept(
|
|
133
|
-
deps: readonly string[],
|
|
134
|
-
cb: (mods: Array<ModuleNamespace | undefined>) => void,
|
|
135
|
-
): void
|
|
136
|
-
|
|
137
|
-
acceptExports(
|
|
138
|
-
exportNames: string | readonly string[],
|
|
139
|
-
cb?: (mod: ModuleNamespace | undefined) => void,
|
|
140
|
-
): void
|
|
141
|
-
|
|
142
|
-
dispose(cb: (data: any) => void): void
|
|
143
|
-
prune(cb: (data: any) => void): void
|
|
144
|
-
invalidate(message?: string): void
|
|
145
|
-
|
|
146
|
-
on<T extends CustomEventName>(
|
|
147
|
-
event: T,
|
|
148
|
-
cb: (payload: InferCustomEventPayload<T>) => void,
|
|
149
|
-
): void
|
|
150
|
-
off<T extends CustomEventName>(
|
|
151
|
-
event: T,
|
|
152
|
-
cb: (payload: InferCustomEventPayload<T>) => void,
|
|
153
|
-
): void
|
|
154
|
-
send<T extends CustomEventName>(
|
|
155
|
-
event: T,
|
|
156
|
-
data?: InferCustomEventPayload<T>,
|
|
157
|
-
): void
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
declare const DEFAULT_REQUEST_STUBS: Record<string, Record<string, unknown>>;
|
|
161
|
-
declare class ModuleCacheMap extends Map<string, ModuleCache> {
|
|
162
|
-
normalizePath(fsPath: string): string;
|
|
163
|
-
/**
|
|
164
|
-
* Assign partial data to the map
|
|
165
|
-
*/
|
|
166
|
-
update(fsPath: string, mod: ModuleCache): this;
|
|
167
|
-
setByModuleId(modulePath: string, mod: ModuleCache): this;
|
|
168
|
-
set(fsPath: string, mod: ModuleCache): this;
|
|
169
|
-
getByModuleId(modulePath: string): ModuleCache & Required<Pick<ModuleCache, "imports" | "importers">>;
|
|
170
|
-
get(fsPath: string): ModuleCache & Required<Pick<ModuleCache, "importers" | "imports">>;
|
|
171
|
-
deleteByModuleId(modulePath: string): boolean;
|
|
172
|
-
delete(fsPath: string): boolean;
|
|
173
|
-
invalidateModule(mod: ModuleCache): boolean;
|
|
174
|
-
/**
|
|
175
|
-
* Invalidate modules that dependent on the given modules, up to the main entry
|
|
176
|
-
*/
|
|
177
|
-
invalidateDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
|
|
178
|
-
/**
|
|
179
|
-
* Invalidate dependency modules of the given modules, down to the bottom-level dependencies
|
|
180
|
-
*/
|
|
181
|
-
invalidateSubDepTree(ids: string[] | Set<string>, invalidated?: Set<string>): Set<string>;
|
|
182
|
-
/**
|
|
183
|
-
* Return parsed source map based on inlined source map of the module
|
|
184
|
-
*/
|
|
185
|
-
getSourceMap(id: string): EncodedSourceMap | null;
|
|
186
|
-
}
|
|
187
|
-
type ModuleExecutionInfo = Map<string, ModuleExecutionInfoEntry>;
|
|
188
|
-
interface ModuleExecutionInfoEntry {
|
|
189
|
-
startOffset: number;
|
|
190
|
-
/** The duration that was spent executing the module. */
|
|
191
|
-
duration: number;
|
|
192
|
-
/** The time that was spent executing the module itself and externalized imports. */
|
|
193
|
-
selfTime: number;
|
|
194
|
-
}
|
|
195
|
-
declare class ViteNodeRunner {
|
|
196
|
-
options: ViteNodeRunnerOptions;
|
|
197
|
-
root: string;
|
|
198
|
-
debug: boolean;
|
|
199
|
-
/**
|
|
200
|
-
* Holds the cache of modules
|
|
201
|
-
* Keys of the map are filepaths, or plain package names
|
|
202
|
-
*/
|
|
203
|
-
moduleCache: ModuleCacheMap;
|
|
204
|
-
/**
|
|
205
|
-
* Tracks the stack of modules being executed for the purpose of calculating import self-time.
|
|
206
|
-
*
|
|
207
|
-
* Note that while in most cases, imports are a linear stack of modules,
|
|
208
|
-
* this is occasionally not the case, for example when you have parallel top-level dynamic imports like so:
|
|
209
|
-
*
|
|
210
|
-
* ```ts
|
|
211
|
-
* await Promise.all([
|
|
212
|
-
* import('./module1'),
|
|
213
|
-
* import('./module2'),
|
|
214
|
-
* ]);
|
|
215
|
-
* ```
|
|
216
|
-
*
|
|
217
|
-
* In this case, the self time will be reported incorrectly for one of the modules (could go negative).
|
|
218
|
-
* As top-level awaits with dynamic imports like this are uncommon, we don't handle this case specifically.
|
|
219
|
-
*/
|
|
220
|
-
private executionStack;
|
|
221
|
-
private performanceNow;
|
|
222
|
-
constructor(options: ViteNodeRunnerOptions);
|
|
223
|
-
executeFile(file: string): Promise<any>;
|
|
224
|
-
executeId(rawId: string): Promise<any>;
|
|
225
|
-
shouldResolveId(id: string, _importee?: string): boolean;
|
|
226
|
-
private _resolveUrl;
|
|
227
|
-
resolveUrl(id: string, importee?: string): Promise<[url: string, fsPath: string]>;
|
|
228
|
-
private _fetchModule;
|
|
229
|
-
protected getContextPrimitives(): {
|
|
230
|
-
Object: ObjectConstructor;
|
|
231
|
-
Reflect: typeof Reflect;
|
|
232
|
-
Symbol: SymbolConstructor;
|
|
233
|
-
};
|
|
234
|
-
protected runModule(context: Record<string, any>, transformed: string): Promise<void>;
|
|
235
|
-
/**
|
|
236
|
-
* Starts calculating the module execution info such as the total duration and self time spent on executing the module.
|
|
237
|
-
* Returns a function to call once the module has finished executing.
|
|
238
|
-
*/
|
|
239
|
-
protected startCalculateModuleExecutionInfo(filename: string, startOffset: number): () => ModuleExecutionInfoEntry;
|
|
240
|
-
prepareContext(context: Record<string, any>): Record<string, any>;
|
|
241
|
-
/**
|
|
242
|
-
* Define if a module should be interop-ed
|
|
243
|
-
* This function mostly for the ability to override by subclass
|
|
244
|
-
*/
|
|
245
|
-
shouldInterop(path: string, mod: any): boolean;
|
|
246
|
-
protected importExternalModule(path: string): Promise<any>;
|
|
247
|
-
/**
|
|
248
|
-
* Import a module and interop it
|
|
249
|
-
*/
|
|
250
|
-
interopedImport(path: string): Promise<any>;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
type Nullable<T> = T | null | undefined;
|
|
254
|
-
type Arrayable<T> = T | Array<T>;
|
|
255
|
-
type Awaitable<T> = T | PromiseLike<T>;
|
|
256
|
-
interface DepsHandlingOptions {
|
|
257
|
-
external?: (string | RegExp)[];
|
|
258
|
-
inline?: (string | RegExp)[] | true;
|
|
259
|
-
inlineFiles?: string[];
|
|
260
|
-
/**
|
|
261
|
-
* A list of directories that are considered to hold Node.js modules
|
|
262
|
-
* Have to include "/" at the start and end of the path
|
|
263
|
-
*
|
|
264
|
-
* Vite-Node checks the whole absolute path of the import, so make sure you don't include
|
|
265
|
-
* unwanted files accidentally
|
|
266
|
-
* @default ['/node_modules/']
|
|
267
|
-
*/
|
|
268
|
-
moduleDirectories?: string[];
|
|
269
|
-
cacheDir?: string;
|
|
270
|
-
/**
|
|
271
|
-
* Try to guess the CJS version of a package when it's invalid ESM
|
|
272
|
-
* @default false
|
|
273
|
-
*/
|
|
274
|
-
fallbackCJS?: boolean;
|
|
275
|
-
}
|
|
276
|
-
interface StartOfSourceMap {
|
|
277
|
-
file?: string;
|
|
278
|
-
sourceRoot?: string;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
interface RawSourceMap extends StartOfSourceMap {
|
|
282
|
-
version: number;
|
|
283
|
-
sources: string[];
|
|
284
|
-
names: string[];
|
|
285
|
-
sourcesContent?: (string | null)[];
|
|
286
|
-
mappings: string;
|
|
287
|
-
}
|
|
288
|
-
interface FetchResult {
|
|
289
|
-
code?: string;
|
|
290
|
-
externalize?: string;
|
|
291
|
-
map?: EncodedSourceMap | null;
|
|
292
|
-
}
|
|
293
|
-
type HotContext = Omit<ViteHotContext, "acceptDeps" | "decline">;
|
|
294
|
-
type FetchFunction = (id: string) => Promise<FetchResult>;
|
|
295
|
-
type ResolveIdFunction = (id: string, importer?: string) => Awaitable<ViteNodeResolveId | null | undefined | void>;
|
|
296
|
-
type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
|
|
297
|
-
interface ModuleCache {
|
|
298
|
-
promise?: Promise<any>;
|
|
299
|
-
exports?: any;
|
|
300
|
-
evaluated?: boolean;
|
|
301
|
-
resolving?: boolean;
|
|
302
|
-
code?: string;
|
|
303
|
-
map?: EncodedSourceMap;
|
|
304
|
-
/**
|
|
305
|
-
* Module ids that imports this module
|
|
306
|
-
*/
|
|
307
|
-
importers?: Set<string>;
|
|
308
|
-
imports?: Set<string>;
|
|
309
|
-
}
|
|
310
|
-
interface ViteNodeRunnerOptions {
|
|
311
|
-
root: string;
|
|
312
|
-
fetchModule: FetchFunction;
|
|
313
|
-
resolveId?: ResolveIdFunction;
|
|
314
|
-
createHotContext?: CreateHotContextFunction;
|
|
315
|
-
base?: string;
|
|
316
|
-
moduleCache?: ModuleCacheMap;
|
|
317
|
-
moduleExecutionInfo?: ModuleExecutionInfo;
|
|
318
|
-
interopDefault?: boolean;
|
|
319
|
-
requestStubs?: Record<string, any>;
|
|
320
|
-
debug?: boolean;
|
|
321
|
-
}
|
|
322
|
-
interface ViteNodeResolveId {
|
|
323
|
-
external?: boolean | "absolute" | "relative";
|
|
324
|
-
id: string;
|
|
325
|
-
meta?: Record<string, any> | null;
|
|
326
|
-
moduleSideEffects?: boolean | "no-treeshake" | null;
|
|
327
|
-
syntheticNamedExports?: boolean | string | null;
|
|
328
|
-
}
|
|
329
|
-
interface ViteNodeResolveModule {
|
|
330
|
-
external: string | null;
|
|
331
|
-
id: string;
|
|
332
|
-
fsPath: string;
|
|
333
|
-
}
|
|
334
|
-
interface ViteNodeServerOptions {
|
|
335
|
-
/**
|
|
336
|
-
* Inject inline sourcemap to modules
|
|
337
|
-
* @default 'inline'
|
|
338
|
-
*/
|
|
339
|
-
sourcemap?: "inline" | boolean;
|
|
340
|
-
/**
|
|
341
|
-
* Deps handling
|
|
342
|
-
*/
|
|
343
|
-
deps?: DepsHandlingOptions;
|
|
344
|
-
/**
|
|
345
|
-
* Transform method for modules
|
|
346
|
-
*/
|
|
347
|
-
transformMode?: {
|
|
348
|
-
ssr?: RegExp[];
|
|
349
|
-
web?: RegExp[];
|
|
350
|
-
};
|
|
351
|
-
debug?: DebuggerOptions;
|
|
352
|
-
}
|
|
353
|
-
interface DebuggerOptions {
|
|
354
|
-
/**
|
|
355
|
-
* Dump the transformed module to filesystem
|
|
356
|
-
* Passing a string will dump to the specified path
|
|
357
|
-
*/
|
|
358
|
-
dumpModules?: boolean | string;
|
|
359
|
-
/**
|
|
360
|
-
* Read dumpped module from filesystem whenever exists.
|
|
361
|
-
* Useful for debugging by modifying the dump result from the filesystem.
|
|
362
|
-
*/
|
|
363
|
-
loadDumppedModules?: boolean;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
export { ModuleCacheMap as M, ViteNodeRunner as a, DEFAULT_REQUEST_STUBS as e };
|
|
367
|
-
export type { Arrayable as A, CustomEventMap as C, DebuggerOptions as D, FetchResult as F, HMRPayload as H, Nullable as N, RawSourceMap as R, StartOfSourceMap as S, ViteNodeServerOptions as V, HotContext as b, DepsHandlingOptions as c, ViteNodeResolveId as d, ModuleExecutionInfo as f, ModuleExecutionInfoEntry as g, Awaitable as h, FetchFunction as i, ResolveIdFunction as j, CreateHotContextFunction as k, ModuleCache as l, ViteNodeRunnerOptions as m, ViteNodeResolveModule as n };
|
package/dist/index.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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-D6Pqey3g.js';
|
|
2
|
-
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-BWFx6tPc.js';
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/server.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
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-D6Pqey3g.js';
|
|
3
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-BWFx6tPc.js';
|
|
4
|
-
|
|
5
|
-
declare class Debugger {
|
|
6
|
-
options: DebuggerOptions;
|
|
7
|
-
dumpDir: string | undefined;
|
|
8
|
-
initPromise: Promise<void> | undefined;
|
|
9
|
-
externalizeMap: Map<string, string>;
|
|
10
|
-
constructor(root: string, options: DebuggerOptions);
|
|
11
|
-
clearDump(): Promise<void>;
|
|
12
|
-
encodeId(id: string): string;
|
|
13
|
-
recordExternalize(id: string, path: string): Promise<void>;
|
|
14
|
-
dumpFile(id: string, result: TransformResult | null): Promise<void>;
|
|
15
|
-
loadDump(id: string): Promise<TransformResult | null>;
|
|
16
|
-
writeInfo(): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare function guessCJSversion(id: string): string | undefined;
|
|
20
|
-
declare function shouldExternalize(id: string, options?: DepsHandlingOptions, cache?: Map<string, Promise<string | false>>): Promise<string | false>;
|
|
21
|
-
|
|
22
|
-
interface FetchCache {
|
|
23
|
-
duration?: number;
|
|
24
|
-
timestamp: number;
|
|
25
|
-
result: FetchResult;
|
|
26
|
-
}
|
|
27
|
-
declare class ViteNodeServer {
|
|
28
|
-
server: ViteDevServer;
|
|
29
|
-
options: ViteNodeServerOptions;
|
|
30
|
-
private fetchPromiseMap;
|
|
31
|
-
private transformPromiseMap;
|
|
32
|
-
private durations;
|
|
33
|
-
private existingOptimizedDeps;
|
|
34
|
-
fetchCaches: Record<"ssr" | "web", Map<string, FetchCache>>;
|
|
35
|
-
fetchCache: Map<string, FetchCache>;
|
|
36
|
-
externalizeCache: Map<string, Promise<string | false>>;
|
|
37
|
-
debugger?: Debugger;
|
|
38
|
-
constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
|
|
39
|
-
shouldExternalize(id: string): Promise<string | false>;
|
|
40
|
-
getTotalDuration(): number;
|
|
41
|
-
private ensureExists;
|
|
42
|
-
resolveId(id: string, importer?: string, transformMode?: "web" | "ssr"): Promise<ViteNodeResolveId | null>;
|
|
43
|
-
getSourceMap(source: string): EncodedSourceMap | null;
|
|
44
|
-
private assertMode;
|
|
45
|
-
fetchModule(id: string, transformMode?: "web" | "ssr"): Promise<FetchResult>;
|
|
46
|
-
fetchResult(id: string, mode: "web" | "ssr"): Promise<FetchResult>;
|
|
47
|
-
transformRequest(id: string, filepath?: string, transformMode?: "web" | "ssr"): Promise<TransformResult | null | undefined>;
|
|
48
|
-
transformModule(id: string, transformMode?: "web" | "ssr"): Promise<{
|
|
49
|
-
code: string | undefined;
|
|
50
|
-
}>;
|
|
51
|
-
getTransformMode(id: string): "ssr" | "web";
|
|
52
|
-
private getChangedModule;
|
|
53
|
-
private _fetchModule;
|
|
54
|
-
protected processTransformResult(filepath: string, result: TransformResult): Promise<TransformResult>;
|
|
55
|
-
private _transformRequest;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export { ViteNodeServer, guessCJSversion, shouldExternalize };
|