vite-node 0.31.4 → 0.32.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.cjs +2 -2
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/client.cjs +32 -15
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +32 -15
- package/dist/hmr.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/server.cjs +1 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.mjs +1 -0
- package/dist/{types-33f0e4ff.d.ts → types-516036fa.d.ts} +4 -3
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -6,8 +6,8 @@ var vite = require('vite');
|
|
|
6
6
|
var server = require('./server.cjs');
|
|
7
7
|
var client = require('./client.cjs');
|
|
8
8
|
var utils = require('./utils.cjs');
|
|
9
|
-
var hmr = require('./chunk-hmr.cjs');
|
|
10
9
|
var sourceMap = require('./source-map.cjs');
|
|
10
|
+
var hmr = require('./chunk-hmr.cjs');
|
|
11
11
|
require('perf_hooks');
|
|
12
12
|
require('fs');
|
|
13
13
|
require('pathe');
|
|
@@ -24,7 +24,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
24
24
|
var cac__default = /*#__PURE__*/_interopDefaultLegacy(cac);
|
|
25
25
|
var c__default = /*#__PURE__*/_interopDefaultLegacy(c);
|
|
26
26
|
|
|
27
|
-
var version = "0.
|
|
27
|
+
var version = "0.32.0";
|
|
28
28
|
|
|
29
29
|
const cli = cac__default["default"]("vite-node");
|
|
30
30
|
cli.version(version).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").help();
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import 'node:path';
|
|
|
17
17
|
import 'node:vm';
|
|
18
18
|
import 'node:events';
|
|
19
19
|
|
|
20
|
-
var version = "0.
|
|
20
|
+
var version = "0.32.0";
|
|
21
21
|
|
|
22
22
|
const cli = cac("vite-node");
|
|
23
23
|
cli.version(version).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").help();
|
package/dist/client.cjs
CHANGED
|
@@ -86,7 +86,7 @@ class ModuleCacheMap extends Map {
|
|
|
86
86
|
update(fsPath, mod) {
|
|
87
87
|
fsPath = this.normalizePath(fsPath);
|
|
88
88
|
if (!super.has(fsPath))
|
|
89
|
-
|
|
89
|
+
this.setByModuleId(fsPath, mod);
|
|
90
90
|
else
|
|
91
91
|
Object.assign(super.get(fsPath), mod);
|
|
92
92
|
return this;
|
|
@@ -99,8 +99,15 @@ class ModuleCacheMap extends Map {
|
|
|
99
99
|
}
|
|
100
100
|
getByModuleId(modulePath) {
|
|
101
101
|
if (!super.has(modulePath))
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
this.setByModuleId(modulePath, {});
|
|
103
|
+
const mod = super.get(modulePath);
|
|
104
|
+
if (!mod.imports) {
|
|
105
|
+
Object.assign(mod, {
|
|
106
|
+
imports: /* @__PURE__ */ new Set(),
|
|
107
|
+
importers: /* @__PURE__ */ new Set()
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return mod;
|
|
104
111
|
}
|
|
105
112
|
get(fsPath) {
|
|
106
113
|
return this.getByModuleId(this.normalizePath(fsPath));
|
|
@@ -112,12 +119,13 @@ class ModuleCacheMap extends Map {
|
|
|
112
119
|
return this.deleteByModuleId(this.normalizePath(fsPath));
|
|
113
120
|
}
|
|
114
121
|
invalidateModule(mod) {
|
|
115
|
-
var _a;
|
|
122
|
+
var _a, _b;
|
|
116
123
|
delete mod.evaluated;
|
|
117
124
|
delete mod.resolving;
|
|
118
125
|
delete mod.promise;
|
|
119
126
|
delete mod.exports;
|
|
120
127
|
(_a = mod.importers) == null ? void 0 : _a.clear();
|
|
128
|
+
(_b = mod.imports) == null ? void 0 : _b.clear();
|
|
121
129
|
return true;
|
|
122
130
|
}
|
|
123
131
|
/**
|
|
@@ -188,16 +196,12 @@ class ViteNodeRunner {
|
|
|
188
196
|
async cachedRequest(id, fsPath, callstack) {
|
|
189
197
|
const importee = callstack[callstack.length - 1];
|
|
190
198
|
const mod = this.moduleCache.get(fsPath);
|
|
191
|
-
|
|
192
|
-
mod.importers = /* @__PURE__ */ new Set();
|
|
199
|
+
const { imports, importers } = mod;
|
|
193
200
|
if (importee)
|
|
194
|
-
|
|
201
|
+
importers.add(importee);
|
|
195
202
|
const getStack = () => `stack:
|
|
196
203
|
${[...callstack, fsPath].reverse().map((p) => ` - ${p}`).join("\n")}`;
|
|
197
|
-
if (callstack.includes(fsPath) ||
|
|
198
|
-
var _a;
|
|
199
|
-
return (_a = this.moduleCache.get(c).importers) == null ? void 0 : _a.has(fsPath);
|
|
200
|
-
})) {
|
|
204
|
+
if (callstack.includes(fsPath) || Array.from(imports.values()).some((i) => importers.has(i))) {
|
|
201
205
|
if (mod.exports)
|
|
202
206
|
return mod.exports;
|
|
203
207
|
}
|
|
@@ -218,7 +222,7 @@ ${getStack()}`), 2e3);
|
|
|
218
222
|
}
|
|
219
223
|
}
|
|
220
224
|
shouldResolveId(id, _importee) {
|
|
221
|
-
return !utils.isInternalRequest(id) && !utils.isNodeBuiltin(id);
|
|
225
|
+
return !utils.isInternalRequest(id) && !utils.isNodeBuiltin(id) && !id.startsWith("data:");
|
|
222
226
|
}
|
|
223
227
|
async _resolveUrl(id, importer) {
|
|
224
228
|
if (importer && id.startsWith(utils.VALID_ID_PREFIX))
|
|
@@ -230,9 +234,19 @@ ${getStack()}`), 2e3);
|
|
|
230
234
|
if (!this.options.resolveId || exists)
|
|
231
235
|
return [id, path];
|
|
232
236
|
const resolved = await this.options.resolveId(id, importer);
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
237
|
+
if (!resolved) {
|
|
238
|
+
const error = new Error(
|
|
239
|
+
`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
|
|
240
|
+
|
|
241
|
+
- If you rely on tsconfig.json to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution.
|
|
242
|
+
- Make sure you don't have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors`
|
|
243
|
+
);
|
|
244
|
+
Object.defineProperty(error, "code", { value: "ERR_MODULE_NOT_FOUND", enumerable: true });
|
|
245
|
+
Object.defineProperty(error, Symbol.for("vitest.error.not_found.data"), { value: { id, importer }, enumerable: false });
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
const resolvedId = utils.normalizeRequestId(resolved.id, this.options.base);
|
|
249
|
+
return [resolvedId, resolvedId];
|
|
236
250
|
}
|
|
237
251
|
async resolveUrl(id, importee) {
|
|
238
252
|
const resolveKey = `resolve:${id}`;
|
|
@@ -254,6 +268,9 @@ ${getStack()}`), 2e3);
|
|
|
254
268
|
const mod = this.moduleCache.getByModuleId(moduleId);
|
|
255
269
|
const request = async (dep) => {
|
|
256
270
|
const [id2, depFsPath] = await this.resolveUrl(`${dep}`, fsPath);
|
|
271
|
+
const depMod = this.moduleCache.getByModuleId(depFsPath);
|
|
272
|
+
depMod.importers.add(moduleId);
|
|
273
|
+
mod.imports.add(depFsPath);
|
|
257
274
|
return this.dependencyRequest(id2, depFsPath, callstack);
|
|
258
275
|
};
|
|
259
276
|
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './types.d-7442d07f.js';
|
|
2
|
-
export { i as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-
|
|
2
|
+
export { i as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-516036fa.js';
|
|
3
3
|
import 'vite/types/hot';
|
package/dist/client.mjs
CHANGED
|
@@ -59,7 +59,7 @@ class ModuleCacheMap extends Map {
|
|
|
59
59
|
update(fsPath, mod) {
|
|
60
60
|
fsPath = this.normalizePath(fsPath);
|
|
61
61
|
if (!super.has(fsPath))
|
|
62
|
-
|
|
62
|
+
this.setByModuleId(fsPath, mod);
|
|
63
63
|
else
|
|
64
64
|
Object.assign(super.get(fsPath), mod);
|
|
65
65
|
return this;
|
|
@@ -72,8 +72,15 @@ class ModuleCacheMap extends Map {
|
|
|
72
72
|
}
|
|
73
73
|
getByModuleId(modulePath) {
|
|
74
74
|
if (!super.has(modulePath))
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
this.setByModuleId(modulePath, {});
|
|
76
|
+
const mod = super.get(modulePath);
|
|
77
|
+
if (!mod.imports) {
|
|
78
|
+
Object.assign(mod, {
|
|
79
|
+
imports: /* @__PURE__ */ new Set(),
|
|
80
|
+
importers: /* @__PURE__ */ new Set()
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return mod;
|
|
77
84
|
}
|
|
78
85
|
get(fsPath) {
|
|
79
86
|
return this.getByModuleId(this.normalizePath(fsPath));
|
|
@@ -85,12 +92,13 @@ class ModuleCacheMap extends Map {
|
|
|
85
92
|
return this.deleteByModuleId(this.normalizePath(fsPath));
|
|
86
93
|
}
|
|
87
94
|
invalidateModule(mod) {
|
|
88
|
-
var _a;
|
|
95
|
+
var _a, _b;
|
|
89
96
|
delete mod.evaluated;
|
|
90
97
|
delete mod.resolving;
|
|
91
98
|
delete mod.promise;
|
|
92
99
|
delete mod.exports;
|
|
93
100
|
(_a = mod.importers) == null ? void 0 : _a.clear();
|
|
101
|
+
(_b = mod.imports) == null ? void 0 : _b.clear();
|
|
94
102
|
return true;
|
|
95
103
|
}
|
|
96
104
|
/**
|
|
@@ -161,16 +169,12 @@ class ViteNodeRunner {
|
|
|
161
169
|
async cachedRequest(id, fsPath, callstack) {
|
|
162
170
|
const importee = callstack[callstack.length - 1];
|
|
163
171
|
const mod = this.moduleCache.get(fsPath);
|
|
164
|
-
|
|
165
|
-
mod.importers = /* @__PURE__ */ new Set();
|
|
172
|
+
const { imports, importers } = mod;
|
|
166
173
|
if (importee)
|
|
167
|
-
|
|
174
|
+
importers.add(importee);
|
|
168
175
|
const getStack = () => `stack:
|
|
169
176
|
${[...callstack, fsPath].reverse().map((p) => ` - ${p}`).join("\n")}`;
|
|
170
|
-
if (callstack.includes(fsPath) ||
|
|
171
|
-
var _a;
|
|
172
|
-
return (_a = this.moduleCache.get(c).importers) == null ? void 0 : _a.has(fsPath);
|
|
173
|
-
})) {
|
|
177
|
+
if (callstack.includes(fsPath) || Array.from(imports.values()).some((i) => importers.has(i))) {
|
|
174
178
|
if (mod.exports)
|
|
175
179
|
return mod.exports;
|
|
176
180
|
}
|
|
@@ -191,7 +195,7 @@ ${getStack()}`), 2e3);
|
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
197
|
shouldResolveId(id, _importee) {
|
|
194
|
-
return !isInternalRequest(id) && !isNodeBuiltin(id);
|
|
198
|
+
return !isInternalRequest(id) && !isNodeBuiltin(id) && !id.startsWith("data:");
|
|
195
199
|
}
|
|
196
200
|
async _resolveUrl(id, importer) {
|
|
197
201
|
if (importer && id.startsWith(VALID_ID_PREFIX))
|
|
@@ -203,9 +207,19 @@ ${getStack()}`), 2e3);
|
|
|
203
207
|
if (!this.options.resolveId || exists)
|
|
204
208
|
return [id, path];
|
|
205
209
|
const resolved = await this.options.resolveId(id, importer);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
if (!resolved) {
|
|
211
|
+
const error = new Error(
|
|
212
|
+
`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
|
|
213
|
+
|
|
214
|
+
- If you rely on tsconfig.json to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution.
|
|
215
|
+
- Make sure you don't have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors`
|
|
216
|
+
);
|
|
217
|
+
Object.defineProperty(error, "code", { value: "ERR_MODULE_NOT_FOUND", enumerable: true });
|
|
218
|
+
Object.defineProperty(error, Symbol.for("vitest.error.not_found.data"), { value: { id, importer }, enumerable: false });
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
const resolvedId = normalizeRequestId(resolved.id, this.options.base);
|
|
222
|
+
return [resolvedId, resolvedId];
|
|
209
223
|
}
|
|
210
224
|
async resolveUrl(id, importee) {
|
|
211
225
|
const resolveKey = `resolve:${id}`;
|
|
@@ -227,6 +241,9 @@ ${getStack()}`), 2e3);
|
|
|
227
241
|
const mod = this.moduleCache.getByModuleId(moduleId);
|
|
228
242
|
const request = async (dep) => {
|
|
229
243
|
const [id2, depFsPath] = await this.resolveUrl(`${dep}`, fsPath);
|
|
244
|
+
const depMod = this.moduleCache.getByModuleId(depFsPath);
|
|
245
|
+
depMod.importers.add(moduleId);
|
|
246
|
+
mod.imports.add(depFsPath);
|
|
230
247
|
return this.dependencyRequest(id2, depFsPath, callstack);
|
|
231
248
|
};
|
|
232
249
|
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
package/dist/hmr.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import { HMRPayload as HMRPayload$1, Plugin } from 'vite';
|
|
3
|
-
import { h as ViteNodeRunner, H as HotContext } from './types-
|
|
3
|
+
import { h as ViteNodeRunner, H as HotContext } from './types-516036fa.js';
|
|
4
4
|
import 'vite/types/hot';
|
|
5
5
|
import './types.d-7442d07f.js';
|
|
6
6
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as Arrayable, a as Awaitable, C as CreateHotContextFunction, g as DebuggerOptions, D as DepsHandlingOptions, b as FetchFunction, F as FetchResult, H as HotContext, d as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, c as ResolveIdFunction, S as StartOfSourceMap, e as ViteNodeResolveId, V as ViteNodeRunnerOptions, f as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, a as Awaitable, C as CreateHotContextFunction, g as DebuggerOptions, D as DepsHandlingOptions, b as FetchFunction, F as FetchResult, H as HotContext, d as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, c as ResolveIdFunction, S as StartOfSourceMap, e as ViteNodeResolveId, V as ViteNodeRunnerOptions, f as ViteNodeServerOptions } from './types-516036fa.js';
|
|
2
2
|
export { D as DecodedSourceMap, E as EncodedSourceMap } from './types.d-7442d07f.js';
|
|
3
3
|
import 'vite/types/hot';
|
package/dist/server.cjs
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
2
|
import { E as EncodedSourceMap } from './types.d-7442d07f.js';
|
|
3
|
-
import { g as DebuggerOptions, D as DepsHandlingOptions, f as ViteNodeServerOptions, F as FetchResult, e as ViteNodeResolveId } from './types-
|
|
3
|
+
import { g as DebuggerOptions, D as DepsHandlingOptions, f as ViteNodeServerOptions, F as FetchResult, e as ViteNodeResolveId } from './types-516036fa.js';
|
|
4
4
|
import 'vite/types/hot';
|
|
5
5
|
|
|
6
6
|
declare class Debugger {
|
package/dist/server.mjs
CHANGED
|
@@ -7,11 +7,11 @@ declare class ModuleCacheMap extends Map<string, ModuleCache> {
|
|
|
7
7
|
/**
|
|
8
8
|
* Assign partial data to the map
|
|
9
9
|
*/
|
|
10
|
-
update(fsPath: string, mod:
|
|
10
|
+
update(fsPath: string, mod: ModuleCache): this;
|
|
11
11
|
setByModuleId(modulePath: string, mod: ModuleCache): this;
|
|
12
12
|
set(fsPath: string, mod: ModuleCache): this;
|
|
13
|
-
getByModuleId(modulePath: string): ModuleCache
|
|
14
|
-
get(fsPath: string): ModuleCache
|
|
13
|
+
getByModuleId(modulePath: string): ModuleCache & Required<Pick<ModuleCache, "imports" | "importers">>;
|
|
14
|
+
get(fsPath: string): ModuleCache & Required<Pick<ModuleCache, "imports" | "importers">>;
|
|
15
15
|
deleteByModuleId(modulePath: string): boolean;
|
|
16
16
|
delete(fsPath: string): boolean;
|
|
17
17
|
invalidateModule(mod: ModuleCache): boolean;
|
|
@@ -115,6 +115,7 @@ interface ModuleCache {
|
|
|
115
115
|
* Module ids that imports this module
|
|
116
116
|
*/
|
|
117
117
|
importers?: Set<string>;
|
|
118
|
+
imports?: Set<string>;
|
|
118
119
|
}
|
|
119
120
|
interface ViteNodeRunnerOptions {
|
|
120
121
|
root: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'vite/types/hot';
|
|
2
2
|
export { D as DecodedSourceMap, E as EncodedSourceMap } from './types.d-7442d07f.js';
|
|
3
|
-
export { A as Arrayable, a as Awaitable, C as CreateHotContextFunction, g as DebuggerOptions, D as DepsHandlingOptions, b as FetchFunction, F as FetchResult, H as HotContext, d as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, c as ResolveIdFunction, S as StartOfSourceMap, e as ViteNodeResolveId, V as ViteNodeRunnerOptions, f as ViteNodeServerOptions } from './types-
|
|
3
|
+
export { A as Arrayable, a as Awaitable, C as CreateHotContextFunction, g as DebuggerOptions, D as DepsHandlingOptions, b as FetchFunction, F as FetchResult, H as HotContext, d as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, c as ResolveIdFunction, S as StartOfSourceMap, e as ViteNodeResolveId, V as ViteNodeRunnerOptions, f as ViteNodeServerOptions } from './types-516036fa.js';
|
package/dist/utils.d.ts
CHANGED