vite-node 0.17.0 → 0.17.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/chunk-client.cjs +12 -9
- package/dist/chunk-client.mjs +12 -9
- package/dist/chunk-hmr.cjs +3 -3
- package/dist/chunk-hmr.mjs +3 -3
- package/dist/chunk-utils.cjs +2 -2
- package/dist/chunk-utils.mjs +2 -2
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/package.json +1 -1
- 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-client.cjs
CHANGED
|
@@ -91,31 +91,34 @@ class ViteNodeRunner {
|
|
|
91
91
|
return await this.cachedRequest(id, []);
|
|
92
92
|
}
|
|
93
93
|
async cachedRequest(rawId, callstack) {
|
|
94
|
-
var _a, _b;
|
|
94
|
+
var _a, _b, _c, _d;
|
|
95
95
|
const id = utils.normalizeRequestId(rawId, this.options.base);
|
|
96
96
|
const fsPath = utils.toFilePath(id, this.root);
|
|
97
|
-
if ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.
|
|
98
|
-
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.
|
|
97
|
+
if (callstack.includes(fsPath) && ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.exports))
|
|
98
|
+
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.exports;
|
|
99
|
+
if ((_c = this.moduleCache.get(fsPath)) == null ? void 0 : _c.promise)
|
|
100
|
+
return (_d = this.moduleCache.get(fsPath)) == null ? void 0 : _d.promise;
|
|
99
101
|
const promise = this.directRequest(id, fsPath, callstack);
|
|
100
102
|
this.moduleCache.set(fsPath, { promise });
|
|
101
103
|
return await promise;
|
|
102
104
|
}
|
|
103
105
|
async directRequest(id, fsPath, _callstack) {
|
|
104
|
-
const callstack = [..._callstack,
|
|
106
|
+
const callstack = [..._callstack, fsPath];
|
|
105
107
|
const request = async (dep) => {
|
|
106
108
|
var _a;
|
|
109
|
+
const fsPath2 = utils.toFilePath(utils.normalizeRequestId(dep, this.options.base), this.root);
|
|
107
110
|
const getStack = () => {
|
|
108
111
|
return `stack:
|
|
109
|
-
${[...callstack,
|
|
112
|
+
${[...callstack, fsPath2].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
110
113
|
};
|
|
111
114
|
let debugTimer;
|
|
112
115
|
if (this.debug)
|
|
113
|
-
debugTimer = setTimeout(() => this.debugLog(() => `module ${
|
|
116
|
+
debugTimer = setTimeout(() => this.debugLog(() => `module ${fsPath2} takes over 2s to load.
|
|
114
117
|
${getStack()}`), 2e3);
|
|
115
118
|
try {
|
|
116
|
-
if (callstack.includes(
|
|
119
|
+
if (callstack.includes(fsPath2)) {
|
|
117
120
|
this.debugLog(() => `circular dependency, ${getStack()}`);
|
|
118
|
-
const depExports = (_a = this.moduleCache.get(
|
|
121
|
+
const depExports = (_a = this.moduleCache.get(fsPath2)) == null ? void 0 : _a.exports;
|
|
119
122
|
if (depExports)
|
|
120
123
|
return depExports;
|
|
121
124
|
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
@@ -155,7 +158,7 @@ ${getStack()}`), 2e3);
|
|
|
155
158
|
const meta = { url: url$1 };
|
|
156
159
|
const exports = /* @__PURE__ */ Object.create(null);
|
|
157
160
|
exports[Symbol.toStringTag] = "Module";
|
|
158
|
-
this.moduleCache.set(
|
|
161
|
+
this.moduleCache.set(fsPath, { code: transformed, exports });
|
|
159
162
|
const __filename = url.fileURLToPath(url$1);
|
|
160
163
|
const moduleProxy = {
|
|
161
164
|
set exports(value) {
|
package/dist/chunk-client.mjs
CHANGED
|
@@ -66,31 +66,34 @@ class ViteNodeRunner {
|
|
|
66
66
|
return await this.cachedRequest(id, []);
|
|
67
67
|
}
|
|
68
68
|
async cachedRequest(rawId, callstack) {
|
|
69
|
-
var _a, _b;
|
|
69
|
+
var _a, _b, _c, _d;
|
|
70
70
|
const id = normalizeRequestId(rawId, this.options.base);
|
|
71
71
|
const fsPath = toFilePath(id, this.root);
|
|
72
|
-
if ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.
|
|
73
|
-
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.
|
|
72
|
+
if (callstack.includes(fsPath) && ((_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.exports))
|
|
73
|
+
return (_b = this.moduleCache.get(fsPath)) == null ? void 0 : _b.exports;
|
|
74
|
+
if ((_c = this.moduleCache.get(fsPath)) == null ? void 0 : _c.promise)
|
|
75
|
+
return (_d = this.moduleCache.get(fsPath)) == null ? void 0 : _d.promise;
|
|
74
76
|
const promise = this.directRequest(id, fsPath, callstack);
|
|
75
77
|
this.moduleCache.set(fsPath, { promise });
|
|
76
78
|
return await promise;
|
|
77
79
|
}
|
|
78
80
|
async directRequest(id, fsPath, _callstack) {
|
|
79
|
-
const callstack = [..._callstack,
|
|
81
|
+
const callstack = [..._callstack, fsPath];
|
|
80
82
|
const request = async (dep) => {
|
|
81
83
|
var _a;
|
|
84
|
+
const fsPath2 = toFilePath(normalizeRequestId(dep, this.options.base), this.root);
|
|
82
85
|
const getStack = () => {
|
|
83
86
|
return `stack:
|
|
84
|
-
${[...callstack,
|
|
87
|
+
${[...callstack, fsPath2].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
85
88
|
};
|
|
86
89
|
let debugTimer;
|
|
87
90
|
if (this.debug)
|
|
88
|
-
debugTimer = setTimeout(() => this.debugLog(() => `module ${
|
|
91
|
+
debugTimer = setTimeout(() => this.debugLog(() => `module ${fsPath2} takes over 2s to load.
|
|
89
92
|
${getStack()}`), 2e3);
|
|
90
93
|
try {
|
|
91
|
-
if (callstack.includes(
|
|
94
|
+
if (callstack.includes(fsPath2)) {
|
|
92
95
|
this.debugLog(() => `circular dependency, ${getStack()}`);
|
|
93
|
-
const depExports = (_a = this.moduleCache.get(
|
|
96
|
+
const depExports = (_a = this.moduleCache.get(fsPath2)) == null ? void 0 : _a.exports;
|
|
94
97
|
if (depExports)
|
|
95
98
|
return depExports;
|
|
96
99
|
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
@@ -130,7 +133,7 @@ ${getStack()}`), 2e3);
|
|
|
130
133
|
const meta = { url };
|
|
131
134
|
const exports = /* @__PURE__ */ Object.create(null);
|
|
132
135
|
exports[Symbol.toStringTag] = "Module";
|
|
133
|
-
this.moduleCache.set(
|
|
136
|
+
this.moduleCache.set(fsPath, { code: transformed, exports });
|
|
134
137
|
const __filename = fileURLToPath(url);
|
|
135
138
|
const moduleProxy = {
|
|
136
139
|
set exports(value) {
|
package/dist/chunk-hmr.cjs
CHANGED
|
@@ -52,9 +52,9 @@ function sendMessageBuffer(runner, emitter) {
|
|
|
52
52
|
maps.messageBuffer.length = 0;
|
|
53
53
|
}
|
|
54
54
|
async function reload(runner, files) {
|
|
55
|
-
Array.from(runner.moduleCache.keys()).forEach((
|
|
56
|
-
if (!
|
|
57
|
-
runner.moduleCache.delete(
|
|
55
|
+
Array.from(runner.moduleCache.keys()).forEach((fsPath) => {
|
|
56
|
+
if (!fsPath.includes("node_modules"))
|
|
57
|
+
runner.moduleCache.delete(fsPath);
|
|
58
58
|
});
|
|
59
59
|
return Promise.all(files.map((file) => runner.executeId(file)));
|
|
60
60
|
}
|
package/dist/chunk-hmr.mjs
CHANGED
|
@@ -46,9 +46,9 @@ function sendMessageBuffer(runner, emitter) {
|
|
|
46
46
|
maps.messageBuffer.length = 0;
|
|
47
47
|
}
|
|
48
48
|
async function reload(runner, files) {
|
|
49
|
-
Array.from(runner.moduleCache.keys()).forEach((
|
|
50
|
-
if (!
|
|
51
|
-
runner.moduleCache.delete(
|
|
49
|
+
Array.from(runner.moduleCache.keys()).forEach((fsPath) => {
|
|
50
|
+
if (!fsPath.includes("node_modules"))
|
|
51
|
+
runner.moduleCache.delete(fsPath);
|
|
52
52
|
});
|
|
53
53
|
return Promise.all(files.map((file) => runner.executeId(file)));
|
|
54
54
|
}
|
package/dist/chunk-utils.cjs
CHANGED
|
@@ -22,10 +22,10 @@ function isPrimitive(v) {
|
|
|
22
22
|
return v !== Object(v);
|
|
23
23
|
}
|
|
24
24
|
function toFilePath(id, root) {
|
|
25
|
-
let absolute =
|
|
25
|
+
let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? pathe.resolve(root, id.slice(1)) : id;
|
|
26
26
|
if (absolute.startsWith("//"))
|
|
27
27
|
absolute = absolute.slice(1);
|
|
28
|
-
return isWindows && absolute.startsWith("/") ? url.fileURLToPath(url.pathToFileURL(absolute.slice(1)).href) : absolute;
|
|
28
|
+
return isWindows && absolute.startsWith("/") ? slash(url.fileURLToPath(url.pathToFileURL(absolute.slice(1)).href)) : absolute;
|
|
29
29
|
}
|
|
30
30
|
let SOURCEMAPPING_URL = "sourceMa";
|
|
31
31
|
SOURCEMAPPING_URL += "ppingURL";
|
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
|
@@ -628,7 +628,7 @@ class CAC extends events.EventEmitter {
|
|
|
628
628
|
|
|
629
629
|
const cac = (name = "") => new CAC(name);
|
|
630
630
|
|
|
631
|
-
var version = "0.17.
|
|
631
|
+
var version = "0.17.1";
|
|
632
632
|
|
|
633
633
|
const cli = cac("vite-node");
|
|
634
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();
|
package/dist/cli.mjs
CHANGED
|
@@ -626,7 +626,7 @@ class CAC extends EventEmitter {
|
|
|
626
626
|
|
|
627
627
|
const cac = (name = "") => new CAC(name);
|
|
628
628
|
|
|
629
|
-
var version = "0.17.
|
|
629
|
+
var version = "0.17.1";
|
|
630
630
|
|
|
631
631
|
const cli = cac("vite-node");
|
|
632
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();
|
package/package.json
CHANGED
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 };
|