vite-node 3.2.4 → 4.0.0-beta.10
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/LICENSE +1 -1
- package/README.md +4 -2
- package/dist/chunk-hmr.cjs +25 -53
- package/dist/chunk-hmr.mjs +25 -53
- package/dist/cli.cjs +15 -36
- package/dist/cli.d.ts +2 -2
- package/dist/cli.mjs +15 -36
- package/dist/client.cjs +43 -107
- package/dist/client.d.ts +2 -2
- package/dist/client.mjs +43 -107
- package/dist/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/hmr.d.ts +4 -7
- package/dist/{index.d-DGmxD2U7.d.ts → index.d-uN06xifv.d.ts} +6 -7
- package/dist/index.d.ts +2 -2
- package/dist/server.cjs +42 -100
- package/dist/server.d.ts +3 -3
- package/dist/server.mjs +42 -100
- package/dist/source-map.cjs +209 -319
- package/dist/source-map.d.ts +4 -4
- package/dist/source-map.mjs +211 -321
- package/dist/{trace-mapping.d-DLVdEqOp.d.ts → trace-mapping.d-BWFx6tPc.d.ts} +6 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils.cjs +13 -33
- package/dist/utils.d.ts +5 -5
- package/dist/utils.mjs +13 -33
- package/package.json +2 -2
package/dist/client.mjs
CHANGED
|
@@ -8,10 +8,7 @@ import { createImportMetaEnvProxy, slash, isInternalRequest, isNodeBuiltin, norm
|
|
|
8
8
|
import 'pathe';
|
|
9
9
|
import 'node:fs';
|
|
10
10
|
|
|
11
|
-
const { setTimeout, clearTimeout } = globalThis
|
|
12
|
-
const debugExecute = createDebug("vite-node:client:execute");
|
|
13
|
-
const debugNative = createDebug("vite-node:client:native");
|
|
14
|
-
const clientStub = {
|
|
11
|
+
const { setTimeout, clearTimeout } = globalThis, debugExecute = createDebug("vite-node:client:execute"), debugNative = createDebug("vite-node:client:native"), clientStub = {
|
|
15
12
|
injectQuery: (id) => id,
|
|
16
13
|
createHotContext: () => {
|
|
17
14
|
return {
|
|
@@ -26,8 +23,7 @@ const clientStub = {
|
|
|
26
23
|
},
|
|
27
24
|
updateStyle: () => {},
|
|
28
25
|
removeStyle: () => {}
|
|
29
|
-
};
|
|
30
|
-
const env = createImportMetaEnvProxy();
|
|
26
|
+
}, env = createImportMetaEnvProxy();
|
|
31
27
|
const DEFAULT_REQUEST_STUBS = {
|
|
32
28
|
"/@vite/client": clientStub,
|
|
33
29
|
"@vite/client": clientStub
|
|
@@ -40,8 +36,7 @@ class ModuleCacheMap extends Map {
|
|
|
40
36
|
* Assign partial data to the map
|
|
41
37
|
*/
|
|
42
38
|
update(fsPath, mod) {
|
|
43
|
-
fsPath = this.normalizePath(fsPath);
|
|
44
|
-
if (!super.has(fsPath)) this.setByModuleId(fsPath, mod);
|
|
39
|
+
if (fsPath = this.normalizePath(fsPath), !super.has(fsPath)) this.setByModuleId(fsPath, mod);
|
|
45
40
|
else Object.assign(super.get(fsPath), mod);
|
|
46
41
|
return this;
|
|
47
42
|
}
|
|
@@ -71,13 +66,7 @@ class ModuleCacheMap extends Map {
|
|
|
71
66
|
}
|
|
72
67
|
invalidateModule(mod) {
|
|
73
68
|
var _mod$importers, _mod$imports;
|
|
74
|
-
delete mod.evaluated;
|
|
75
|
-
delete mod.resolving;
|
|
76
|
-
delete mod.promise;
|
|
77
|
-
delete mod.exports;
|
|
78
|
-
(_mod$importers = mod.importers) === null || _mod$importers === void 0 || _mod$importers.clear();
|
|
79
|
-
(_mod$imports = mod.imports) === null || _mod$imports === void 0 || _mod$imports.clear();
|
|
80
|
-
return true;
|
|
69
|
+
return delete mod.evaluated, delete mod.resolving, delete mod.promise, delete mod.exports, (_mod$importers = mod.importers) === null || _mod$importers === void 0 || _mod$importers.clear(), (_mod$imports = mod.imports) === null || _mod$imports === void 0 || _mod$imports.clear(), true;
|
|
81
70
|
}
|
|
82
71
|
/**
|
|
83
72
|
* Invalidate modules that dependent on the given modules, up to the main entry
|
|
@@ -117,11 +106,7 @@ class ModuleCacheMap extends Map {
|
|
|
117
106
|
const cache = this.get(id);
|
|
118
107
|
if (cache.map) return cache.map;
|
|
119
108
|
const map = cache.code && extractSourceMap(cache.code);
|
|
120
|
-
|
|
121
|
-
cache.map = map;
|
|
122
|
-
return map;
|
|
123
|
-
}
|
|
124
|
-
return null;
|
|
109
|
+
return map ? (cache.map = map, map) : null;
|
|
125
110
|
}
|
|
126
111
|
}
|
|
127
112
|
class ViteNodeRunner {
|
|
@@ -152,10 +137,7 @@ class ViteNodeRunner {
|
|
|
152
137
|
// `performance` can be mocked, so make sure we're using the original function
|
|
153
138
|
performanceNow = performance.now.bind(performance);
|
|
154
139
|
constructor(options) {
|
|
155
|
-
this.options = options;
|
|
156
|
-
this.root = options.root ?? process.cwd();
|
|
157
|
-
this.moduleCache = options.moduleCache ?? new ModuleCacheMap();
|
|
158
|
-
this.debug = options.debug ?? (typeof process !== "undefined" ? !!process.env.VITE_NODE_DEBUG_RUNNER : false);
|
|
140
|
+
this.options = options, this.root = options.root ?? process.cwd(), this.moduleCache = options.moduleCache ?? new ModuleCacheMap(), this.debug = options.debug ?? (typeof process !== "undefined" ? !!process.env.VITE_NODE_DEBUG_RUNNER : false);
|
|
159
141
|
}
|
|
160
142
|
async executeFile(file) {
|
|
161
143
|
const url = `/@fs/${slash(resolve(file))}`;
|
|
@@ -167,9 +149,7 @@ class ViteNodeRunner {
|
|
|
167
149
|
}
|
|
168
150
|
/** @internal */
|
|
169
151
|
async cachedRequest(id, fsPath, callstack) {
|
|
170
|
-
const importee = callstack
|
|
171
|
-
const mod = this.moduleCache.get(fsPath);
|
|
172
|
-
const { imports, importers } = mod;
|
|
152
|
+
const importee = callstack.at(-1), mod = this.moduleCache.get(fsPath), { imports, importers } = mod;
|
|
173
153
|
if (importee) importers.add(importee);
|
|
174
154
|
const getStack = () => `stack:\n${[...callstack, fsPath].reverse().map((p) => ` - ${p}`).join("\n")}`;
|
|
175
155
|
// check circular dependency
|
|
@@ -182,14 +162,12 @@ class ViteNodeRunner {
|
|
|
182
162
|
// cached module
|
|
183
163
|
if (mod.promise) return await mod.promise;
|
|
184
164
|
const promise = this.directRequest(id, fsPath, callstack);
|
|
185
|
-
Object.assign(mod, {
|
|
165
|
+
return Object.assign(mod, {
|
|
186
166
|
promise,
|
|
187
167
|
evaluated: false
|
|
188
|
-
});
|
|
189
|
-
return await promise;
|
|
168
|
+
}), await promise;
|
|
190
169
|
} finally {
|
|
191
|
-
mod.evaluated = true;
|
|
192
|
-
if (debugTimer) clearTimeout(debugTimer);
|
|
170
|
+
if (mod.evaluated = true, debugTimer) clearTimeout(debugTimer);
|
|
193
171
|
}
|
|
194
172
|
}
|
|
195
173
|
shouldResolveId(id, _importee) {
|
|
@@ -204,22 +182,20 @@ class ViteNodeRunner {
|
|
|
204
182
|
const resolved = await this.options.resolveId(dep, importer);
|
|
205
183
|
// supported since Vite 5-beta.19
|
|
206
184
|
if (resolved === null || resolved === void 0 || (_resolved$meta = resolved.meta) === null || _resolved$meta === void 0 || (_resolved$meta = _resolved$meta["vite:alias"]) === null || _resolved$meta === void 0 ? void 0 : _resolved$meta.noResolved) {
|
|
207
|
-
const error = new Error(`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
|
|
185
|
+
const error = /* @__PURE__ */ new Error(`Cannot find module '${id}'${importer ? ` imported from '${importer}'` : ""}.
|
|
208
186
|
|
|
209
187
|
- If you rely on tsconfig.json's "paths" to resolve modules, please install "vite-tsconfig-paths" plugin to handle module resolution.
|
|
210
188
|
- Make sure you don't have relative aliases in your Vitest config. Use absolute paths instead. Read more: https://vitest.dev/guide/common-errors`);
|
|
211
|
-
Object.defineProperty(error, "code", {
|
|
189
|
+
throw Object.defineProperty(error, "code", {
|
|
212
190
|
value: "ERR_MODULE_NOT_FOUND",
|
|
213
191
|
enumerable: true
|
|
214
|
-
})
|
|
215
|
-
Object.defineProperty(error, Symbol.for("vitest.error.not_found.data"), {
|
|
192
|
+
}), Object.defineProperty(error, Symbol.for("vitest.error.not_found.data"), {
|
|
216
193
|
value: {
|
|
217
194
|
id: dep,
|
|
218
195
|
importer
|
|
219
196
|
},
|
|
220
197
|
enumerable: false
|
|
221
|
-
});
|
|
222
|
-
throw error;
|
|
198
|
+
}), error;
|
|
223
199
|
}
|
|
224
200
|
const resolvedId = resolved ? normalizeRequestId(resolved.id, this.options.base) : dep;
|
|
225
201
|
return [resolvedId, resolvedId];
|
|
@@ -245,47 +221,31 @@ class ViteNodeRunner {
|
|
|
245
221
|
// rethrow vite error if it cannot load the module because it's not resolved
|
|
246
222
|
if (typeof cause === "object" && cause.code === "ERR_LOAD_URL" || typeof (cause === null || cause === void 0 ? void 0 : cause.message) === "string" && cause.message.includes("Failed to load url")) {
|
|
247
223
|
const error = new Error(`Cannot find ${isBareImport(id) ? "package" : "module"} '${id}'${importer ? ` imported from '${importer}'` : ""}`, { cause });
|
|
248
|
-
error.code = "ERR_MODULE_NOT_FOUND";
|
|
249
|
-
throw error;
|
|
224
|
+
throw error.code = "ERR_MODULE_NOT_FOUND", error;
|
|
250
225
|
}
|
|
251
226
|
throw cause;
|
|
252
227
|
}
|
|
253
228
|
}
|
|
254
229
|
/** @internal */
|
|
255
230
|
async directRequest(id, fsPath, _callstack) {
|
|
256
|
-
const moduleId = normalizeModuleId(fsPath)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const [id, depFsPath] = await this.resolveUrl(String(dep), fsPath);
|
|
261
|
-
const depMod = this.moduleCache.getByModuleId(depFsPath);
|
|
262
|
-
depMod.importers.add(moduleId);
|
|
263
|
-
mod.imports.add(depFsPath);
|
|
264
|
-
return this.dependencyRequest(id, depFsPath, callstack);
|
|
265
|
-
};
|
|
266
|
-
const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
231
|
+
const moduleId = normalizeModuleId(fsPath), callstack = [..._callstack, moduleId], mod = this.moduleCache.getByModuleId(moduleId), request = async (dep) => {
|
|
232
|
+
const [id, depFsPath] = await this.resolveUrl(String(dep), fsPath), depMod = this.moduleCache.getByModuleId(depFsPath);
|
|
233
|
+
return depMod.importers.add(moduleId), mod.imports.add(depFsPath), this.dependencyRequest(id, depFsPath, callstack);
|
|
234
|
+
}, requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
|
|
267
235
|
if (id in requestStubs) return requestStubs[id];
|
|
268
236
|
let { code: transformed, externalize } = await this._fetchModule(id, callstack[callstack.length - 2]);
|
|
269
237
|
if (externalize) {
|
|
270
238
|
debugNative(externalize);
|
|
271
239
|
const exports = await this.interopedImport(externalize);
|
|
272
|
-
mod.exports = exports;
|
|
273
|
-
return exports;
|
|
240
|
+
return mod.exports = exports, exports;
|
|
274
241
|
}
|
|
275
242
|
if (transformed == null) throw new Error(`[vite-node] Failed to load "${id}" imported from ${callstack[callstack.length - 2]}`);
|
|
276
|
-
const { Object, Reflect, Symbol } = this.getContextPrimitives()
|
|
277
|
-
const modulePath = cleanUrl(moduleId);
|
|
278
|
-
// disambiguate the `<UNIT>:/` on windows: see nodejs/node#31710
|
|
279
|
-
const href = pathToFileURL(modulePath).href;
|
|
280
|
-
const __filename = fileURLToPath(href);
|
|
281
|
-
const __dirname = dirname(__filename);
|
|
282
|
-
const meta = {
|
|
243
|
+
const { Object, Reflect, Symbol } = this.getContextPrimitives(), modulePath = cleanUrl(moduleId), href = pathToFileURL(modulePath).href, __filename = fileURLToPath(href), __dirname = dirname(__filename), meta = {
|
|
283
244
|
url: href,
|
|
284
245
|
env,
|
|
285
246
|
filename: __filename,
|
|
286
247
|
dirname: __dirname
|
|
287
|
-
};
|
|
288
|
-
const exports = Object.create(null);
|
|
248
|
+
}, exports = Object.create(null);
|
|
289
249
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
290
250
|
value: "Module",
|
|
291
251
|
enumerable: false,
|
|
@@ -297,25 +257,17 @@ class ViteNodeRunner {
|
|
|
297
257
|
// inside the module itself. imported module is always "exports"
|
|
298
258
|
const cjsExports = new Proxy(exports, {
|
|
299
259
|
get: (target, p, receiver) => {
|
|
300
|
-
|
|
301
|
-
return Reflect.get(Object.prototype, p, receiver);
|
|
260
|
+
return Reflect.has(target, p) ? Reflect.get(target, p, receiver) : Reflect.get(Object.prototype, p, receiver);
|
|
302
261
|
},
|
|
303
262
|
getPrototypeOf: () => Object.prototype,
|
|
304
263
|
set: (_, p, value) => {
|
|
305
264
|
// treat "module.exports =" the same as "exports.default =" to not have nested "default.default",
|
|
306
265
|
// so "exports.default" becomes the actual module
|
|
307
|
-
if (p === "default" && this.shouldInterop(modulePath, { default: value }) && cjsExports !== value)
|
|
308
|
-
exportAll(cjsExports, value);
|
|
309
|
-
exports.default = value;
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
266
|
+
if (p === "default" && this.shouldInterop(modulePath, { default: value }) && cjsExports !== value) return exportAll(cjsExports, value), exports.default = value, true;
|
|
312
267
|
if (!Reflect.has(exports, "default")) exports.default = {};
|
|
313
268
|
// returns undefined, when accessing named exports, if default is not an object
|
|
314
269
|
// but is still present inside hasOwnKeys, this is Node behaviour for CJS
|
|
315
|
-
if (moduleExports !== SYMBOL_NOT_DEFINED && isPrimitive(moduleExports))
|
|
316
|
-
defineExport(exports, p, () => void 0);
|
|
317
|
-
return true;
|
|
318
|
-
}
|
|
270
|
+
if (moduleExports !== SYMBOL_NOT_DEFINED && isPrimitive(moduleExports)) return defineExport(exports, p, () => void 0), true;
|
|
319
271
|
if (!isPrimitive(exports.default)) exports.default[p] = value;
|
|
320
272
|
if (p !== "default") defineExport(exports, p, () => value);
|
|
321
273
|
return true;
|
|
@@ -327,9 +279,7 @@ class ViteNodeRunner {
|
|
|
327
279
|
});
|
|
328
280
|
const moduleProxy = {
|
|
329
281
|
set exports(value) {
|
|
330
|
-
exportAll(cjsExports, value);
|
|
331
|
-
exports.default = value;
|
|
332
|
-
moduleExports = value;
|
|
282
|
+
exportAll(cjsExports, value), exports.default = value, moduleExports = value;
|
|
333
283
|
},
|
|
334
284
|
get exports() {
|
|
335
285
|
return cjsExports;
|
|
@@ -341,8 +291,7 @@ class ViteNodeRunner {
|
|
|
341
291
|
enumerable: true,
|
|
342
292
|
get: () => {
|
|
343
293
|
var _this$options$createH, _this$options;
|
|
344
|
-
hotContext || (hotContext = (_this$options$createH = (_this$options = this.options).createHotContext) === null || _this$options$createH === void 0 ? void 0 : _this$options$createH.call(_this$options, this, moduleId));
|
|
345
|
-
return hotContext;
|
|
294
|
+
return hotContext || (hotContext = (_this$options$createH = (_this$options = this.options).createHotContext) === null || _this$options$createH === void 0 ? void 0 : _this$options$createH.call(_this$options, this, moduleId)), hotContext;
|
|
346
295
|
},
|
|
347
296
|
set: (value) => {
|
|
348
297
|
hotContext = value;
|
|
@@ -369,11 +318,9 @@ class ViteNodeRunner {
|
|
|
369
318
|
__filename,
|
|
370
319
|
__dirname
|
|
371
320
|
});
|
|
372
|
-
debugExecute(__filename);
|
|
373
321
|
// remove shebang
|
|
374
|
-
if (transformed[0] === "#") transformed = transformed.replace(/^#!.*/, (s) => " ".repeat(s.length));
|
|
375
|
-
await this.runModule(context, transformed);
|
|
376
|
-
return exports;
|
|
322
|
+
if (debugExecute(__filename), transformed[0] === "#") transformed = transformed.replace(/^#!.*/, (s) => " ".repeat(s.length));
|
|
323
|
+
return await this.runModule(context, transformed), exports;
|
|
377
324
|
}
|
|
378
325
|
getContextPrimitives() {
|
|
379
326
|
return {
|
|
@@ -384,14 +331,11 @@ class ViteNodeRunner {
|
|
|
384
331
|
}
|
|
385
332
|
async runModule(context, transformed) {
|
|
386
333
|
// add 'use strict' since ESM enables it by default
|
|
387
|
-
const codeDefinition = `'use strict';async (${Object.keys(context).join(",")})=>{{
|
|
388
|
-
const code = `${codeDefinition}${transformed}\n}}`;
|
|
389
|
-
const options = {
|
|
334
|
+
const codeDefinition = `'use strict';async (${Object.keys(context).join(",")})=>{{`, code = `${codeDefinition}${transformed}\n}}`, options = {
|
|
390
335
|
filename: context.__filename,
|
|
391
336
|
lineOffset: 0,
|
|
392
337
|
columnOffset: -codeDefinition.length
|
|
393
|
-
};
|
|
394
|
-
const finishModuleExecutionInfo = this.startCalculateModuleExecutionInfo(options.filename, codeDefinition.length);
|
|
338
|
+
}, finishModuleExecutionInfo = this.startCalculateModuleExecutionInfo(options.filename, codeDefinition.length);
|
|
395
339
|
try {
|
|
396
340
|
const fn = vm.runInThisContext(code, options);
|
|
397
341
|
await fn(...Object.values(context));
|
|
@@ -406,14 +350,12 @@ class ViteNodeRunner {
|
|
|
406
350
|
*/
|
|
407
351
|
startCalculateModuleExecutionInfo(filename, startOffset) {
|
|
408
352
|
const startTime = this.performanceNow();
|
|
409
|
-
this.executionStack.push({
|
|
353
|
+
return this.executionStack.push({
|
|
410
354
|
filename,
|
|
411
355
|
startTime,
|
|
412
356
|
subImportTime: 0
|
|
413
|
-
})
|
|
414
|
-
|
|
415
|
-
const duration = this.performanceNow() - startTime;
|
|
416
|
-
const currentExecution = this.executionStack.pop();
|
|
357
|
+
}), () => {
|
|
358
|
+
const duration = this.performanceNow() - startTime, currentExecution = this.executionStack.pop();
|
|
417
359
|
if (currentExecution == null) throw new Error("Execution stack is empty, this should never happen");
|
|
418
360
|
const selfTime = duration - currentExecution.subImportTime;
|
|
419
361
|
if (this.executionStack.length > 0) this.executionStack.at(-1).subImportTime += duration;
|
|
@@ -432,10 +374,9 @@ class ViteNodeRunner {
|
|
|
432
374
|
* This function mostly for the ability to override by subclass
|
|
433
375
|
*/
|
|
434
376
|
shouldInterop(path, mod) {
|
|
435
|
-
if (this.options.interopDefault === false) return false;
|
|
436
377
|
// never interop ESM modules
|
|
437
378
|
// TODO: should also skip for `.js` with `type="module"`
|
|
438
|
-
return !path.endsWith(".mjs") && "default" in mod;
|
|
379
|
+
return this.options.interopDefault === false ? false : !path.endsWith(".mjs") && "default" in mod;
|
|
439
380
|
}
|
|
440
381
|
importExternalModule(path) {
|
|
441
382
|
return import(
|
|
@@ -452,12 +393,10 @@ class ViteNodeRunner {
|
|
|
452
393
|
const { mod, defaultExport } = interopModule(importedModule);
|
|
453
394
|
return new Proxy(mod, {
|
|
454
395
|
get(mod, prop) {
|
|
455
|
-
|
|
456
|
-
return mod[prop] ?? (defaultExport === null || defaultExport === void 0 ? void 0 : defaultExport[prop]);
|
|
396
|
+
return prop === "default" ? defaultExport : mod[prop] ?? (defaultExport === null || defaultExport === void 0 ? void 0 : defaultExport[prop]);
|
|
457
397
|
},
|
|
458
398
|
has(mod, prop) {
|
|
459
|
-
|
|
460
|
-
return prop in mod || defaultExport && prop in defaultExport;
|
|
399
|
+
return prop === "default" ? defaultExport !== void 0 : prop in mod || defaultExport && prop in defaultExport;
|
|
461
400
|
},
|
|
462
401
|
getOwnPropertyDescriptor(mod, prop) {
|
|
463
402
|
const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);
|
|
@@ -478,8 +417,7 @@ function interopModule(mod) {
|
|
|
478
417
|
};
|
|
479
418
|
let defaultExport = "default" in mod ? mod.default : mod;
|
|
480
419
|
if (!isPrimitive(defaultExport) && "__esModule" in defaultExport) {
|
|
481
|
-
mod = defaultExport;
|
|
482
|
-
if ("default" in defaultExport) defaultExport = defaultExport.default;
|
|
420
|
+
if (mod = defaultExport, "default" in defaultExport) defaultExport = defaultExport.default;
|
|
483
421
|
}
|
|
484
422
|
return {
|
|
485
423
|
mod,
|
|
@@ -495,13 +433,11 @@ function defineExport(exports, key, value) {
|
|
|
495
433
|
});
|
|
496
434
|
}
|
|
497
435
|
function exportAll(exports, sourceModule) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
defineExport(exports, key, () => sourceModule[key]);
|
|
504
|
-
} catch {}
|
|
436
|
+
if (exports !== sourceModule && !(isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise)) {
|
|
437
|
+
for (const key in sourceModule) if (key !== "default" && !(key in exports)) try {
|
|
438
|
+
defineExport(exports, key, () => sourceModule[key]);
|
|
439
|
+
} catch {}
|
|
440
|
+
}
|
|
505
441
|
}
|
|
506
442
|
|
|
507
443
|
export { DEFAULT_REQUEST_STUBS, ModuleCacheMap, ViteNodeRunner };
|
package/dist/constants.cjs
CHANGED
|
@@ -28,7 +28,7 @@ const KNOWN_ASSET_TYPES = [
|
|
|
28
28
|
"pdf",
|
|
29
29
|
"txt"
|
|
30
30
|
];
|
|
31
|
-
const KNOWN_ASSET_RE = new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
|
|
31
|
+
const KNOWN_ASSET_RE = /* @__PURE__ */ new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
|
|
32
32
|
const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
|
33
33
|
|
|
34
34
|
exports.CSS_LANGS_RE = CSS_LANGS_RE;
|
package/dist/constants.mjs
CHANGED
|
@@ -26,7 +26,7 @@ const KNOWN_ASSET_TYPES = [
|
|
|
26
26
|
"pdf",
|
|
27
27
|
"txt"
|
|
28
28
|
];
|
|
29
|
-
const KNOWN_ASSET_RE = new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
|
|
29
|
+
const KNOWN_ASSET_RE = /* @__PURE__ */ new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`);
|
|
30
30
|
const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
|
31
31
|
|
|
32
32
|
export { CSS_LANGS_RE, KNOWN_ASSET_RE, KNOWN_ASSET_TYPES };
|
package/dist/hmr.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HMRPayload, Plugin } from 'vite';
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
|
-
import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index.d-
|
|
4
|
-
import './trace-mapping.d-
|
|
3
|
+
import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index.d-uN06xifv.js';
|
|
4
|
+
import './trace-mapping.d-BWFx6tPc.js';
|
|
5
5
|
|
|
6
6
|
type EventType = string | symbol;
|
|
7
7
|
type Handler<T = unknown> = (event: T) => void;
|
|
@@ -11,7 +11,7 @@ interface Emitter<Events extends Record<EventType, unknown>> {
|
|
|
11
11
|
emit: (<Key extends keyof Events>(type: Key, event: Events[Key]) => void) & (<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never) => void);
|
|
12
12
|
}
|
|
13
13
|
type HMREmitter = Emitter<{
|
|
14
|
-
message: HMRPayload
|
|
14
|
+
message: HMRPayload;
|
|
15
15
|
}> & EventEmitter;
|
|
16
16
|
declare module "vite" {
|
|
17
17
|
interface ViteDevServer {
|
|
@@ -21,10 +21,8 @@ declare module "vite" {
|
|
|
21
21
|
declare function createHmrEmitter(): HMREmitter;
|
|
22
22
|
declare function viteNodeHmrPlugin(): Plugin;
|
|
23
23
|
|
|
24
|
-
/* eslint-disable no-console */
|
|
25
|
-
|
|
26
24
|
type ModuleNamespace = Record<string, any> & {
|
|
27
|
-
[Symbol.toStringTag]: "Module"
|
|
25
|
+
[Symbol.toStringTag]: "Module";
|
|
28
26
|
};
|
|
29
27
|
type InferCustomEventPayload<T extends string> = T extends keyof CustomEventMap ? CustomEventMap[T] : any;
|
|
30
28
|
interface HotModule {
|
|
@@ -32,7 +30,6 @@ interface HotModule {
|
|
|
32
30
|
callbacks: HotCallback[];
|
|
33
31
|
}
|
|
34
32
|
interface HotCallback {
|
|
35
|
-
// the dependencies must be fetchable paths
|
|
36
33
|
deps: string[];
|
|
37
34
|
fn: (modules: (ModuleNamespace | undefined)[]) => void;
|
|
38
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-
|
|
1
|
+
import { E as EncodedSourceMap } from './trace-mapping.d-BWFx6tPc.js';
|
|
2
2
|
|
|
3
3
|
/** @deprecated use HotPayload */
|
|
4
4
|
type HMRPayload = HotPayload
|
|
@@ -213,7 +213,6 @@ declare class ViteNodeRunner {
|
|
|
213
213
|
* As top-level awaits with dynamic imports like this are uncommon, we don't handle this case specifically.
|
|
214
214
|
*/
|
|
215
215
|
private executionStack;
|
|
216
|
-
// `performance` can be mocked, so make sure we're using the original function
|
|
217
216
|
private performanceNow;
|
|
218
217
|
constructor(options: ViteNodeRunnerOptions);
|
|
219
218
|
executeFile(file: string): Promise<any>;
|
|
@@ -223,9 +222,9 @@ declare class ViteNodeRunner {
|
|
|
223
222
|
resolveUrl(id: string, importee?: string): Promise<[url: string, fsPath: string]>;
|
|
224
223
|
private _fetchModule;
|
|
225
224
|
protected getContextPrimitives(): {
|
|
226
|
-
Object: ObjectConstructor
|
|
227
|
-
Reflect: typeof Reflect
|
|
228
|
-
Symbol: SymbolConstructor
|
|
225
|
+
Object: ObjectConstructor;
|
|
226
|
+
Reflect: typeof Reflect;
|
|
227
|
+
Symbol: SymbolConstructor;
|
|
229
228
|
};
|
|
230
229
|
protected runModule(context: Record<string, any>, transformed: string): Promise<void>;
|
|
231
230
|
/**
|
|
@@ -341,8 +340,8 @@ interface ViteNodeServerOptions {
|
|
|
341
340
|
* Transform method for modules
|
|
342
341
|
*/
|
|
343
342
|
transformMode?: {
|
|
344
|
-
ssr?: RegExp[]
|
|
345
|
-
web?: RegExp[]
|
|
343
|
+
ssr?: RegExp[];
|
|
344
|
+
web?: RegExp[];
|
|
346
345
|
};
|
|
347
346
|
debug?: DebuggerOptions;
|
|
348
347
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-
|
|
2
|
-
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-
|
|
1
|
+
export { A as Arrayable, h as Awaitable, k as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, i as FetchFunction, F as FetchResult, b as HotContext, l as ModuleCache, M as ModuleCacheMap, f as ModuleExecutionInfo, N as Nullable, R as RawSourceMap, j as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, n as ViteNodeResolveModule, m as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index.d-uN06xifv.js';
|
|
2
|
+
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-BWFx6tPc.js';
|