vite-node 0.31.4 → 0.32.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/cli.cjs +2 -2
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/client.cjs +29 -23
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +29 -23
- 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.1";
|
|
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.1";
|
|
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,21 +222,20 @@ ${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))
|
|
225
229
|
importer = void 0;
|
|
226
|
-
|
|
227
|
-
if (!this.shouldResolveId(
|
|
228
|
-
return [
|
|
229
|
-
const { path, exists } = utils.toFilePath(
|
|
230
|
+
const dep = utils.normalizeRequestId(id, this.options.base);
|
|
231
|
+
if (!this.shouldResolveId(dep))
|
|
232
|
+
return [dep, dep];
|
|
233
|
+
const { path, exists } = utils.toFilePath(dep, this.root);
|
|
230
234
|
if (!this.options.resolveId || exists)
|
|
231
|
-
return [
|
|
232
|
-
const resolved = await this.options.resolveId(
|
|
233
|
-
const resolvedId = resolved ? utils.normalizeRequestId(resolved.id, this.options.base) :
|
|
234
|
-
|
|
235
|
-
return [resolvedId, fsPath];
|
|
235
|
+
return [dep, path];
|
|
236
|
+
const resolved = await this.options.resolveId(dep, importer);
|
|
237
|
+
const resolvedId = resolved ? utils.normalizeRequestId(resolved.id, this.options.base) : dep;
|
|
238
|
+
return [resolvedId, resolvedId];
|
|
236
239
|
}
|
|
237
240
|
async resolveUrl(id, importee) {
|
|
238
241
|
const resolveKey = `resolve:${id}`;
|
|
@@ -253,7 +256,10 @@ ${getStack()}`), 2e3);
|
|
|
253
256
|
const callstack = [..._callstack, moduleId];
|
|
254
257
|
const mod = this.moduleCache.getByModuleId(moduleId);
|
|
255
258
|
const request = async (dep) => {
|
|
256
|
-
const [id2, depFsPath] = await this.resolveUrl(
|
|
259
|
+
const [id2, depFsPath] = await this.resolveUrl(String(dep), fsPath);
|
|
260
|
+
const depMod = this.moduleCache.getByModuleId(depFsPath);
|
|
261
|
+
depMod.importers.add(moduleId);
|
|
262
|
+
mod.imports.add(depFsPath);
|
|
257
263
|
return this.dependencyRequest(id2, depFsPath, callstack);
|
|
258
264
|
};
|
|
259
265
|
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
@@ -285,7 +291,7 @@ ${getStack()}`), 2e3);
|
|
|
285
291
|
},
|
|
286
292
|
getPrototypeOf: () => Object.prototype,
|
|
287
293
|
set: (_, p, value) => {
|
|
288
|
-
if (p === "default" && this.shouldInterop(modulePath, { default: value })) {
|
|
294
|
+
if (p === "default" && this.shouldInterop(modulePath, { default: value }) && cjsExports !== value) {
|
|
289
295
|
exportAll(cjsExports, value);
|
|
290
296
|
exports.default = value;
|
|
291
297
|
return true;
|
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,21 +195,20 @@ ${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))
|
|
198
202
|
importer = void 0;
|
|
199
|
-
|
|
200
|
-
if (!this.shouldResolveId(
|
|
201
|
-
return [
|
|
202
|
-
const { path, exists } = toFilePath(
|
|
203
|
+
const dep = normalizeRequestId(id, this.options.base);
|
|
204
|
+
if (!this.shouldResolveId(dep))
|
|
205
|
+
return [dep, dep];
|
|
206
|
+
const { path, exists } = toFilePath(dep, this.root);
|
|
203
207
|
if (!this.options.resolveId || exists)
|
|
204
|
-
return [
|
|
205
|
-
const resolved = await this.options.resolveId(
|
|
206
|
-
const resolvedId = resolved ? normalizeRequestId(resolved.id, this.options.base) :
|
|
207
|
-
|
|
208
|
-
return [resolvedId, fsPath];
|
|
208
|
+
return [dep, path];
|
|
209
|
+
const resolved = await this.options.resolveId(dep, importer);
|
|
210
|
+
const resolvedId = resolved ? normalizeRequestId(resolved.id, this.options.base) : dep;
|
|
211
|
+
return [resolvedId, resolvedId];
|
|
209
212
|
}
|
|
210
213
|
async resolveUrl(id, importee) {
|
|
211
214
|
const resolveKey = `resolve:${id}`;
|
|
@@ -226,7 +229,10 @@ ${getStack()}`), 2e3);
|
|
|
226
229
|
const callstack = [..._callstack, moduleId];
|
|
227
230
|
const mod = this.moduleCache.getByModuleId(moduleId);
|
|
228
231
|
const request = async (dep) => {
|
|
229
|
-
const [id2, depFsPath] = await this.resolveUrl(
|
|
232
|
+
const [id2, depFsPath] = await this.resolveUrl(String(dep), fsPath);
|
|
233
|
+
const depMod = this.moduleCache.getByModuleId(depFsPath);
|
|
234
|
+
depMod.importers.add(moduleId);
|
|
235
|
+
mod.imports.add(depFsPath);
|
|
230
236
|
return this.dependencyRequest(id2, depFsPath, callstack);
|
|
231
237
|
};
|
|
232
238
|
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
@@ -258,7 +264,7 @@ ${getStack()}`), 2e3);
|
|
|
258
264
|
},
|
|
259
265
|
getPrototypeOf: () => Object.prototype,
|
|
260
266
|
set: (_, p, value) => {
|
|
261
|
-
if (p === "default" && this.shouldInterop(modulePath, { default: value })) {
|
|
267
|
+
if (p === "default" && this.shouldInterop(modulePath, { default: value }) && cjsExports !== value) {
|
|
262
268
|
exportAll(cjsExports, value);
|
|
263
269
|
exports.default = value;
|
|
264
270
|
return true;
|
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