vite-node 0.16.0 → 0.18.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/chunk-client.cjs +25 -10
- package/dist/chunk-client.mjs +25 -10
- package/dist/chunk-hmr.cjs +233 -0
- package/dist/chunk-hmr.mjs +221 -0
- package/dist/chunk-server.cjs +1 -20
- package/dist/chunk-server.mjs +1 -20
- package/dist/chunk-utils.cjs +2 -2
- package/dist/chunk-utils.mjs +2 -2
- package/dist/cli.cjs +21 -35
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +22 -36
- package/dist/client.d.ts +1 -1
- package/dist/hmr.cjs +18 -0
- package/dist/hmr.d.ts +57 -0
- package/dist/hmr.mjs +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/{types-93bdaf32.d.ts → types-b59fb161.d.ts} +104 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +7 -2
- package/cli.d.ts +0 -8
- package/client.d.ts +0 -37
- package/index.d.ts +0 -1
- package/server.d.ts +0 -26
- package/types.d.ts +0 -68
- package/utils.d.ts +0 -10
package/dist/chunk-utils.mjs
CHANGED
|
@@ -20,10 +20,10 @@ function isPrimitive(v) {
|
|
|
20
20
|
return v !== Object(v);
|
|
21
21
|
}
|
|
22
22
|
function toFilePath(id, root) {
|
|
23
|
-
let absolute =
|
|
23
|
+
let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? resolve(root, id.slice(1)) : id;
|
|
24
24
|
if (absolute.startsWith("//"))
|
|
25
25
|
absolute = absolute.slice(1);
|
|
26
|
-
return isWindows && absolute.startsWith("/") ? fileURLToPath(pathToFileURL(absolute.slice(1)).href) : absolute;
|
|
26
|
+
return isWindows && absolute.startsWith("/") ? slash(fileURLToPath(pathToFileURL(absolute.slice(1)).href)) : absolute;
|
|
27
27
|
}
|
|
28
28
|
let SOURCEMAPPING_URL = "sourceMa";
|
|
29
29
|
SOURCEMAPPING_URL += "ppingURL";
|
package/dist/cli.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var vite = require('vite');
|
|
|
6
6
|
var server = require('./chunk-server.cjs');
|
|
7
7
|
var client = require('./chunk-client.cjs');
|
|
8
8
|
var utils = require('./chunk-utils.cjs');
|
|
9
|
+
var hmr = require('./chunk-hmr.cjs');
|
|
9
10
|
require('pathe');
|
|
10
11
|
require('debug');
|
|
11
12
|
require('fs');
|
|
@@ -627,32 +628,14 @@ class CAC extends events.EventEmitter {
|
|
|
627
628
|
|
|
628
629
|
const cac = (name = "") => new CAC(name);
|
|
629
630
|
|
|
630
|
-
var version = "0.
|
|
631
|
+
var version = "0.18.0";
|
|
631
632
|
|
|
632
|
-
var __defProp = Object.defineProperty;
|
|
633
|
-
var __defProps = Object.defineProperties;
|
|
634
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
635
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
636
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
637
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
638
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
639
|
-
var __spreadValues = (a, b) => {
|
|
640
|
-
for (var prop in b || (b = {}))
|
|
641
|
-
if (__hasOwnProp.call(b, prop))
|
|
642
|
-
__defNormalProp(a, prop, b[prop]);
|
|
643
|
-
if (__getOwnPropSymbols)
|
|
644
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
645
|
-
if (__propIsEnum.call(b, prop))
|
|
646
|
-
__defNormalProp(a, prop, b[prop]);
|
|
647
|
-
}
|
|
648
|
-
return a;
|
|
649
|
-
};
|
|
650
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
651
633
|
const cli = cac("vite-node");
|
|
652
634
|
cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--options <options>", "Use specified Vite server options").help();
|
|
653
635
|
cli.command("[...files]").action(run);
|
|
654
636
|
cli.parse();
|
|
655
637
|
async function run(files, options = {}) {
|
|
638
|
+
var _a;
|
|
656
639
|
if (!files.length) {
|
|
657
640
|
console.error(kolorist.red("No files specified."));
|
|
658
641
|
cli.outputHelp();
|
|
@@ -663,7 +646,10 @@ async function run(files, options = {}) {
|
|
|
663
646
|
const server$1 = await vite.createServer({
|
|
664
647
|
logLevel: "error",
|
|
665
648
|
configFile: options.config,
|
|
666
|
-
root: options.root
|
|
649
|
+
root: options.root,
|
|
650
|
+
plugins: [
|
|
651
|
+
options.watch && hmr.viteNodeHmrPlugin()
|
|
652
|
+
]
|
|
667
653
|
});
|
|
668
654
|
await server$1.pluginContainer.buildStart({});
|
|
669
655
|
const node = new server.ViteNodeServer(server$1, parsedServerOptions);
|
|
@@ -675,6 +661,9 @@ async function run(files, options = {}) {
|
|
|
675
661
|
},
|
|
676
662
|
resolveId(id, importer) {
|
|
677
663
|
return node.resolveId(id, importer);
|
|
664
|
+
},
|
|
665
|
+
createHotContext(runner2, url) {
|
|
666
|
+
return hmr.createHotContext(runner2, server$1.emitter, files, url);
|
|
678
667
|
}
|
|
679
668
|
});
|
|
680
669
|
await runner.executeId("/@vite/env");
|
|
@@ -682,31 +671,28 @@ async function run(files, options = {}) {
|
|
|
682
671
|
await runner.executeFile(file);
|
|
683
672
|
if (!options.watch)
|
|
684
673
|
await server$1.close();
|
|
685
|
-
server$1.
|
|
686
|
-
|
|
687
|
-
Array.from(runner.moduleCache.keys()).forEach((i) => {
|
|
688
|
-
if (!i.includes("node_modules"))
|
|
689
|
-
runner.moduleCache.delete(i);
|
|
690
|
-
});
|
|
691
|
-
for (const file of files)
|
|
692
|
-
await runner.executeFile(file);
|
|
674
|
+
(_a = server$1.emitter) == null ? void 0 : _a.on("message", (payload) => {
|
|
675
|
+
hmr.handleMessage(runner, server$1.emitter, files, payload);
|
|
693
676
|
});
|
|
694
677
|
}
|
|
695
678
|
function parseServerOptions(serverOptions) {
|
|
696
679
|
var _a, _b, _c, _d, _e;
|
|
697
680
|
const inlineOptions = ((_a = serverOptions.deps) == null ? void 0 : _a.inline) === true ? true : utils.toArray((_b = serverOptions.deps) == null ? void 0 : _b.inline);
|
|
698
|
-
return
|
|
699
|
-
|
|
681
|
+
return {
|
|
682
|
+
...serverOptions,
|
|
683
|
+
deps: {
|
|
684
|
+
...serverOptions.deps,
|
|
700
685
|
inline: inlineOptions !== true ? inlineOptions.map((dep) => {
|
|
701
686
|
return dep.startsWith("/") && dep.endsWith("/") ? new RegExp(dep) : dep;
|
|
702
687
|
}) : true,
|
|
703
688
|
external: utils.toArray((_c = serverOptions.deps) == null ? void 0 : _c.external).map((dep) => {
|
|
704
689
|
return dep.startsWith("/") && dep.endsWith("/") ? new RegExp(dep) : dep;
|
|
705
690
|
})
|
|
706
|
-
}
|
|
707
|
-
transformMode:
|
|
691
|
+
},
|
|
692
|
+
transformMode: {
|
|
693
|
+
...serverOptions.transformMode,
|
|
708
694
|
ssr: utils.toArray((_d = serverOptions.transformMode) == null ? void 0 : _d.ssr).map((dep) => new RegExp(dep)),
|
|
709
695
|
web: utils.toArray((_e = serverOptions.transformMode) == null ? void 0 : _e.web).map((dep) => new RegExp(dep))
|
|
710
|
-
}
|
|
711
|
-
}
|
|
696
|
+
}
|
|
697
|
+
};
|
|
712
698
|
}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { red
|
|
2
|
+
import { red } from 'kolorist';
|
|
3
3
|
import { createServer } from 'vite';
|
|
4
4
|
import { V as ViteNodeServer } from './chunk-server.mjs';
|
|
5
5
|
import { V as ViteNodeRunner } from './chunk-client.mjs';
|
|
6
6
|
import { t as toArray } from './chunk-utils.mjs';
|
|
7
|
+
import { v as viteNodeHmrPlugin, c as createHotContext, h as handleMessage } from './chunk-hmr.mjs';
|
|
7
8
|
import 'pathe';
|
|
8
9
|
import 'debug';
|
|
9
10
|
import 'fs';
|
|
@@ -625,32 +626,14 @@ class CAC extends EventEmitter {
|
|
|
625
626
|
|
|
626
627
|
const cac = (name = "") => new CAC(name);
|
|
627
628
|
|
|
628
|
-
var version = "0.
|
|
629
|
+
var version = "0.18.0";
|
|
629
630
|
|
|
630
|
-
var __defProp = Object.defineProperty;
|
|
631
|
-
var __defProps = Object.defineProperties;
|
|
632
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
633
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
634
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
635
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
636
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
637
|
-
var __spreadValues = (a, b) => {
|
|
638
|
-
for (var prop in b || (b = {}))
|
|
639
|
-
if (__hasOwnProp.call(b, prop))
|
|
640
|
-
__defNormalProp(a, prop, b[prop]);
|
|
641
|
-
if (__getOwnPropSymbols)
|
|
642
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
643
|
-
if (__propIsEnum.call(b, prop))
|
|
644
|
-
__defNormalProp(a, prop, b[prop]);
|
|
645
|
-
}
|
|
646
|
-
return a;
|
|
647
|
-
};
|
|
648
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
649
631
|
const cli = cac("vite-node");
|
|
650
632
|
cli.version(version).option("-r, --root <path>", "Use specified root directory").option("-c, --config <path>", "Use specified config file").option("-w, --watch", 'Restart on file changes, similar to "nodemon"').option("--options <options>", "Use specified Vite server options").help();
|
|
651
633
|
cli.command("[...files]").action(run);
|
|
652
634
|
cli.parse();
|
|
653
635
|
async function run(files, options = {}) {
|
|
636
|
+
var _a;
|
|
654
637
|
if (!files.length) {
|
|
655
638
|
console.error(red("No files specified."));
|
|
656
639
|
cli.outputHelp();
|
|
@@ -661,7 +644,10 @@ async function run(files, options = {}) {
|
|
|
661
644
|
const server = await createServer({
|
|
662
645
|
logLevel: "error",
|
|
663
646
|
configFile: options.config,
|
|
664
|
-
root: options.root
|
|
647
|
+
root: options.root,
|
|
648
|
+
plugins: [
|
|
649
|
+
options.watch && viteNodeHmrPlugin()
|
|
650
|
+
]
|
|
665
651
|
});
|
|
666
652
|
await server.pluginContainer.buildStart({});
|
|
667
653
|
const node = new ViteNodeServer(server, parsedServerOptions);
|
|
@@ -673,6 +659,9 @@ async function run(files, options = {}) {
|
|
|
673
659
|
},
|
|
674
660
|
resolveId(id, importer) {
|
|
675
661
|
return node.resolveId(id, importer);
|
|
662
|
+
},
|
|
663
|
+
createHotContext(runner2, url) {
|
|
664
|
+
return createHotContext(runner2, server.emitter, files, url);
|
|
676
665
|
}
|
|
677
666
|
});
|
|
678
667
|
await runner.executeId("/@vite/env");
|
|
@@ -680,31 +669,28 @@ async function run(files, options = {}) {
|
|
|
680
669
|
await runner.executeFile(file);
|
|
681
670
|
if (!options.watch)
|
|
682
671
|
await server.close();
|
|
683
|
-
server.
|
|
684
|
-
|
|
685
|
-
Array.from(runner.moduleCache.keys()).forEach((i) => {
|
|
686
|
-
if (!i.includes("node_modules"))
|
|
687
|
-
runner.moduleCache.delete(i);
|
|
688
|
-
});
|
|
689
|
-
for (const file of files)
|
|
690
|
-
await runner.executeFile(file);
|
|
672
|
+
(_a = server.emitter) == null ? void 0 : _a.on("message", (payload) => {
|
|
673
|
+
handleMessage(runner, server.emitter, files, payload);
|
|
691
674
|
});
|
|
692
675
|
}
|
|
693
676
|
function parseServerOptions(serverOptions) {
|
|
694
677
|
var _a, _b, _c, _d, _e;
|
|
695
678
|
const inlineOptions = ((_a = serverOptions.deps) == null ? void 0 : _a.inline) === true ? true : toArray((_b = serverOptions.deps) == null ? void 0 : _b.inline);
|
|
696
|
-
return
|
|
697
|
-
|
|
679
|
+
return {
|
|
680
|
+
...serverOptions,
|
|
681
|
+
deps: {
|
|
682
|
+
...serverOptions.deps,
|
|
698
683
|
inline: inlineOptions !== true ? inlineOptions.map((dep) => {
|
|
699
684
|
return dep.startsWith("/") && dep.endsWith("/") ? new RegExp(dep) : dep;
|
|
700
685
|
}) : true,
|
|
701
686
|
external: toArray((_c = serverOptions.deps) == null ? void 0 : _c.external).map((dep) => {
|
|
702
687
|
return dep.startsWith("/") && dep.endsWith("/") ? new RegExp(dep) : dep;
|
|
703
688
|
})
|
|
704
|
-
}
|
|
705
|
-
transformMode:
|
|
689
|
+
},
|
|
690
|
+
transformMode: {
|
|
691
|
+
...serverOptions.transformMode,
|
|
706
692
|
ssr: toArray((_d = serverOptions.transformMode) == null ? void 0 : _d.ssr).map((dep) => new RegExp(dep)),
|
|
707
693
|
web: toArray((_e = serverOptions.transformMode) == null ? void 0 : _e.web).map((dep) => new RegExp(dep))
|
|
708
|
-
}
|
|
709
|
-
}
|
|
694
|
+
}
|
|
695
|
+
};
|
|
710
696
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { i as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, g as ViteNodeRunner } from './types-b59fb161.js';
|
package/dist/hmr.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var hmr = require('./chunk-hmr.cjs');
|
|
6
|
+
require('events');
|
|
7
|
+
require('kolorist');
|
|
8
|
+
require('debug');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.createHmrEmitter = hmr.createHmrEmitter;
|
|
13
|
+
exports.createHotContext = hmr.createHotContext;
|
|
14
|
+
exports.getCache = hmr.getCache;
|
|
15
|
+
exports.handleMessage = hmr.handleMessage;
|
|
16
|
+
exports.reload = hmr.reload;
|
|
17
|
+
exports.sendMessageBuffer = hmr.sendMessageBuffer;
|
|
18
|
+
exports.viteNodeHmrPlugin = hmr.viteNodeHmrPlugin;
|
package/dist/hmr.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { HMRPayload, Plugin } from 'vite';
|
|
3
|
+
import { U as UpdatePayload, P as PrunePayload, f as FullReloadPayload, E as ErrorPayload, g as ViteNodeRunner, h as HMRPayload$1, H as HotContext } from './types-b59fb161.js';
|
|
4
|
+
|
|
5
|
+
declare type EventType = string | symbol;
|
|
6
|
+
declare type Handler<T = unknown> = (event: T) => void;
|
|
7
|
+
interface Emitter<Events extends Record<EventType, unknown>> {
|
|
8
|
+
on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
|
|
9
|
+
off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;
|
|
10
|
+
emit<Key extends keyof Events>(type: Key, event: Events[Key]): void;
|
|
11
|
+
emit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;
|
|
12
|
+
}
|
|
13
|
+
declare 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
|
+
interface CustomEventMap {
|
|
25
|
+
'vite:beforeUpdate': UpdatePayload;
|
|
26
|
+
'vite:beforePrune': PrunePayload;
|
|
27
|
+
'vite:beforeFullReload': FullReloadPayload;
|
|
28
|
+
'vite:error': ErrorPayload;
|
|
29
|
+
}
|
|
30
|
+
declare type InferCustomEventPayload<T extends string> = T extends keyof CustomEventMap ? CustomEventMap[T] : any;
|
|
31
|
+
interface HotModule {
|
|
32
|
+
id: string;
|
|
33
|
+
callbacks: HotCallback[];
|
|
34
|
+
}
|
|
35
|
+
interface HotCallback {
|
|
36
|
+
deps: string[];
|
|
37
|
+
fn: (modules: object[]) => void;
|
|
38
|
+
}
|
|
39
|
+
interface CacheData {
|
|
40
|
+
hotModulesMap: Map<string, HotModule>;
|
|
41
|
+
dataMap: Map<string, any>;
|
|
42
|
+
disposeMap: Map<string, (data: any) => void | Promise<void>>;
|
|
43
|
+
pruneMap: Map<string, (data: any) => void | Promise<void>>;
|
|
44
|
+
customListenersMap: Map<string, ((data: any) => void)[]>;
|
|
45
|
+
ctxToListenersMap: Map<string, Map<string, ((data: any) => void)[]>>;
|
|
46
|
+
messageBuffer: string[];
|
|
47
|
+
isFirstUpdate: boolean;
|
|
48
|
+
pending: boolean;
|
|
49
|
+
queued: Promise<(() => void) | undefined>[];
|
|
50
|
+
}
|
|
51
|
+
declare function getCache(runner: ViteNodeRunner): CacheData;
|
|
52
|
+
declare function sendMessageBuffer(runner: ViteNodeRunner, emitter: HMREmitter): void;
|
|
53
|
+
declare function reload(runner: ViteNodeRunner, files: string[]): Promise<any[]>;
|
|
54
|
+
declare function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], payload: HMRPayload$1): Promise<void>;
|
|
55
|
+
declare function createHotContext(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], ownerPath: string): HotContext;
|
|
56
|
+
|
|
57
|
+
export { CustomEventMap, Emitter, EventType, HMREmitter, Handler, HotCallback, HotModule, InferCustomEventPayload, createHmrEmitter, createHotContext, getCache, handleMessage, reload, sendMessageBuffer, viteNodeHmrPlugin };
|
package/dist/hmr.mjs
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-b59fb161.js';
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ViteDevServer, TransformResult } from 'vite';
|
|
2
|
-
import { D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './types-
|
|
2
|
+
import { D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './types-b59fb161.js';
|
|
3
3
|
|
|
4
4
|
declare function guessCJSversion(id: string): string | undefined;
|
|
5
5
|
declare function shouldExternalize(id: string, options?: DepsHandlingOptions, cache?: Map<string, Promise<string | false>>): Promise<string | false>;
|
|
@@ -1,3 +1,103 @@
|
|
|
1
|
+
type HMRPayload =
|
|
2
|
+
| ConnectedPayload
|
|
3
|
+
| UpdatePayload
|
|
4
|
+
| FullReloadPayload
|
|
5
|
+
| CustomPayload
|
|
6
|
+
| ErrorPayload
|
|
7
|
+
| PrunePayload
|
|
8
|
+
|
|
9
|
+
interface ConnectedPayload {
|
|
10
|
+
type: 'connected'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface UpdatePayload {
|
|
14
|
+
type: 'update'
|
|
15
|
+
updates: Update[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Update {
|
|
19
|
+
type: 'js-update' | 'css-update'
|
|
20
|
+
path: string
|
|
21
|
+
acceptedPath: string
|
|
22
|
+
timestamp: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface PrunePayload {
|
|
26
|
+
type: 'prune'
|
|
27
|
+
paths: string[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface FullReloadPayload {
|
|
31
|
+
type: 'full-reload'
|
|
32
|
+
path?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface CustomPayload {
|
|
36
|
+
type: 'custom'
|
|
37
|
+
event: string
|
|
38
|
+
data?: any
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface ErrorPayload {
|
|
42
|
+
type: 'error'
|
|
43
|
+
err: {
|
|
44
|
+
[name: string]: any
|
|
45
|
+
message: string
|
|
46
|
+
stack: string
|
|
47
|
+
id?: string
|
|
48
|
+
frame?: string
|
|
49
|
+
plugin?: string
|
|
50
|
+
pluginCode?: string
|
|
51
|
+
loc?: {
|
|
52
|
+
file?: string
|
|
53
|
+
line: number
|
|
54
|
+
column: number
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface CustomEventMap {
|
|
60
|
+
'vite:beforeUpdate': UpdatePayload
|
|
61
|
+
'vite:beforePrune': PrunePayload
|
|
62
|
+
'vite:beforeFullReload': FullReloadPayload
|
|
63
|
+
'vite:error': ErrorPayload
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type InferCustomEventPayload<T extends string> =
|
|
67
|
+
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
68
|
+
|
|
69
|
+
type ModuleNamespace = Record<string, any> & {
|
|
70
|
+
[Symbol.toStringTag]: 'Module'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface ViteHotContext {
|
|
74
|
+
readonly data: any
|
|
75
|
+
|
|
76
|
+
accept(): void
|
|
77
|
+
accept(cb: (mod: ModuleNamespace | undefined) => void): void
|
|
78
|
+
accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
|
|
79
|
+
accept(
|
|
80
|
+
deps: readonly string[],
|
|
81
|
+
cb: (mods: Array<ModuleNamespace | undefined>) => void
|
|
82
|
+
): void
|
|
83
|
+
|
|
84
|
+
acceptExports(exportNames: string | readonly string[]): void
|
|
85
|
+
acceptExports(
|
|
86
|
+
exportNames: string | readonly string[],
|
|
87
|
+
cb: (mod: ModuleNamespace | undefined) => void
|
|
88
|
+
): void
|
|
89
|
+
|
|
90
|
+
dispose(cb: (data: any) => void): void
|
|
91
|
+
decline(): void
|
|
92
|
+
invalidate(): void
|
|
93
|
+
|
|
94
|
+
on<T extends string>(
|
|
95
|
+
event: T,
|
|
96
|
+
cb: (payload: InferCustomEventPayload<T>) => void
|
|
97
|
+
): void
|
|
98
|
+
send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
|
|
99
|
+
}
|
|
100
|
+
|
|
1
101
|
declare const DEFAULT_REQUEST_STUBS: {
|
|
2
102
|
'/@vite/client': {
|
|
3
103
|
injectQuery: (id: string) => string;
|
|
@@ -76,8 +176,10 @@ interface FetchResult {
|
|
|
76
176
|
externalize?: string;
|
|
77
177
|
map?: RawSourceMap;
|
|
78
178
|
}
|
|
179
|
+
declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
|
|
79
180
|
declare type FetchFunction = (id: string) => Promise<FetchResult>;
|
|
80
181
|
declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
182
|
+
declare type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext;
|
|
81
183
|
interface ModuleCache {
|
|
82
184
|
promise?: Promise<any>;
|
|
83
185
|
exports?: any;
|
|
@@ -87,6 +189,7 @@ interface ViteNodeRunnerOptions {
|
|
|
87
189
|
root: string;
|
|
88
190
|
fetchModule: FetchFunction;
|
|
89
191
|
resolveId?: ResolveIdFunction;
|
|
192
|
+
createHotContext?: CreateHotContextFunction;
|
|
90
193
|
base?: string;
|
|
91
194
|
moduleCache?: ModuleCacheMap;
|
|
92
195
|
interopDefault?: boolean;
|
|
@@ -119,4 +222,4 @@ interface ViteNodeServerOptions {
|
|
|
119
222
|
};
|
|
120
223
|
}
|
|
121
224
|
|
|
122
|
-
export { Arrayable as A, DepsHandlingOptions as D, FetchResult as F, ModuleCacheMap as M, Nullable as N, RawSourceMap as R, StartOfSourceMap as S, ViteNodeRunnerOptions as V, FetchFunction as a, ResolveIdFunction as b, ModuleCache as c, ViteNodeResolveId as d, ViteNodeServerOptions as e,
|
|
225
|
+
export { Arrayable as A, CreateHotContextFunction as C, DepsHandlingOptions as D, ErrorPayload as E, FetchResult as F, HotContext as H, ModuleCacheMap as M, Nullable as N, PrunePayload as P, RawSourceMap as R, StartOfSourceMap as S, UpdatePayload as U, ViteNodeRunnerOptions as V, FetchFunction as a, ResolveIdFunction as b, ModuleCache as c, ViteNodeResolveId as d, ViteNodeServerOptions as e, FullReloadPayload as f, ViteNodeRunner as g, HMRPayload as h, DEFAULT_REQUEST_STUBS as i };
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, D as DepsHandlingOptions, a as FetchFunction, F as FetchResult, H as HotContext, c as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, b as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, V as ViteNodeRunnerOptions, e as ViteNodeServerOptions } from './types-b59fb161.js';
|
package/dist/utils.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Vite as Node.js runtime",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
"types": "./dist/utils.d.ts",
|
|
35
35
|
"require": "./dist/utils.cjs",
|
|
36
36
|
"import": "./dist/utils.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./hmr": {
|
|
39
|
+
"types": "./dist/hmr.d.ts",
|
|
40
|
+
"require": "./dist/hmr.cjs",
|
|
41
|
+
"import": "./dist/hmr.mjs"
|
|
37
42
|
}
|
|
38
43
|
},
|
|
39
44
|
"main": "./dist/index.mjs",
|
|
@@ -63,7 +68,7 @@
|
|
|
63
68
|
"kolorist": "^1.5.1",
|
|
64
69
|
"mlly": "^0.5.3",
|
|
65
70
|
"pathe": "^0.2.0",
|
|
66
|
-
"vite": "^2.9.12"
|
|
71
|
+
"vite": "^2.9.12 || ^3.0.0-0"
|
|
67
72
|
},
|
|
68
73
|
"devDependencies": {
|
|
69
74
|
"@types/debug": "^4.1.7",
|
package/cli.d.ts
DELETED
package/client.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ViteNodeRunnerOptions, ModuleCache } from './types.js';
|
|
2
|
-
|
|
3
|
-
declare const DEFAULT_REQUEST_STUBS: {
|
|
4
|
-
'/@vite/client': {
|
|
5
|
-
injectQuery: (id: string) => string;
|
|
6
|
-
createHotContext(): {
|
|
7
|
-
accept: () => void;
|
|
8
|
-
prune: () => void;
|
|
9
|
-
};
|
|
10
|
-
updateStyle(): void;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
declare class ViteNodeRunner {
|
|
14
|
-
options: ViteNodeRunnerOptions;
|
|
15
|
-
root: string;
|
|
16
|
-
moduleCache: Map<string, ModuleCache>;
|
|
17
|
-
constructor(options: ViteNodeRunnerOptions);
|
|
18
|
-
executeFile(file: string): Promise<any>;
|
|
19
|
-
executeId(id: string): Promise<any>;
|
|
20
|
-
cachedRequest(rawId: string, callstack: string[]): Promise<any>;
|
|
21
|
-
directRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
|
|
22
|
-
prepareContext(context: Record<string, any>): Record<string, any>;
|
|
23
|
-
setCache(id: string, mod: Partial<ModuleCache>): void;
|
|
24
|
-
shouldResolveId(dep: string): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Define if a module should be interop-ed
|
|
27
|
-
* This function mostly for the ability to override by subclass
|
|
28
|
-
*/
|
|
29
|
-
shouldInterop(path: string, mod: any): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Import a module and interop it
|
|
32
|
-
*/
|
|
33
|
-
interopedImport(path: string): Promise<any>;
|
|
34
|
-
hasNestedDefault(target: any): any;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { DEFAULT_REQUEST_STUBS, ViteNodeRunner };
|
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DepsHandlingOptions, FetchFunction, FetchResult, ModuleCache, RawSourceMap, ResolveIdFunction, StartOfSourceMap, ViteNodeResolveId, ViteNodeRunnerOptions, ViteNodeServerOptions } from './types.js';
|
package/server.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ViteDevServer, TransformResult } from 'vite';
|
|
2
|
-
import { DepsHandlingOptions, ViteNodeServerOptions, FetchResult, ViteNodeResolveId } from './types.js';
|
|
3
|
-
|
|
4
|
-
declare function guessCJSversion(id: string): string | undefined;
|
|
5
|
-
declare function shouldExternalize(id: string, options?: DepsHandlingOptions, cache?: Map<string, Promise<string | false>>): Promise<string | false>;
|
|
6
|
-
|
|
7
|
-
declare class ViteNodeServer {
|
|
8
|
-
server: ViteDevServer;
|
|
9
|
-
options: ViteNodeServerOptions;
|
|
10
|
-
private fetchPromiseMap;
|
|
11
|
-
private transformPromiseMap;
|
|
12
|
-
fetchCache: Map<string, {
|
|
13
|
-
timestamp: number;
|
|
14
|
-
result: FetchResult;
|
|
15
|
-
}>;
|
|
16
|
-
constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
|
|
17
|
-
shouldExternalize(id: string): Promise<string | false>;
|
|
18
|
-
resolveId(id: string, importer?: string): Promise<ViteNodeResolveId | null>;
|
|
19
|
-
fetchModule(id: string): Promise<FetchResult>;
|
|
20
|
-
transformRequest(id: string): Promise<TransformResult | null | undefined>;
|
|
21
|
-
getTransformMode(id: string): "web" | "ssr";
|
|
22
|
-
private _fetchModule;
|
|
23
|
-
private _transformRequest;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { ViteNodeServer, guessCJSversion, shouldExternalize };
|
package/types.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
interface DepsHandlingOptions {
|
|
2
|
-
external?: (string | RegExp)[];
|
|
3
|
-
inline?: (string | RegExp)[];
|
|
4
|
-
/**
|
|
5
|
-
* Try to guess the CJS version of a package when it's invalid ESM
|
|
6
|
-
* @default true
|
|
7
|
-
*/
|
|
8
|
-
fallbackCJS?: boolean;
|
|
9
|
-
}
|
|
10
|
-
interface StartOfSourceMap {
|
|
11
|
-
file?: string;
|
|
12
|
-
sourceRoot?: string;
|
|
13
|
-
}
|
|
14
|
-
interface RawSourceMap extends StartOfSourceMap {
|
|
15
|
-
version: string;
|
|
16
|
-
sources: string[];
|
|
17
|
-
names: string[];
|
|
18
|
-
sourcesContent?: string[];
|
|
19
|
-
mappings: string;
|
|
20
|
-
}
|
|
21
|
-
interface FetchResult {
|
|
22
|
-
code?: string;
|
|
23
|
-
externalize?: string;
|
|
24
|
-
map?: RawSourceMap;
|
|
25
|
-
}
|
|
26
|
-
declare type FetchFunction = (id: string) => Promise<FetchResult>;
|
|
27
|
-
declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
|
|
28
|
-
interface ModuleCache {
|
|
29
|
-
promise?: Promise<any>;
|
|
30
|
-
exports?: any;
|
|
31
|
-
code?: string;
|
|
32
|
-
}
|
|
33
|
-
interface ViteNodeRunnerOptions {
|
|
34
|
-
fetchModule: FetchFunction;
|
|
35
|
-
resolveId: ResolveIdFunction;
|
|
36
|
-
root: string;
|
|
37
|
-
base?: string;
|
|
38
|
-
moduleCache?: Map<string, ModuleCache>;
|
|
39
|
-
interopDefault?: boolean;
|
|
40
|
-
requestStubs?: Record<string, any>;
|
|
41
|
-
}
|
|
42
|
-
interface ViteNodeResolveId {
|
|
43
|
-
external?: boolean | 'absolute' | 'relative';
|
|
44
|
-
id: string;
|
|
45
|
-
meta?: Record<string, any> | null;
|
|
46
|
-
moduleSideEffects?: boolean | 'no-treeshake' | null;
|
|
47
|
-
syntheticNamedExports?: boolean | string | null;
|
|
48
|
-
}
|
|
49
|
-
interface ViteNodeServerOptions {
|
|
50
|
-
/**
|
|
51
|
-
* Inject inline sourcemap to modules
|
|
52
|
-
* @default 'inline'
|
|
53
|
-
*/
|
|
54
|
-
sourcemap?: 'inline' | boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Deps handling
|
|
57
|
-
*/
|
|
58
|
-
deps?: DepsHandlingOptions;
|
|
59
|
-
/**
|
|
60
|
-
* Transform method for modules
|
|
61
|
-
*/
|
|
62
|
-
transformMode?: {
|
|
63
|
-
ssr?: RegExp[];
|
|
64
|
-
web?: RegExp[];
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export { DepsHandlingOptions, FetchFunction, FetchResult, ModuleCache, RawSourceMap, ResolveIdFunction, StartOfSourceMap, ViteNodeResolveId, ViteNodeRunnerOptions, ViteNodeServerOptions };
|
package/utils.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TransformResult } from 'vite';
|
|
2
|
-
|
|
3
|
-
declare const isWindows: boolean;
|
|
4
|
-
declare function slash(str: string): string;
|
|
5
|
-
declare function normalizeId(id: string, base?: string): string;
|
|
6
|
-
declare function isPrimitive(v: any): boolean;
|
|
7
|
-
declare function toFilePath(id: string, root: string): string;
|
|
8
|
-
declare function withInlineSourcemap(result: TransformResult): Promise<TransformResult>;
|
|
9
|
-
|
|
10
|
-
export { isPrimitive, isWindows, normalizeId, slash, toFilePath, withInlineSourcemap };
|