vite-node 0.30.0 → 0.31.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 +2 -1
- package/dist/cli.mjs +1 -1
- package/dist/client.cjs +22 -27
- package/dist/client.d.ts +2 -1
- package/dist/client.mjs +22 -27
- package/dist/hmr.d.ts +81 -4
- package/dist/index.d.ts +2 -1
- package/dist/server.cjs +8 -8
- package/dist/server.d.ts +4 -3
- package/dist/server.mjs +8 -8
- package/dist/source-map.cjs +4 -4
- package/dist/source-map.mjs +5 -5
- package/dist/{types-c39b64bb.d.ts → types-d9c0fafd.d.ts} +2 -111
- package/dist/types.d.ts +2 -1
- package/dist/utils.d.ts +2 -1
- package/package.json +2 -2
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.31.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.31.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
|
@@ -53,6 +53,8 @@ const clientStub = {
|
|
|
53
53
|
invalidate: () => {
|
|
54
54
|
},
|
|
55
55
|
on: () => {
|
|
56
|
+
},
|
|
57
|
+
send: () => {
|
|
56
58
|
}
|
|
57
59
|
};
|
|
58
60
|
},
|
|
@@ -188,16 +190,29 @@ class ViteNodeRunner {
|
|
|
188
190
|
mod.importers = /* @__PURE__ */ new Set();
|
|
189
191
|
if (importee)
|
|
190
192
|
mod.importers.add(importee);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
193
|
+
const getStack = () => `stack:
|
|
194
|
+
${[...callstack, fsPath].reverse().map((p) => ` - ${p}`).join("\n")}`;
|
|
195
|
+
if (callstack.includes(fsPath) || callstack.some((c) => {
|
|
196
|
+
var _a;
|
|
197
|
+
return (_a = this.moduleCache.get(c).importers) == null ? void 0 : _a.has(fsPath);
|
|
198
|
+
})) {
|
|
199
|
+
if (mod.exports)
|
|
200
|
+
return mod.exports;
|
|
201
|
+
}
|
|
202
|
+
let debugTimer;
|
|
203
|
+
if (this.debug)
|
|
204
|
+
debugTimer = setTimeout(() => console.warn(`[vite-node] module ${fsPath} takes over 2s to load.
|
|
205
|
+
${getStack()}`), 2e3);
|
|
197
206
|
try {
|
|
207
|
+
if (mod.promise)
|
|
208
|
+
return await mod.promise;
|
|
209
|
+
const promise = this.directRequest(id, fsPath, callstack);
|
|
210
|
+
Object.assign(mod, { promise, evaluated: false });
|
|
198
211
|
return await promise;
|
|
199
212
|
} finally {
|
|
200
213
|
mod.evaluated = true;
|
|
214
|
+
if (debugTimer)
|
|
215
|
+
clearTimeout(debugTimer);
|
|
201
216
|
}
|
|
202
217
|
}
|
|
203
218
|
shouldResolveId(id, _importee) {
|
|
@@ -228,27 +243,7 @@ class ViteNodeRunner {
|
|
|
228
243
|
}
|
|
229
244
|
/** @internal */
|
|
230
245
|
async dependencyRequest(id, fsPath, callstack) {
|
|
231
|
-
|
|
232
|
-
const getStack = () => {
|
|
233
|
-
return `stack:
|
|
234
|
-
${[...callstack, fsPath].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
235
|
-
};
|
|
236
|
-
let debugTimer;
|
|
237
|
-
if (this.debug)
|
|
238
|
-
debugTimer = setTimeout(() => console.warn(() => `module ${fsPath} takes over 2s to load.
|
|
239
|
-
${getStack()}`), 2e3);
|
|
240
|
-
try {
|
|
241
|
-
if (callstack.includes(fsPath)) {
|
|
242
|
-
const depExports = (_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.exports;
|
|
243
|
-
if (depExports)
|
|
244
|
-
return depExports;
|
|
245
|
-
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
246
|
-
}
|
|
247
|
-
return await this.cachedRequest(id, fsPath, callstack);
|
|
248
|
-
} finally {
|
|
249
|
-
if (debugTimer)
|
|
250
|
-
clearTimeout(debugTimer);
|
|
251
|
-
}
|
|
246
|
+
return await this.cachedRequest(id, fsPath, callstack);
|
|
252
247
|
}
|
|
253
248
|
/** @internal */
|
|
254
249
|
async directRequest(id, fsPath, _callstack) {
|
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import './types.d-1e7e3fdf.js';
|
|
2
|
-
export {
|
|
2
|
+
export { h as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, g as ViteNodeRunner } from './types-d9c0fafd.js';
|
|
3
|
+
import 'vite/types/hot';
|
package/dist/client.mjs
CHANGED
|
@@ -26,6 +26,8 @@ const clientStub = {
|
|
|
26
26
|
invalidate: () => {
|
|
27
27
|
},
|
|
28
28
|
on: () => {
|
|
29
|
+
},
|
|
30
|
+
send: () => {
|
|
29
31
|
}
|
|
30
32
|
};
|
|
31
33
|
},
|
|
@@ -161,16 +163,29 @@ class ViteNodeRunner {
|
|
|
161
163
|
mod.importers = /* @__PURE__ */ new Set();
|
|
162
164
|
if (importee)
|
|
163
165
|
mod.importers.add(importee);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
const getStack = () => `stack:
|
|
167
|
+
${[...callstack, fsPath].reverse().map((p) => ` - ${p}`).join("\n")}`;
|
|
168
|
+
if (callstack.includes(fsPath) || callstack.some((c) => {
|
|
169
|
+
var _a;
|
|
170
|
+
return (_a = this.moduleCache.get(c).importers) == null ? void 0 : _a.has(fsPath);
|
|
171
|
+
})) {
|
|
172
|
+
if (mod.exports)
|
|
173
|
+
return mod.exports;
|
|
174
|
+
}
|
|
175
|
+
let debugTimer;
|
|
176
|
+
if (this.debug)
|
|
177
|
+
debugTimer = setTimeout(() => console.warn(`[vite-node] module ${fsPath} takes over 2s to load.
|
|
178
|
+
${getStack()}`), 2e3);
|
|
170
179
|
try {
|
|
180
|
+
if (mod.promise)
|
|
181
|
+
return await mod.promise;
|
|
182
|
+
const promise = this.directRequest(id, fsPath, callstack);
|
|
183
|
+
Object.assign(mod, { promise, evaluated: false });
|
|
171
184
|
return await promise;
|
|
172
185
|
} finally {
|
|
173
186
|
mod.evaluated = true;
|
|
187
|
+
if (debugTimer)
|
|
188
|
+
clearTimeout(debugTimer);
|
|
174
189
|
}
|
|
175
190
|
}
|
|
176
191
|
shouldResolveId(id, _importee) {
|
|
@@ -201,27 +216,7 @@ class ViteNodeRunner {
|
|
|
201
216
|
}
|
|
202
217
|
/** @internal */
|
|
203
218
|
async dependencyRequest(id, fsPath, callstack) {
|
|
204
|
-
|
|
205
|
-
const getStack = () => {
|
|
206
|
-
return `stack:
|
|
207
|
-
${[...callstack, fsPath].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
208
|
-
};
|
|
209
|
-
let debugTimer;
|
|
210
|
-
if (this.debug)
|
|
211
|
-
debugTimer = setTimeout(() => console.warn(() => `module ${fsPath} takes over 2s to load.
|
|
212
|
-
${getStack()}`), 2e3);
|
|
213
|
-
try {
|
|
214
|
-
if (callstack.includes(fsPath)) {
|
|
215
|
-
const depExports = (_a = this.moduleCache.get(fsPath)) == null ? void 0 : _a.exports;
|
|
216
|
-
if (depExports)
|
|
217
|
-
return depExports;
|
|
218
|
-
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
219
|
-
}
|
|
220
|
-
return await this.cachedRequest(id, fsPath, callstack);
|
|
221
|
-
} finally {
|
|
222
|
-
if (debugTimer)
|
|
223
|
-
clearTimeout(debugTimer);
|
|
224
|
-
}
|
|
219
|
+
return await this.cachedRequest(id, fsPath, callstack);
|
|
225
220
|
}
|
|
226
221
|
/** @internal */
|
|
227
222
|
async directRequest(id, fsPath, _callstack) {
|
package/dist/hmr.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import { HMRPayload, Plugin } from 'vite';
|
|
3
|
-
import { g as
|
|
2
|
+
import { HMRPayload as HMRPayload$1, Plugin } from 'vite';
|
|
3
|
+
import { g as ViteNodeRunner, H as HotContext } from './types-d9c0fafd.js';
|
|
4
|
+
import 'vite/types/hot';
|
|
4
5
|
import './types.d-1e7e3fdf.js';
|
|
5
6
|
|
|
6
7
|
type EventType = string | symbol;
|
|
@@ -12,7 +13,7 @@ interface Emitter<Events extends Record<EventType, unknown>> {
|
|
|
12
13
|
emit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;
|
|
13
14
|
}
|
|
14
15
|
type HMREmitter = Emitter<{
|
|
15
|
-
'message': HMRPayload;
|
|
16
|
+
'message': HMRPayload$1;
|
|
16
17
|
}> & EventEmitter;
|
|
17
18
|
declare module 'vite' {
|
|
18
19
|
interface ViteDevServer {
|
|
@@ -22,6 +23,82 @@ declare module 'vite' {
|
|
|
22
23
|
declare function createHmrEmitter(): HMREmitter;
|
|
23
24
|
declare function viteNodeHmrPlugin(): Plugin;
|
|
24
25
|
|
|
26
|
+
type HMRPayload =
|
|
27
|
+
| ConnectedPayload
|
|
28
|
+
| UpdatePayload
|
|
29
|
+
| FullReloadPayload
|
|
30
|
+
| CustomPayload
|
|
31
|
+
| ErrorPayload
|
|
32
|
+
| PrunePayload
|
|
33
|
+
|
|
34
|
+
interface ConnectedPayload {
|
|
35
|
+
type: 'connected'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface UpdatePayload {
|
|
39
|
+
type: 'update'
|
|
40
|
+
updates: Update[]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface Update {
|
|
44
|
+
type: 'js-update' | 'css-update'
|
|
45
|
+
path: string
|
|
46
|
+
acceptedPath: string
|
|
47
|
+
timestamp: number
|
|
48
|
+
/**
|
|
49
|
+
* @experimental internal
|
|
50
|
+
*/
|
|
51
|
+
explicitImportRequired?: boolean | undefined
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface PrunePayload {
|
|
55
|
+
type: 'prune'
|
|
56
|
+
paths: string[]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface FullReloadPayload {
|
|
60
|
+
type: 'full-reload'
|
|
61
|
+
path?: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface CustomPayload {
|
|
65
|
+
type: 'custom'
|
|
66
|
+
event: string
|
|
67
|
+
data?: any
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface ErrorPayload {
|
|
71
|
+
type: 'error'
|
|
72
|
+
err: {
|
|
73
|
+
[name: string]: any
|
|
74
|
+
message: string
|
|
75
|
+
stack: string
|
|
76
|
+
id?: string
|
|
77
|
+
frame?: string
|
|
78
|
+
plugin?: string
|
|
79
|
+
pluginCode?: string
|
|
80
|
+
loc?: {
|
|
81
|
+
file?: string
|
|
82
|
+
line: number
|
|
83
|
+
column: number
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface CustomEventMap {
|
|
89
|
+
'vite:beforeUpdate': UpdatePayload
|
|
90
|
+
'vite:afterUpdate': UpdatePayload
|
|
91
|
+
'vite:beforePrune': PrunePayload
|
|
92
|
+
'vite:beforeFullReload': FullReloadPayload
|
|
93
|
+
'vite:error': ErrorPayload
|
|
94
|
+
'vite:invalidate': InvalidatePayload
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface InvalidatePayload {
|
|
98
|
+
path: string
|
|
99
|
+
message: string | undefined
|
|
100
|
+
}
|
|
101
|
+
|
|
25
102
|
type InferCustomEventPayload<T extends string> = T extends keyof CustomEventMap ? CustomEventMap[T] : any;
|
|
26
103
|
interface HotModule {
|
|
27
104
|
id: string;
|
|
@@ -46,7 +123,7 @@ interface CacheData {
|
|
|
46
123
|
declare function getCache(runner: ViteNodeRunner): CacheData;
|
|
47
124
|
declare function sendMessageBuffer(runner: ViteNodeRunner, emitter: HMREmitter): void;
|
|
48
125
|
declare function reload(runner: ViteNodeRunner, files: string[]): Promise<any[]>;
|
|
49
|
-
declare function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], payload: HMRPayload
|
|
126
|
+
declare function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], payload: HMRPayload): Promise<void>;
|
|
50
127
|
declare function createHotContext(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], ownerPath: string): HotContext;
|
|
51
128
|
|
|
52
129
|
export { Emitter, EventType, HMREmitter, Handler, HotCallback, HotModule, InferCustomEventPayload, createHmrEmitter, createHotContext, getCache, handleMessage, reload, sendMessageBuffer, viteNodeHmrPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
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-d9c0fafd.js';
|
|
2
2
|
export { D as DecodedSourceMap, E as EncodedSourceMap } from './types.d-1e7e3fdf.js';
|
|
3
|
+
import 'vite/types/hot';
|
package/dist/server.cjs
CHANGED
|
@@ -288,11 +288,11 @@ class ViteNodeServer {
|
|
|
288
288
|
}
|
|
289
289
|
return this.fetchPromiseMap.get(id);
|
|
290
290
|
}
|
|
291
|
-
async transformRequest(id) {
|
|
291
|
+
async transformRequest(id, filepath = id) {
|
|
292
292
|
if (!this.transformPromiseMap.has(id)) {
|
|
293
293
|
this.transformPromiseMap.set(
|
|
294
294
|
id,
|
|
295
|
-
this._transformRequest(id).finally(() => {
|
|
295
|
+
this._transformRequest(id, filepath).finally(() => {
|
|
296
296
|
this.transformPromiseMap.delete(id);
|
|
297
297
|
})
|
|
298
298
|
);
|
|
@@ -337,7 +337,7 @@ class ViteNodeServer {
|
|
|
337
337
|
(_b = this.debugger) == null ? void 0 : _b.recordExternalize(id, externalize);
|
|
338
338
|
} else {
|
|
339
339
|
const start = perf_hooks.performance.now();
|
|
340
|
-
const r = await this._transformRequest(id, transformMode);
|
|
340
|
+
const r = await this._transformRequest(id, filePath, transformMode);
|
|
341
341
|
duration = perf_hooks.performance.now() - start;
|
|
342
342
|
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
343
343
|
}
|
|
@@ -348,14 +348,14 @@ class ViteNodeServer {
|
|
|
348
348
|
});
|
|
349
349
|
return result;
|
|
350
350
|
}
|
|
351
|
-
async processTransformResult(
|
|
352
|
-
const mod = this.server.moduleGraph.getModuleById(
|
|
351
|
+
async processTransformResult(filepath, result) {
|
|
352
|
+
const mod = this.server.moduleGraph.getModuleById(filepath);
|
|
353
353
|
return sourceMap.withInlineSourcemap(result, {
|
|
354
|
-
filepath: (mod == null ? void 0 : mod.file) ||
|
|
354
|
+
filepath: (mod == null ? void 0 : mod.file) || filepath,
|
|
355
355
|
root: this.server.config.root
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
|
-
async _transformRequest(id, customTransformMode) {
|
|
358
|
+
async _transformRequest(id, filepath, customTransformMode) {
|
|
359
359
|
var _a, _b, _c, _d;
|
|
360
360
|
debugRequest(id);
|
|
361
361
|
let result = null;
|
|
@@ -374,7 +374,7 @@ class ViteNodeServer {
|
|
|
374
374
|
}
|
|
375
375
|
const sourcemap = this.options.sourcemap ?? "inline";
|
|
376
376
|
if (sourcemap === "inline" && result && !id.includes("node_modules"))
|
|
377
|
-
result = await this.processTransformResult(
|
|
377
|
+
result = await this.processTransformResult(filepath, result);
|
|
378
378
|
if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules)
|
|
379
379
|
await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
|
|
380
380
|
return result;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
2
|
import { E as EncodedSourceMap } from './types.d-1e7e3fdf.js';
|
|
3
|
-
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './types-
|
|
3
|
+
import { f as DebuggerOptions, D as DepsHandlingOptions, e as ViteNodeServerOptions, F as FetchResult, d as ViteNodeResolveId } from './types-d9c0fafd.js';
|
|
4
|
+
import 'vite/types/hot';
|
|
4
5
|
|
|
5
6
|
declare class Debugger {
|
|
6
7
|
options: DebuggerOptions;
|
|
@@ -38,10 +39,10 @@ declare class ViteNodeServer {
|
|
|
38
39
|
resolveId(id: string, importer?: string, transformMode?: 'web' | 'ssr'): Promise<ViteNodeResolveId | null>;
|
|
39
40
|
getSourceMap(source: string): EncodedSourceMap | null;
|
|
40
41
|
fetchModule(id: string, transformMode?: 'web' | 'ssr'): Promise<FetchResult>;
|
|
41
|
-
transformRequest(id: string): Promise<TransformResult | null | undefined>;
|
|
42
|
+
transformRequest(id: string, filepath?: string): Promise<TransformResult | null | undefined>;
|
|
42
43
|
getTransformMode(id: string): "web" | "ssr";
|
|
43
44
|
private _fetchModule;
|
|
44
|
-
protected processTransformResult(
|
|
45
|
+
protected processTransformResult(filepath: string, result: TransformResult): Promise<TransformResult>;
|
|
45
46
|
private _transformRequest;
|
|
46
47
|
}
|
|
47
48
|
|
package/dist/server.mjs
CHANGED
|
@@ -279,11 +279,11 @@ class ViteNodeServer {
|
|
|
279
279
|
}
|
|
280
280
|
return this.fetchPromiseMap.get(id);
|
|
281
281
|
}
|
|
282
|
-
async transformRequest(id) {
|
|
282
|
+
async transformRequest(id, filepath = id) {
|
|
283
283
|
if (!this.transformPromiseMap.has(id)) {
|
|
284
284
|
this.transformPromiseMap.set(
|
|
285
285
|
id,
|
|
286
|
-
this._transformRequest(id).finally(() => {
|
|
286
|
+
this._transformRequest(id, filepath).finally(() => {
|
|
287
287
|
this.transformPromiseMap.delete(id);
|
|
288
288
|
})
|
|
289
289
|
);
|
|
@@ -328,7 +328,7 @@ class ViteNodeServer {
|
|
|
328
328
|
(_b = this.debugger) == null ? void 0 : _b.recordExternalize(id, externalize);
|
|
329
329
|
} else {
|
|
330
330
|
const start = performance.now();
|
|
331
|
-
const r = await this._transformRequest(id, transformMode);
|
|
331
|
+
const r = await this._transformRequest(id, filePath, transformMode);
|
|
332
332
|
duration = performance.now() - start;
|
|
333
333
|
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
334
334
|
}
|
|
@@ -339,14 +339,14 @@ class ViteNodeServer {
|
|
|
339
339
|
});
|
|
340
340
|
return result;
|
|
341
341
|
}
|
|
342
|
-
async processTransformResult(
|
|
343
|
-
const mod = this.server.moduleGraph.getModuleById(
|
|
342
|
+
async processTransformResult(filepath, result) {
|
|
343
|
+
const mod = this.server.moduleGraph.getModuleById(filepath);
|
|
344
344
|
return withInlineSourcemap(result, {
|
|
345
|
-
filepath: (mod == null ? void 0 : mod.file) ||
|
|
345
|
+
filepath: (mod == null ? void 0 : mod.file) || filepath,
|
|
346
346
|
root: this.server.config.root
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
|
-
async _transformRequest(id, customTransformMode) {
|
|
349
|
+
async _transformRequest(id, filepath, customTransformMode) {
|
|
350
350
|
var _a, _b, _c, _d;
|
|
351
351
|
debugRequest(id);
|
|
352
352
|
let result = null;
|
|
@@ -365,7 +365,7 @@ class ViteNodeServer {
|
|
|
365
365
|
}
|
|
366
366
|
const sourcemap = this.options.sourcemap ?? "inline";
|
|
367
367
|
if (sourcemap === "inline" && result && !id.includes("node_modules"))
|
|
368
|
-
result = await this.processTransformResult(
|
|
368
|
+
result = await this.processTransformResult(filepath, result);
|
|
369
369
|
if ((_c = this.options.debug) == null ? void 0 : _c.dumpModules)
|
|
370
370
|
await ((_d = this.debugger) == null ? void 0 : _d.dumpFile(id, result));
|
|
371
371
|
return result;
|
package/dist/source-map.cjs
CHANGED
|
@@ -874,10 +874,10 @@ function withInlineSourcemap(result, options) {
|
|
|
874
874
|
map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
|
|
875
875
|
if (!source)
|
|
876
876
|
return source;
|
|
877
|
-
if (
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
877
|
+
if (pathe.isAbsolute(source)) {
|
|
878
|
+
const actualPath = !source.startsWith(options.root) && source.startsWith("/") ? pathe.resolve(options.root, source.slice(1)) : source;
|
|
879
|
+
return pathe.relative(pathe.dirname(options.filepath), actualPath);
|
|
880
|
+
}
|
|
881
881
|
return source;
|
|
882
882
|
});
|
|
883
883
|
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`, "g");
|
package/dist/source-map.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAbsolute, resolve as resolve$2,
|
|
1
|
+
import { isAbsolute, resolve as resolve$2, relative, dirname } from 'pathe';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
|
|
@@ -865,10 +865,10 @@ function withInlineSourcemap(result, options) {
|
|
|
865
865
|
map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
|
|
866
866
|
if (!source)
|
|
867
867
|
return source;
|
|
868
|
-
if (
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
868
|
+
if (isAbsolute(source)) {
|
|
869
|
+
const actualPath = !source.startsWith(options.root) && source.startsWith("/") ? resolve$2(options.root, source.slice(1)) : source;
|
|
870
|
+
return relative(dirname(options.filepath), actualPath);
|
|
871
|
+
}
|
|
872
872
|
return source;
|
|
873
873
|
});
|
|
874
874
|
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`, "g");
|
|
@@ -1,115 +1,6 @@
|
|
|
1
|
+
import { ViteHotContext } from 'vite/types/hot';
|
|
1
2
|
import { E as EncodedSourceMap } from './types.d-1e7e3fdf.js';
|
|
2
3
|
|
|
3
|
-
type HMRPayload =
|
|
4
|
-
| ConnectedPayload
|
|
5
|
-
| UpdatePayload
|
|
6
|
-
| FullReloadPayload
|
|
7
|
-
| CustomPayload
|
|
8
|
-
| ErrorPayload
|
|
9
|
-
| PrunePayload
|
|
10
|
-
|
|
11
|
-
interface ConnectedPayload {
|
|
12
|
-
type: 'connected'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface UpdatePayload {
|
|
16
|
-
type: 'update'
|
|
17
|
-
updates: Update[]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface Update {
|
|
21
|
-
type: 'js-update' | 'css-update'
|
|
22
|
-
path: string
|
|
23
|
-
acceptedPath: string
|
|
24
|
-
timestamp: number
|
|
25
|
-
/**
|
|
26
|
-
* @experimental internal
|
|
27
|
-
*/
|
|
28
|
-
explicitImportRequired?: boolean | undefined
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface PrunePayload {
|
|
32
|
-
type: 'prune'
|
|
33
|
-
paths: string[]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface FullReloadPayload {
|
|
37
|
-
type: 'full-reload'
|
|
38
|
-
path?: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
interface CustomPayload {
|
|
42
|
-
type: 'custom'
|
|
43
|
-
event: string
|
|
44
|
-
data?: any
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface ErrorPayload {
|
|
48
|
-
type: 'error'
|
|
49
|
-
err: {
|
|
50
|
-
[name: string]: any
|
|
51
|
-
message: string
|
|
52
|
-
stack: string
|
|
53
|
-
id?: string
|
|
54
|
-
frame?: string
|
|
55
|
-
plugin?: string
|
|
56
|
-
pluginCode?: string
|
|
57
|
-
loc?: {
|
|
58
|
-
file?: string
|
|
59
|
-
line: number
|
|
60
|
-
column: number
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface CustomEventMap {
|
|
66
|
-
'vite:beforeUpdate': UpdatePayload
|
|
67
|
-
'vite:afterUpdate': UpdatePayload
|
|
68
|
-
'vite:beforePrune': PrunePayload
|
|
69
|
-
'vite:beforeFullReload': FullReloadPayload
|
|
70
|
-
'vite:error': ErrorPayload
|
|
71
|
-
'vite:invalidate': InvalidatePayload
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
interface InvalidatePayload {
|
|
75
|
-
path: string
|
|
76
|
-
message: string | undefined
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
type InferCustomEventPayload<T extends string> =
|
|
80
|
-
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
81
|
-
|
|
82
|
-
type ModuleNamespace = Record<string, any> & {
|
|
83
|
-
[Symbol.toStringTag]: 'Module'
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface ViteHotContext {
|
|
87
|
-
readonly data: any
|
|
88
|
-
|
|
89
|
-
accept(): void
|
|
90
|
-
accept(cb: (mod: ModuleNamespace | undefined) => void): void
|
|
91
|
-
accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
|
|
92
|
-
accept(
|
|
93
|
-
deps: readonly string[],
|
|
94
|
-
cb: (mods: Array<ModuleNamespace | undefined>) => void,
|
|
95
|
-
): void
|
|
96
|
-
|
|
97
|
-
acceptExports(
|
|
98
|
-
exportNames: string | readonly string[],
|
|
99
|
-
cb?: (mod: ModuleNamespace | undefined) => void,
|
|
100
|
-
): void
|
|
101
|
-
|
|
102
|
-
dispose(cb: (data: any) => void): void
|
|
103
|
-
prune(cb: (data: any) => void): void
|
|
104
|
-
invalidate(message?: string): void
|
|
105
|
-
|
|
106
|
-
on<T extends string>(
|
|
107
|
-
event: T,
|
|
108
|
-
cb: (payload: InferCustomEventPayload<T>) => void,
|
|
109
|
-
): void
|
|
110
|
-
send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
|
|
111
|
-
}
|
|
112
|
-
|
|
113
4
|
declare const DEFAULT_REQUEST_STUBS: Record<string, unknown>;
|
|
114
5
|
declare class ModuleCacheMap extends Map<string, ModuleCache> {
|
|
115
6
|
normalizePath(fsPath: string): string;
|
|
@@ -265,4 +156,4 @@ interface DebuggerOptions {
|
|
|
265
156
|
loadDumppedModules?: boolean;
|
|
266
157
|
}
|
|
267
158
|
|
|
268
|
-
export { Arrayable as A, CreateHotContextFunction as C, DepsHandlingOptions as D, FetchResult as F, HotContext as H, ModuleCacheMap as M, Nullable as N, RawSourceMap as R, StartOfSourceMap as S, ViteNodeRunnerOptions as V, FetchFunction as a, ResolveIdFunction as b, ModuleCache as c, ViteNodeResolveId as d, ViteNodeServerOptions as e, DebuggerOptions as f,
|
|
159
|
+
export { Arrayable as A, CreateHotContextFunction as C, DepsHandlingOptions as D, FetchResult as F, HotContext as H, ModuleCacheMap as M, Nullable as N, RawSourceMap as R, StartOfSourceMap as S, ViteNodeRunnerOptions as V, FetchFunction as a, ResolveIdFunction as b, ModuleCache as c, ViteNodeResolveId as d, ViteNodeServerOptions as e, DebuggerOptions as f, ViteNodeRunner as g, DEFAULT_REQUEST_STUBS as h };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import 'vite/types/hot';
|
|
2
2
|
export { D as DecodedSourceMap, E as EncodedSourceMap } from './types.d-1e7e3fdf.js';
|
|
3
|
+
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-d9c0fafd.js';
|
package/dist/utils.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Vite as Node.js runtime",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"funding": "https://
|
|
7
|
+
"funding": "https://opencollective.com/vitest",
|
|
8
8
|
"homepage": "https://github.com/vitest-dev/vitest/blob/main/packages/vite-node#readme",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|