vite-node 0.25.5 → 0.25.6
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 +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/client.cjs +18 -14
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +19 -15
- package/dist/hmr.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/server.cjs +1 -9
- package/dist/server.d.ts +1 -1
- package/dist/server.mjs +2 -10
- package/dist/source-map.d.ts +1 -1
- package/dist/{types-de49c638.d.ts → types-60eb9672.d.ts} +0 -2
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -632,7 +632,7 @@ class CAC extends events.EventEmitter {
|
|
|
632
632
|
|
|
633
633
|
const cac = (name = "") => new CAC(name);
|
|
634
634
|
|
|
635
|
-
var version = "0.25.
|
|
635
|
+
var version = "0.25.6";
|
|
636
636
|
|
|
637
637
|
const cli = cac("vite-node");
|
|
638
638
|
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.d.ts
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -630,7 +630,7 @@ class CAC extends EventEmitter {
|
|
|
630
630
|
|
|
631
631
|
const cac = (name = "") => new CAC(name);
|
|
632
632
|
|
|
633
|
-
var version = "0.25.
|
|
633
|
+
var version = "0.25.6";
|
|
634
634
|
|
|
635
635
|
const cli = cac("vite-node");
|
|
636
636
|
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/client.cjs
CHANGED
|
@@ -177,9 +177,9 @@ class ViteNodeRunner {
|
|
|
177
177
|
async directRequest(id, fsPath, _callstack) {
|
|
178
178
|
const callstack = [..._callstack, fsPath];
|
|
179
179
|
let mod = this.moduleCache.get(fsPath);
|
|
180
|
-
const request = async (
|
|
180
|
+
const request = async (dep2) => {
|
|
181
181
|
var _a;
|
|
182
|
-
const depFsPath = utils.toFilePath(utils.normalizeRequestId(
|
|
182
|
+
const depFsPath = utils.toFilePath(utils.normalizeRequestId(dep2, this.options.base), this.root);
|
|
183
183
|
const getStack = () => {
|
|
184
184
|
return `stack:
|
|
185
185
|
${[...callstack, depFsPath].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
@@ -195,37 +195,40 @@ ${getStack()}`), 2e3);
|
|
|
195
195
|
return depExports;
|
|
196
196
|
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
197
197
|
}
|
|
198
|
-
return await this.cachedRequest(
|
|
198
|
+
return await this.cachedRequest(dep2, callstack);
|
|
199
199
|
} finally {
|
|
200
200
|
if (debugTimer)
|
|
201
201
|
clearTimeout(debugTimer);
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
204
|
Object.defineProperty(request, "callstack", { get: () => callstack });
|
|
205
|
-
const resolveId = async (
|
|
206
|
-
if (this.options.resolveId && this.shouldResolveId(
|
|
205
|
+
const resolveId = async (dep2, callstackPosition = 1) => {
|
|
206
|
+
if (this.options.resolveId && this.shouldResolveId(dep2)) {
|
|
207
207
|
let importer = callstack[callstack.length - callstackPosition];
|
|
208
|
+
if (importer && !dep2.startsWith("."))
|
|
209
|
+
importer = void 0;
|
|
208
210
|
if (importer && importer.startsWith("mock:"))
|
|
209
211
|
importer = importer.slice(5);
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
+
const resolved = await this.options.resolveId(utils.normalizeRequestId(dep2), importer);
|
|
213
|
+
return [dep2, resolved == null ? void 0 : resolved.id];
|
|
212
214
|
}
|
|
213
|
-
return
|
|
215
|
+
return [dep2, void 0];
|
|
214
216
|
};
|
|
217
|
+
const [dep, resolvedId] = await resolveId(id, 2);
|
|
215
218
|
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
216
219
|
if (id in requestStubs)
|
|
217
220
|
return requestStubs[id];
|
|
218
|
-
let { code: transformed, externalize
|
|
219
|
-
if (
|
|
220
|
-
if (this.moduleCache.has(
|
|
221
|
-
mod = this.moduleCache.get(
|
|
221
|
+
let { code: transformed, externalize } = await this.options.fetchModule(resolvedId || dep);
|
|
222
|
+
if (resolvedId && !fsPath.includes("?") && fsPath !== resolvedId) {
|
|
223
|
+
if (this.moduleCache.has(resolvedId)) {
|
|
224
|
+
mod = this.moduleCache.get(resolvedId);
|
|
222
225
|
this.moduleCache.set(fsPath, mod);
|
|
223
226
|
if (mod.promise)
|
|
224
227
|
return mod.promise;
|
|
225
228
|
if (mod.exports)
|
|
226
229
|
return mod.exports;
|
|
227
230
|
} else {
|
|
228
|
-
this.moduleCache.set(
|
|
231
|
+
this.moduleCache.set(resolvedId, mod);
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
if (externalize) {
|
|
@@ -236,7 +239,8 @@ ${getStack()}`), 2e3);
|
|
|
236
239
|
}
|
|
237
240
|
if (transformed == null)
|
|
238
241
|
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
239
|
-
const
|
|
242
|
+
const file = utils.cleanUrl(resolvedId || fsPath);
|
|
243
|
+
const url$1 = url.pathToFileURL(file).href;
|
|
240
244
|
const meta = { url: url$1 };
|
|
241
245
|
const exports = /* @__PURE__ */ Object.create(null);
|
|
242
246
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
package/dist/client.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-
|
|
1
|
+
export { j as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, h as ViteNodeRunner } from './types-60eb9672.js';
|
package/dist/client.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import vm from 'vm';
|
|
|
4
4
|
import { resolve, dirname, isAbsolute, extname } from 'pathe';
|
|
5
5
|
import { isNodeBuiltin } from 'mlly';
|
|
6
6
|
import createDebug from 'debug';
|
|
7
|
-
import { normalizeModuleId, slash, normalizeRequestId, toFilePath,
|
|
7
|
+
import { normalizeModuleId, slash, normalizeRequestId, toFilePath, cleanUrl, isPrimitive } from './utils.mjs';
|
|
8
8
|
import { extractSourceMap } from './source-map.mjs';
|
|
9
9
|
import 'fs';
|
|
10
10
|
import 'source-map-support';
|
|
@@ -150,9 +150,9 @@ class ViteNodeRunner {
|
|
|
150
150
|
async directRequest(id, fsPath, _callstack) {
|
|
151
151
|
const callstack = [..._callstack, fsPath];
|
|
152
152
|
let mod = this.moduleCache.get(fsPath);
|
|
153
|
-
const request = async (
|
|
153
|
+
const request = async (dep2) => {
|
|
154
154
|
var _a;
|
|
155
|
-
const depFsPath = toFilePath(normalizeRequestId(
|
|
155
|
+
const depFsPath = toFilePath(normalizeRequestId(dep2, this.options.base), this.root);
|
|
156
156
|
const getStack = () => {
|
|
157
157
|
return `stack:
|
|
158
158
|
${[...callstack, depFsPath].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
@@ -168,37 +168,40 @@ ${getStack()}`), 2e3);
|
|
|
168
168
|
return depExports;
|
|
169
169
|
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
170
170
|
}
|
|
171
|
-
return await this.cachedRequest(
|
|
171
|
+
return await this.cachedRequest(dep2, callstack);
|
|
172
172
|
} finally {
|
|
173
173
|
if (debugTimer)
|
|
174
174
|
clearTimeout(debugTimer);
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
177
|
Object.defineProperty(request, "callstack", { get: () => callstack });
|
|
178
|
-
const resolveId = async (
|
|
179
|
-
if (this.options.resolveId && this.shouldResolveId(
|
|
178
|
+
const resolveId = async (dep2, callstackPosition = 1) => {
|
|
179
|
+
if (this.options.resolveId && this.shouldResolveId(dep2)) {
|
|
180
180
|
let importer = callstack[callstack.length - callstackPosition];
|
|
181
|
+
if (importer && !dep2.startsWith("."))
|
|
182
|
+
importer = void 0;
|
|
181
183
|
if (importer && importer.startsWith("mock:"))
|
|
182
184
|
importer = importer.slice(5);
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
+
const resolved = await this.options.resolveId(normalizeRequestId(dep2), importer);
|
|
186
|
+
return [dep2, resolved == null ? void 0 : resolved.id];
|
|
185
187
|
}
|
|
186
|
-
return
|
|
188
|
+
return [dep2, void 0];
|
|
187
189
|
};
|
|
190
|
+
const [dep, resolvedId] = await resolveId(id, 2);
|
|
188
191
|
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
189
192
|
if (id in requestStubs)
|
|
190
193
|
return requestStubs[id];
|
|
191
|
-
let { code: transformed, externalize
|
|
192
|
-
if (
|
|
193
|
-
if (this.moduleCache.has(
|
|
194
|
-
mod = this.moduleCache.get(
|
|
194
|
+
let { code: transformed, externalize } = await this.options.fetchModule(resolvedId || dep);
|
|
195
|
+
if (resolvedId && !fsPath.includes("?") && fsPath !== resolvedId) {
|
|
196
|
+
if (this.moduleCache.has(resolvedId)) {
|
|
197
|
+
mod = this.moduleCache.get(resolvedId);
|
|
195
198
|
this.moduleCache.set(fsPath, mod);
|
|
196
199
|
if (mod.promise)
|
|
197
200
|
return mod.promise;
|
|
198
201
|
if (mod.exports)
|
|
199
202
|
return mod.exports;
|
|
200
203
|
} else {
|
|
201
|
-
this.moduleCache.set(
|
|
204
|
+
this.moduleCache.set(resolvedId, mod);
|
|
202
205
|
}
|
|
203
206
|
}
|
|
204
207
|
if (externalize) {
|
|
@@ -209,7 +212,8 @@ ${getStack()}`), 2e3);
|
|
|
209
212
|
}
|
|
210
213
|
if (transformed == null)
|
|
211
214
|
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
212
|
-
const
|
|
215
|
+
const file = cleanUrl(resolvedId || fsPath);
|
|
216
|
+
const url = pathToFileURL(file).href;
|
|
213
217
|
const meta = { url };
|
|
214
218
|
const exports = /* @__PURE__ */ Object.create(null);
|
|
215
219
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
package/dist/hmr.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { HMRPayload, Plugin } from 'vite';
|
|
3
|
-
import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-
|
|
3
|
+
import { g as CustomEventMap, h as ViteNodeRunner, i as HMRPayload$1, H as HotContext } from './types-60eb9672.js';
|
|
4
4
|
|
|
5
5
|
declare type EventType = string | symbol;
|
|
6
6
|
declare type Handler<T = unknown> = (event: T) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, 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-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, 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-60eb9672.js';
|
package/dist/server.cjs
CHANGED
|
@@ -263,8 +263,6 @@ class ViteNodeServer {
|
|
|
263
263
|
const module = this.server.moduleGraph.getModuleById(id);
|
|
264
264
|
const timestamp = module ? module.lastHMRTimestamp : null;
|
|
265
265
|
const cache = this.fetchCache.get(filePath);
|
|
266
|
-
if (cache == null ? void 0 : cache.result.id)
|
|
267
|
-
id = cache.result.id;
|
|
268
266
|
if (timestamp !== null && cache && cache.timestamp >= timestamp)
|
|
269
267
|
return cache.result;
|
|
270
268
|
const time = Date.now();
|
|
@@ -274,16 +272,10 @@ class ViteNodeServer {
|
|
|
274
272
|
result = { externalize };
|
|
275
273
|
(_a = this.debugger) == null ? void 0 : _a.recordExternalize(id, externalize);
|
|
276
274
|
} else {
|
|
277
|
-
let file = module == null ? void 0 : module.file;
|
|
278
|
-
if (!file) {
|
|
279
|
-
const [, resolvedId] = await this.server.moduleGraph.resolveUrl(id, true);
|
|
280
|
-
id = resolvedId;
|
|
281
|
-
file = utils.cleanUrl(resolvedId);
|
|
282
|
-
}
|
|
283
275
|
const start = perf_hooks.performance.now();
|
|
284
276
|
const r = await this._transformRequest(id);
|
|
285
277
|
duration = perf_hooks.performance.now() - start;
|
|
286
|
-
result = {
|
|
278
|
+
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
287
279
|
}
|
|
288
280
|
this.fetchCache.set(filePath, {
|
|
289
281
|
duration,
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
|
-
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId, R as RawSourceMap } from './types-
|
|
2
|
+
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId, R as RawSourceMap } from './types-60eb9672.js';
|
|
3
3
|
|
|
4
4
|
declare class Debugger {
|
|
5
5
|
options: DebuggerOptions;
|
package/dist/server.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { resolve, join } from 'pathe';
|
|
|
3
3
|
import createDebug from 'debug';
|
|
4
4
|
import { existsSync, promises } from 'fs';
|
|
5
5
|
import { isNodeBuiltin, isValidNodeImport } from 'mlly';
|
|
6
|
-
import { slash, toArray, normalizeModuleId, toFilePath
|
|
6
|
+
import { slash, toArray, normalizeModuleId, toFilePath } from './utils.mjs';
|
|
7
7
|
import { p as picocolors } from './chunk-picocolors.mjs';
|
|
8
8
|
import { withInlineSourcemap } from './source-map.mjs';
|
|
9
9
|
import 'url';
|
|
@@ -255,8 +255,6 @@ class ViteNodeServer {
|
|
|
255
255
|
const module = this.server.moduleGraph.getModuleById(id);
|
|
256
256
|
const timestamp = module ? module.lastHMRTimestamp : null;
|
|
257
257
|
const cache = this.fetchCache.get(filePath);
|
|
258
|
-
if (cache == null ? void 0 : cache.result.id)
|
|
259
|
-
id = cache.result.id;
|
|
260
258
|
if (timestamp !== null && cache && cache.timestamp >= timestamp)
|
|
261
259
|
return cache.result;
|
|
262
260
|
const time = Date.now();
|
|
@@ -266,16 +264,10 @@ class ViteNodeServer {
|
|
|
266
264
|
result = { externalize };
|
|
267
265
|
(_a = this.debugger) == null ? void 0 : _a.recordExternalize(id, externalize);
|
|
268
266
|
} else {
|
|
269
|
-
let file = module == null ? void 0 : module.file;
|
|
270
|
-
if (!file) {
|
|
271
|
-
const [, resolvedId] = await this.server.moduleGraph.resolveUrl(id, true);
|
|
272
|
-
id = resolvedId;
|
|
273
|
-
file = cleanUrl(resolvedId);
|
|
274
|
-
}
|
|
275
267
|
const start = performance.now();
|
|
276
268
|
const r = await this._transformRequest(id);
|
|
277
269
|
duration = performance.now() - start;
|
|
278
|
-
result = {
|
|
270
|
+
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
279
271
|
}
|
|
280
272
|
this.fetchCache.set(filePath, {
|
|
281
273
|
duration,
|
package/dist/source-map.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult } from 'vite';
|
|
2
|
-
import { R as RawSourceMap } from './types-
|
|
2
|
+
import { R as RawSourceMap } from './types-60eb9672.js';
|
|
3
3
|
|
|
4
4
|
interface InstallSourceMapSupportOptions {
|
|
5
5
|
getSourceMap: (source: string) => RawSourceMap | null | undefined;
|
|
@@ -201,8 +201,6 @@ interface FetchResult {
|
|
|
201
201
|
code?: string;
|
|
202
202
|
externalize?: string;
|
|
203
203
|
map?: RawSourceMap;
|
|
204
|
-
id?: string;
|
|
205
|
-
file?: string;
|
|
206
204
|
}
|
|
207
205
|
declare type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>;
|
|
208
206
|
declare type FetchFunction = (id: string) => Promise<FetchResult>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, 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-
|
|
1
|
+
export { A as Arrayable, C as CreateHotContextFunction, f as DebuggerOptions, 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-60eb9672.js';
|
package/dist/utils.d.ts
CHANGED