vite-node 1.0.0-beta.0 → 1.0.0-beta.2
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 -1
- package/dist/cli.d.ts +3 -3
- package/dist/cli.mjs +2 -1
- package/dist/client.d.ts +2 -2
- package/dist/hmr.d.ts +3 -3
- package/dist/{index-6fb787b2.d.ts → index-e4206afe.d.ts} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/server.cjs +43 -22
- package/dist/server.d.ts +14 -8
- package/dist/server.mjs +43 -22
- package/dist/source-map.d.ts +1 -1
- package/dist/{trace-mapping.d-e677e8f4.d.ts → trace-mapping.d-cf594fd7.d.ts} +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -10,6 +10,7 @@ var sourceMap = require('./source-map.cjs');
|
|
|
10
10
|
var hmr = require('./hmr.cjs');
|
|
11
11
|
require('perf_hooks');
|
|
12
12
|
require('fs');
|
|
13
|
+
require('assert');
|
|
13
14
|
require('pathe');
|
|
14
15
|
require('debug');
|
|
15
16
|
require('mlly');
|
|
@@ -20,7 +21,7 @@ require('node:url');
|
|
|
20
21
|
require('node:vm');
|
|
21
22
|
require('node:events');
|
|
22
23
|
|
|
23
|
-
var version = "1.0.0-beta.
|
|
24
|
+
var version = "1.0.0-beta.2";
|
|
24
25
|
|
|
25
26
|
const cli = cac("vite-node");
|
|
26
27
|
cli.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").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command");
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as ViteNodeServerOptions } from './index-
|
|
2
|
-
import './trace-mapping.d-
|
|
1
|
+
import { V as ViteNodeServerOptions } from './index-e4206afe.js';
|
|
2
|
+
import './trace-mapping.d-cf594fd7.js';
|
|
3
3
|
|
|
4
4
|
interface CliOptions {
|
|
5
5
|
root?: string;
|
|
@@ -18,4 +18,4 @@ type ComputeViteNodeServerOptionsCLI<T extends Record<string, any>> = {
|
|
|
18
18
|
};
|
|
19
19
|
type ViteNodeServerOptionsCLI = ComputeViteNodeServerOptionsCLI<ViteNodeServerOptions>;
|
|
20
20
|
|
|
21
|
-
export { CliOptions, ViteNodeServerOptionsCLI };
|
|
21
|
+
export type { CliOptions, ViteNodeServerOptionsCLI };
|
package/dist/cli.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { installSourcemapsSupport } from './source-map.mjs';
|
|
|
8
8
|
import { viteNodeHmrPlugin, createHotContext, handleMessage } from './hmr.mjs';
|
|
9
9
|
import 'node:perf_hooks';
|
|
10
10
|
import 'node:fs';
|
|
11
|
+
import 'node:assert';
|
|
11
12
|
import 'pathe';
|
|
12
13
|
import 'debug';
|
|
13
14
|
import 'mlly';
|
|
@@ -18,7 +19,7 @@ import 'node:url';
|
|
|
18
19
|
import 'node:vm';
|
|
19
20
|
import 'node:events';
|
|
20
21
|
|
|
21
|
-
var version = "1.0.0-beta.
|
|
22
|
+
var version = "1.0.0-beta.2";
|
|
22
23
|
|
|
23
24
|
const cli = cac("vite-node");
|
|
24
25
|
cli.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").option("-v, --version", "Output the version number").option("-h, --help", "Display help for command");
|
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './trace-mapping.d-
|
|
2
|
-
export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-
|
|
1
|
+
import './trace-mapping.d-cf594fd7.js';
|
|
2
|
+
export { e as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, a as ViteNodeRunner } from './index-e4206afe.js';
|
package/dist/hmr.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
2
|
import { HMRPayload, Plugin } from 'vite';
|
|
3
|
-
import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index-
|
|
4
|
-
import './trace-mapping.d-
|
|
3
|
+
import { C as CustomEventMap, a as ViteNodeRunner, H as HMRPayload$1, b as HotContext } from './index-e4206afe.js';
|
|
4
|
+
import './trace-mapping.d-cf594fd7.js';
|
|
5
5
|
|
|
6
6
|
type EventType = string | symbol;
|
|
7
7
|
type Handler<T = unknown> = (event: T) => void;
|
|
@@ -52,4 +52,4 @@ declare function reload(runner: ViteNodeRunner, files: string[]): Promise<any[]>
|
|
|
52
52
|
declare function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], payload: HMRPayload$1): Promise<void>;
|
|
53
53
|
declare function createHotContext(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], ownerPath: string): HotContext;
|
|
54
54
|
|
|
55
|
-
export { Emitter, EventType, HMREmitter, Handler, HotCallback, HotModule, InferCustomEventPayload, ModuleNamespace, createHmrEmitter, createHotContext, getCache, handleMessage, reload, sendMessageBuffer, viteNodeHmrPlugin };
|
|
55
|
+
export { type Emitter, type EventType, type HMREmitter, type Handler, type HotCallback, type HotModule, type InferCustomEventPayload, type ModuleNamespace, createHmrEmitter, createHotContext, getCache, handleMessage, reload, sendMessageBuffer, viteNodeHmrPlugin };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-
|
|
1
|
+
import { E as EncodedSourceMap } from './trace-mapping.d-cf594fd7.js';
|
|
2
2
|
|
|
3
3
|
type HMRPayload =
|
|
4
4
|
| ConnectedPayload
|
|
@@ -295,4 +295,4 @@ interface DebuggerOptions {
|
|
|
295
295
|
loadDumppedModules?: boolean;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
export { Arrayable as A, CustomEventMap as C, DebuggerOptions as D, FetchResult as F, HMRPayload as H, ModuleCacheMap as M, Nullable as N, RawSourceMap as R, StartOfSourceMap as S, ViteNodeServerOptions as V, ViteNodeRunner as a, HotContext as b, DepsHandlingOptions as c, ViteNodeResolveId as d, DEFAULT_REQUEST_STUBS as e, Awaitable as f, FetchFunction as g, ResolveIdFunction as h, CreateHotContextFunction as i, ModuleCache as j, ViteNodeRunnerOptions as k };
|
|
298
|
+
export { type Arrayable as A, type CustomEventMap as C, type DebuggerOptions as D, type FetchResult as F, type HMRPayload as H, ModuleCacheMap as M, type Nullable as N, type RawSourceMap as R, type StartOfSourceMap as S, type ViteNodeServerOptions as V, ViteNodeRunner as a, type HotContext as b, type DepsHandlingOptions as c, type ViteNodeResolveId as d, DEFAULT_REQUEST_STUBS as e, type Awaitable as f, type FetchFunction as g, type ResolveIdFunction as h, type CreateHotContextFunction as i, type ModuleCache as j, type ViteNodeRunnerOptions as k };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-
|
|
2
|
-
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-
|
|
1
|
+
export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-e4206afe.js';
|
|
2
|
+
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-cf594fd7.js';
|
package/dist/server.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var perf_hooks = require('perf_hooks');
|
|
4
4
|
var fs = require('fs');
|
|
5
|
+
var assert = require('assert');
|
|
5
6
|
var pathe = require('pathe');
|
|
6
7
|
var createDebug = require('debug');
|
|
7
8
|
var mlly = require('mlly');
|
|
@@ -24,8 +25,8 @@ const defaultInline = [
|
|
|
24
25
|
new RegExp(`\\.(${constants.KNOWN_ASSET_TYPES.join("|")})$`)
|
|
25
26
|
];
|
|
26
27
|
const depsExternal = [
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
/\/node_modules\/.*\.cjs\.js$/,
|
|
29
|
+
/\/node_modules\/.*\.mjs$/
|
|
29
30
|
];
|
|
30
31
|
function guessCJSversion(id) {
|
|
31
32
|
if (id.match(ESM_EXT_RE)) {
|
|
@@ -217,9 +218,19 @@ class ViteNodeServer {
|
|
|
217
218
|
if (!options.deps.moduleDirectories.includes("/node_modules/"))
|
|
218
219
|
options.deps.moduleDirectories.push("/node_modules/");
|
|
219
220
|
}
|
|
220
|
-
fetchPromiseMap =
|
|
221
|
-
|
|
221
|
+
fetchPromiseMap = {
|
|
222
|
+
ssr: /* @__PURE__ */ new Map(),
|
|
223
|
+
web: /* @__PURE__ */ new Map()
|
|
224
|
+
};
|
|
225
|
+
transformPromiseMap = {
|
|
226
|
+
ssr: /* @__PURE__ */ new Map(),
|
|
227
|
+
web: /* @__PURE__ */ new Map()
|
|
228
|
+
};
|
|
222
229
|
existingOptimizedDeps = /* @__PURE__ */ new Set();
|
|
230
|
+
fetchCaches = {
|
|
231
|
+
ssr: /* @__PURE__ */ new Map(),
|
|
232
|
+
web: /* @__PURE__ */ new Map()
|
|
233
|
+
};
|
|
223
234
|
fetchCache = /* @__PURE__ */ new Map();
|
|
224
235
|
externalizeCache = /* @__PURE__ */ new Map();
|
|
225
236
|
debugger;
|
|
@@ -255,30 +266,39 @@ class ViteNodeServer {
|
|
|
255
266
|
const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? void 0 : _b.ssrTransformResult;
|
|
256
267
|
return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
|
|
257
268
|
}
|
|
269
|
+
assertMode(mode) {
|
|
270
|
+
assert(mode === "web" || mode === "ssr", `"transformMode" can only be "web" or "ssr", received "${mode}".`);
|
|
271
|
+
}
|
|
258
272
|
async fetchModule(id, transformMode) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
273
|
+
const moduleId = utils.normalizeModuleId(id);
|
|
274
|
+
const mode = transformMode || this.getTransformMode(id);
|
|
275
|
+
this.assertMode(mode);
|
|
276
|
+
const promiseMap = this.fetchPromiseMap[mode];
|
|
277
|
+
if (!promiseMap.has(moduleId)) {
|
|
278
|
+
promiseMap.set(
|
|
279
|
+
moduleId,
|
|
280
|
+
this._fetchModule(moduleId, mode).then((r) => {
|
|
264
281
|
return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
|
|
265
282
|
}).finally(() => {
|
|
266
|
-
|
|
283
|
+
promiseMap.delete(moduleId);
|
|
267
284
|
})
|
|
268
285
|
);
|
|
269
286
|
}
|
|
270
|
-
return
|
|
287
|
+
return promiseMap.get(moduleId);
|
|
271
288
|
}
|
|
272
|
-
async transformRequest(id, filepath = id) {
|
|
273
|
-
|
|
274
|
-
|
|
289
|
+
async transformRequest(id, filepath = id, transformMode) {
|
|
290
|
+
const mode = transformMode || this.getTransformMode(id);
|
|
291
|
+
this.assertMode(mode);
|
|
292
|
+
const promiseMap = this.transformPromiseMap[mode];
|
|
293
|
+
if (!promiseMap.has(id)) {
|
|
294
|
+
promiseMap.set(
|
|
275
295
|
id,
|
|
276
|
-
this._transformRequest(id, filepath).finally(() => {
|
|
277
|
-
|
|
296
|
+
this._transformRequest(id, filepath, mode).finally(() => {
|
|
297
|
+
promiseMap.delete(id);
|
|
278
298
|
})
|
|
279
299
|
);
|
|
280
300
|
}
|
|
281
|
-
return
|
|
301
|
+
return promiseMap.get(id);
|
|
282
302
|
}
|
|
283
303
|
async transformModule(id, transformMode) {
|
|
284
304
|
if (transformMode !== "web")
|
|
@@ -317,7 +337,7 @@ class ViteNodeServer {
|
|
|
317
337
|
const { path: filePath } = utils.toFilePath(id, this.server.config.root);
|
|
318
338
|
const module = this.server.moduleGraph.getModuleById(id);
|
|
319
339
|
const timestamp = module ? module.lastHMRTimestamp : null;
|
|
320
|
-
const cache = this.
|
|
340
|
+
const cache = this.fetchCaches[transformMode].get(filePath);
|
|
321
341
|
if (timestamp && cache && cache.timestamp >= timestamp)
|
|
322
342
|
return cache.result;
|
|
323
343
|
const time = Date.now();
|
|
@@ -332,11 +352,13 @@ class ViteNodeServer {
|
|
|
332
352
|
duration = perf_hooks.performance.now() - start;
|
|
333
353
|
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
334
354
|
}
|
|
335
|
-
|
|
355
|
+
const cacheEntry = {
|
|
336
356
|
duration,
|
|
337
357
|
timestamp: time,
|
|
338
358
|
result
|
|
339
|
-
}
|
|
359
|
+
};
|
|
360
|
+
this.fetchCaches[transformMode].set(filePath, cacheEntry);
|
|
361
|
+
this.fetchCache.set(filePath, cacheEntry);
|
|
340
362
|
return result;
|
|
341
363
|
}
|
|
342
364
|
async processTransformResult(filepath, result) {
|
|
@@ -346,7 +368,7 @@ class ViteNodeServer {
|
|
|
346
368
|
root: this.server.config.root
|
|
347
369
|
});
|
|
348
370
|
}
|
|
349
|
-
async _transformRequest(id, filepath,
|
|
371
|
+
async _transformRequest(id, filepath, transformMode) {
|
|
350
372
|
var _a, _b, _c, _d;
|
|
351
373
|
debugRequest(id);
|
|
352
374
|
let result = null;
|
|
@@ -355,7 +377,6 @@ class ViteNodeServer {
|
|
|
355
377
|
if (result)
|
|
356
378
|
return result;
|
|
357
379
|
}
|
|
358
|
-
const transformMode = customTransformMode ?? this.getTransformMode(id);
|
|
359
380
|
if (transformMode === "web") {
|
|
360
381
|
result = await this.server.transformRequest(id);
|
|
361
382
|
if (result)
|
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
|
-
import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions,
|
|
3
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-
|
|
2
|
+
import { D as DebuggerOptions, c as DepsHandlingOptions, V as ViteNodeServerOptions, d as ViteNodeResolveId, F as FetchResult } from './index-e4206afe.js';
|
|
3
|
+
import { E as EncodedSourceMap } from './trace-mapping.d-cf594fd7.js';
|
|
4
4
|
|
|
5
5
|
declare class Debugger {
|
|
6
6
|
options: DebuggerOptions;
|
|
@@ -19,17 +19,22 @@ declare class Debugger {
|
|
|
19
19
|
declare function guessCJSversion(id: string): string | undefined;
|
|
20
20
|
declare function shouldExternalize(id: string, options?: DepsHandlingOptions, cache?: Map<string, Promise<string | false>>): Promise<string | false>;
|
|
21
21
|
|
|
22
|
+
interface FetchCache {
|
|
23
|
+
duration?: number;
|
|
24
|
+
timestamp: number;
|
|
25
|
+
result: FetchResult;
|
|
26
|
+
}
|
|
22
27
|
declare class ViteNodeServer {
|
|
23
28
|
server: ViteDevServer;
|
|
24
29
|
options: ViteNodeServerOptions;
|
|
25
30
|
private fetchPromiseMap;
|
|
26
31
|
private transformPromiseMap;
|
|
27
32
|
private existingOptimizedDeps;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
fetchCaches: {
|
|
34
|
+
ssr: Map<string, FetchCache>;
|
|
35
|
+
web: Map<string, FetchCache>;
|
|
36
|
+
};
|
|
37
|
+
fetchCache: Map<string, FetchCache>;
|
|
33
38
|
externalizeCache: Map<string, Promise<string | false>>;
|
|
34
39
|
debugger?: Debugger;
|
|
35
40
|
constructor(server: ViteDevServer, options?: ViteNodeServerOptions);
|
|
@@ -37,8 +42,9 @@ declare class ViteNodeServer {
|
|
|
37
42
|
private ensureExists;
|
|
38
43
|
resolveId(id: string, importer?: string, transformMode?: 'web' | 'ssr'): Promise<ViteNodeResolveId | null>;
|
|
39
44
|
getSourceMap(source: string): EncodedSourceMap | null;
|
|
45
|
+
private assertMode;
|
|
40
46
|
fetchModule(id: string, transformMode?: 'web' | 'ssr'): Promise<FetchResult>;
|
|
41
|
-
transformRequest(id: string, filepath?: string): Promise<TransformResult | null | undefined>;
|
|
47
|
+
transformRequest(id: string, filepath?: string, transformMode?: 'web' | 'ssr'): Promise<TransformResult | null | undefined>;
|
|
42
48
|
transformModule(id: string, transformMode?: 'web' | 'ssr'): Promise<{
|
|
43
49
|
code: string | undefined;
|
|
44
50
|
}>;
|
package/dist/server.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
2
|
import { existsSync, promises } from 'node:fs';
|
|
3
|
+
import assert from 'node:assert';
|
|
3
4
|
import { join, resolve, relative, normalize } from 'pathe';
|
|
4
5
|
import createDebug from 'debug';
|
|
5
6
|
import { isValidNodeImport } from 'mlly';
|
|
@@ -22,8 +23,8 @@ const defaultInline = [
|
|
|
22
23
|
new RegExp(`\\.(${KNOWN_ASSET_TYPES.join("|")})$`)
|
|
23
24
|
];
|
|
24
25
|
const depsExternal = [
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
/\/node_modules\/.*\.cjs\.js$/,
|
|
27
|
+
/\/node_modules\/.*\.mjs$/
|
|
27
28
|
];
|
|
28
29
|
function guessCJSversion(id) {
|
|
29
30
|
if (id.match(ESM_EXT_RE)) {
|
|
@@ -215,9 +216,19 @@ class ViteNodeServer {
|
|
|
215
216
|
if (!options.deps.moduleDirectories.includes("/node_modules/"))
|
|
216
217
|
options.deps.moduleDirectories.push("/node_modules/");
|
|
217
218
|
}
|
|
218
|
-
fetchPromiseMap =
|
|
219
|
-
|
|
219
|
+
fetchPromiseMap = {
|
|
220
|
+
ssr: /* @__PURE__ */ new Map(),
|
|
221
|
+
web: /* @__PURE__ */ new Map()
|
|
222
|
+
};
|
|
223
|
+
transformPromiseMap = {
|
|
224
|
+
ssr: /* @__PURE__ */ new Map(),
|
|
225
|
+
web: /* @__PURE__ */ new Map()
|
|
226
|
+
};
|
|
220
227
|
existingOptimizedDeps = /* @__PURE__ */ new Set();
|
|
228
|
+
fetchCaches = {
|
|
229
|
+
ssr: /* @__PURE__ */ new Map(),
|
|
230
|
+
web: /* @__PURE__ */ new Map()
|
|
231
|
+
};
|
|
221
232
|
fetchCache = /* @__PURE__ */ new Map();
|
|
222
233
|
externalizeCache = /* @__PURE__ */ new Map();
|
|
223
234
|
debugger;
|
|
@@ -253,30 +264,39 @@ class ViteNodeServer {
|
|
|
253
264
|
const ssrTransformResult = (_b = this.server.moduleGraph.getModuleById(source)) == null ? void 0 : _b.ssrTransformResult;
|
|
254
265
|
return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
|
|
255
266
|
}
|
|
267
|
+
assertMode(mode) {
|
|
268
|
+
assert(mode === "web" || mode === "ssr", `"transformMode" can only be "web" or "ssr", received "${mode}".`);
|
|
269
|
+
}
|
|
256
270
|
async fetchModule(id, transformMode) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
271
|
+
const moduleId = normalizeModuleId(id);
|
|
272
|
+
const mode = transformMode || this.getTransformMode(id);
|
|
273
|
+
this.assertMode(mode);
|
|
274
|
+
const promiseMap = this.fetchPromiseMap[mode];
|
|
275
|
+
if (!promiseMap.has(moduleId)) {
|
|
276
|
+
promiseMap.set(
|
|
277
|
+
moduleId,
|
|
278
|
+
this._fetchModule(moduleId, mode).then((r) => {
|
|
262
279
|
return this.options.sourcemap !== true ? { ...r, map: void 0 } : r;
|
|
263
280
|
}).finally(() => {
|
|
264
|
-
|
|
281
|
+
promiseMap.delete(moduleId);
|
|
265
282
|
})
|
|
266
283
|
);
|
|
267
284
|
}
|
|
268
|
-
return
|
|
285
|
+
return promiseMap.get(moduleId);
|
|
269
286
|
}
|
|
270
|
-
async transformRequest(id, filepath = id) {
|
|
271
|
-
|
|
272
|
-
|
|
287
|
+
async transformRequest(id, filepath = id, transformMode) {
|
|
288
|
+
const mode = transformMode || this.getTransformMode(id);
|
|
289
|
+
this.assertMode(mode);
|
|
290
|
+
const promiseMap = this.transformPromiseMap[mode];
|
|
291
|
+
if (!promiseMap.has(id)) {
|
|
292
|
+
promiseMap.set(
|
|
273
293
|
id,
|
|
274
|
-
this._transformRequest(id, filepath).finally(() => {
|
|
275
|
-
|
|
294
|
+
this._transformRequest(id, filepath, mode).finally(() => {
|
|
295
|
+
promiseMap.delete(id);
|
|
276
296
|
})
|
|
277
297
|
);
|
|
278
298
|
}
|
|
279
|
-
return
|
|
299
|
+
return promiseMap.get(id);
|
|
280
300
|
}
|
|
281
301
|
async transformModule(id, transformMode) {
|
|
282
302
|
if (transformMode !== "web")
|
|
@@ -315,7 +335,7 @@ class ViteNodeServer {
|
|
|
315
335
|
const { path: filePath } = toFilePath(id, this.server.config.root);
|
|
316
336
|
const module = this.server.moduleGraph.getModuleById(id);
|
|
317
337
|
const timestamp = module ? module.lastHMRTimestamp : null;
|
|
318
|
-
const cache = this.
|
|
338
|
+
const cache = this.fetchCaches[transformMode].get(filePath);
|
|
319
339
|
if (timestamp && cache && cache.timestamp >= timestamp)
|
|
320
340
|
return cache.result;
|
|
321
341
|
const time = Date.now();
|
|
@@ -330,11 +350,13 @@ class ViteNodeServer {
|
|
|
330
350
|
duration = performance.now() - start;
|
|
331
351
|
result = { code: r == null ? void 0 : r.code, map: r == null ? void 0 : r.map };
|
|
332
352
|
}
|
|
333
|
-
|
|
353
|
+
const cacheEntry = {
|
|
334
354
|
duration,
|
|
335
355
|
timestamp: time,
|
|
336
356
|
result
|
|
337
|
-
}
|
|
357
|
+
};
|
|
358
|
+
this.fetchCaches[transformMode].set(filePath, cacheEntry);
|
|
359
|
+
this.fetchCache.set(filePath, cacheEntry);
|
|
338
360
|
return result;
|
|
339
361
|
}
|
|
340
362
|
async processTransformResult(filepath, result) {
|
|
@@ -344,7 +366,7 @@ class ViteNodeServer {
|
|
|
344
366
|
root: this.server.config.root
|
|
345
367
|
});
|
|
346
368
|
}
|
|
347
|
-
async _transformRequest(id, filepath,
|
|
369
|
+
async _transformRequest(id, filepath, transformMode) {
|
|
348
370
|
var _a, _b, _c, _d;
|
|
349
371
|
debugRequest(id);
|
|
350
372
|
let result = null;
|
|
@@ -353,7 +375,6 @@ class ViteNodeServer {
|
|
|
353
375
|
if (result)
|
|
354
376
|
return result;
|
|
355
377
|
}
|
|
356
|
-
const transformMode = customTransformMode ?? this.getTransformMode(id);
|
|
357
378
|
if (transformMode === "web") {
|
|
358
379
|
result = await this.server.transformRequest(id);
|
|
359
380
|
if (result)
|
package/dist/source-map.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformResult } from 'vite';
|
|
2
|
-
import { E as EncodedSourceMap } from './trace-mapping.d-
|
|
2
|
+
import { E as EncodedSourceMap } from './trace-mapping.d-cf594fd7.js';
|
|
3
3
|
|
|
4
4
|
interface InstallSourceMapSupportOptions {
|
|
5
5
|
getSourceMap: (source: string) => EncodedSourceMap | null | undefined;
|
|
@@ -51,4 +51,4 @@ declare class TraceMap implements SourceMap {
|
|
|
51
51
|
constructor(map: SourceMapInput, mapUrl?: string | null);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export { DecodedSourceMap as D, EncodedSourceMap as E, SourceMapInput as S };
|
|
54
|
+
export type { DecodedSourceMap as D, EncodedSourceMap as E, SourceMapInput as S };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-
|
|
2
|
-
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-
|
|
1
|
+
export { A as Arrayable, f as Awaitable, i as CreateHotContextFunction, D as DebuggerOptions, c as DepsHandlingOptions, g as FetchFunction, F as FetchResult, b as HotContext, j as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, h as ResolveIdFunction, S as StartOfSourceMap, d as ViteNodeResolveId, k as ViteNodeRunnerOptions, V as ViteNodeServerOptions } from './index-e4206afe.js';
|
|
2
|
+
export { D as DecodedSourceMap, E as EncodedSourceMap, S as SourceMapInput } from './trace-mapping.d-cf594fd7.js';
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as Nullable, A as Arrayable } from './index-
|
|
2
|
-
import './trace-mapping.d-
|
|
1
|
+
import { N as Nullable, A as Arrayable } from './index-e4206afe.js';
|
|
2
|
+
import './trace-mapping.d-cf594fd7.js';
|
|
3
3
|
|
|
4
4
|
declare const isWindows: boolean;
|
|
5
5
|
declare function slash(str: string): string;
|