vite-node 0.34.2 → 0.34.4
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/README.md +3 -3
- package/dist/cli.cjs +2 -2
- package/dist/cli.d.ts +1 -2
- package/dist/cli.mjs +1 -1
- package/dist/client.d.ts +1 -2
- package/dist/hmr.d.ts +4 -81
- package/dist/index.d.ts +1 -2
- package/dist/server.cjs +2 -2
- package/dist/server.d.ts +1 -2
- package/dist/server.mjs +3 -3
- package/dist/source-map.cjs +13 -8
- package/dist/source-map.mjs +13 -8
- package/dist/{types-e8623e9c.d.ts → types-0f31b933.d.ts} +123 -2
- package/dist/types.d.ts +1 -2
- package/dist/utils.cjs +9 -3
- package/dist/utils.d.ts +3 -3
- package/dist/utils.mjs +9 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ npx vite-node -h
|
|
|
40
40
|
|
|
41
41
|
### Options via CLI
|
|
42
42
|
|
|
43
|
-
[All `ViteNodeServer` options](https://github.com/vitest-dev/vitest/blob/main/packages/vite-node/src/types.ts#
|
|
43
|
+
[All `ViteNodeServer` options](https://github.com/vitest-dev/vitest/blob/main/packages/vite-node/src/types.ts#L92-L111) are supported by the CLI. They may be defined through the dot syntax, as shown below:
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
46
|
npx vite-node --options.deps.inline="module-name" --options.deps.external="/module-regexp/" index.ts
|
|
@@ -130,7 +130,7 @@ await server.close()
|
|
|
130
130
|
|
|
131
131
|
Sometimes you might want to inspect the transformed code to investigate issues. You can set environment variable `VITE_NODE_DEBUG_DUMP=true` to let vite-node write the transformed result of each module under `.vite-node/dump`.
|
|
132
132
|
|
|
133
|
-
If you want to debug by modifying the dumped code, you can change the value of `VITE_NODE_DEBUG_DUMP` to `load` and search for the
|
|
133
|
+
If you want to debug by modifying the dumped code, you can change the value of `VITE_NODE_DEBUG_DUMP` to `load` and search for the dumped files and use them for executing.
|
|
134
134
|
|
|
135
135
|
```bash
|
|
136
136
|
VITE_NODE_DEBUG_DUMP=load vite-node example.ts
|
|
@@ -151,7 +151,7 @@ const server = new ViteNodeServer(viteServer, {
|
|
|
151
151
|
|
|
152
152
|
### Debug Execution
|
|
153
153
|
|
|
154
|
-
If the process
|
|
154
|
+
If the process gets stuck, it might be because there are unresolvable circular dependencies. You can set `VITE_NODE_DEBUG_RUNNER=true` for vite-node to warn about this.
|
|
155
155
|
|
|
156
156
|
```bash
|
|
157
157
|
VITE_NODE_DEBUG_RUNNER=true vite-node example.ts
|
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 sourceMap = require('./source-map.cjs');
|
|
10
9
|
var hmr = require('./chunk-hmr.cjs');
|
|
10
|
+
var sourceMap = require('./source-map.cjs');
|
|
11
11
|
require('perf_hooks');
|
|
12
12
|
require('fs');
|
|
13
13
|
require('pathe');
|
|
@@ -25,7 +25,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
25
25
|
var cac__default = /*#__PURE__*/_interopDefaultLegacy(cac);
|
|
26
26
|
var c__default = /*#__PURE__*/_interopDefaultLegacy(c);
|
|
27
27
|
|
|
28
|
-
var version = "0.34.
|
|
28
|
+
var version = "0.34.4";
|
|
29
29
|
|
|
30
30
|
const cli = cac__default["default"]("vite-node");
|
|
31
31
|
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
package/dist/cli.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import 'node:path';
|
|
|
18
18
|
import 'node:vm';
|
|
19
19
|
import 'node:events';
|
|
20
20
|
|
|
21
|
-
var version = "0.34.
|
|
21
|
+
var version = "0.34.4";
|
|
22
22
|
|
|
23
23
|
const cli = cac("vite-node");
|
|
24
24
|
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,3 +1,2 @@
|
|
|
1
1
|
import './types.d-7442d07f.js';
|
|
2
|
-
export {
|
|
3
|
-
import 'vite/types/hot';
|
|
2
|
+
export { k as DEFAULT_REQUEST_STUBS, M as ModuleCacheMap, i as ViteNodeRunner } from './types-0f31b933.js';
|
package/dist/hmr.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import { HMRPayload
|
|
3
|
-
import { h as ViteNodeRunner, H as HotContext } from './types-
|
|
4
|
-
import 'vite/types/hot';
|
|
2
|
+
import { HMRPayload, Plugin } from 'vite';
|
|
3
|
+
import { h as CustomEventMap, i as ViteNodeRunner, j as HMRPayload$1, H as HotContext } from './types-0f31b933.js';
|
|
5
4
|
import './types.d-7442d07f.js';
|
|
6
5
|
|
|
7
6
|
type EventType = string | symbol;
|
|
@@ -13,7 +12,7 @@ interface Emitter<Events extends Record<EventType, unknown>> {
|
|
|
13
12
|
emit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;
|
|
14
13
|
}
|
|
15
14
|
type HMREmitter = Emitter<{
|
|
16
|
-
'message': HMRPayload
|
|
15
|
+
'message': HMRPayload;
|
|
17
16
|
}> & EventEmitter;
|
|
18
17
|
declare module 'vite' {
|
|
19
18
|
interface ViteDevServer {
|
|
@@ -23,82 +22,6 @@ declare module 'vite' {
|
|
|
23
22
|
declare function createHmrEmitter(): HMREmitter;
|
|
24
23
|
declare function viteNodeHmrPlugin(): Plugin;
|
|
25
24
|
|
|
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
|
-
|
|
102
25
|
type ModuleNamespace = Record<string, any> & {
|
|
103
26
|
[Symbol.toStringTag]: 'Module';
|
|
104
27
|
};
|
|
@@ -126,7 +49,7 @@ interface CacheData {
|
|
|
126
49
|
declare function getCache(runner: ViteNodeRunner): CacheData;
|
|
127
50
|
declare function sendMessageBuffer(runner: ViteNodeRunner, emitter: HMREmitter): void;
|
|
128
51
|
declare function reload(runner: ViteNodeRunner, files: string[]): Promise<any[]>;
|
|
129
|
-
declare function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], payload: HMRPayload): Promise<void>;
|
|
52
|
+
declare function handleMessage(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], payload: HMRPayload$1): Promise<void>;
|
|
130
53
|
declare function createHotContext(runner: ViteNodeRunner, emitter: HMREmitter, files: string[], ownerPath: string): HotContext;
|
|
131
54
|
|
|
132
55
|
export { Emitter, EventType, HMREmitter, Handler, HotCallback, HotModule, InferCustomEventPayload, ModuleNamespace, createHmrEmitter, createHotContext, getCache, handleMessage, reload, sendMessageBuffer, viteNodeHmrPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { A as Arrayable, a as Awaitable, C as CreateHotContextFunction, g as DebuggerOptions, D as DepsHandlingOptions, b as FetchFunction, F as FetchResult, H as HotContext, d as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, c as ResolveIdFunction, S as StartOfSourceMap, e as ViteNodeResolveId, V as ViteNodeRunnerOptions, f as ViteNodeServerOptions } from './types-
|
|
1
|
+
export { A as Arrayable, a as Awaitable, C as CreateHotContextFunction, g as DebuggerOptions, D as DepsHandlingOptions, b as FetchFunction, F as FetchResult, H as HotContext, d as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, c as ResolveIdFunction, S as StartOfSourceMap, e as ViteNodeResolveId, V as ViteNodeRunnerOptions, f as ViteNodeServerOptions } from './types-0f31b933.js';
|
|
2
2
|
export { D as DecodedSourceMap, E as EncodedSourceMap } from './types.d-7442d07f.js';
|
|
3
|
-
import 'vite/types/hot';
|
package/dist/server.cjs
CHANGED
|
@@ -249,7 +249,7 @@ class ViteNodeServer {
|
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
async resolveId(id, importer, transformMode) {
|
|
252
|
-
if (importer && !importer.startsWith(this.server.config.root))
|
|
252
|
+
if (importer && !importer.startsWith(utils.withTrailingSlash(this.server.config.root)))
|
|
253
253
|
importer = pathe.resolve(this.server.config.root, importer);
|
|
254
254
|
const mode = transformMode ?? (importer && this.getTransformMode(importer) || "ssr");
|
|
255
255
|
return this.server.pluginContainer.resolveId(id, importer, { ssr: mode === "ssr" });
|
|
@@ -313,7 +313,7 @@ class ViteNodeServer {
|
|
|
313
313
|
let result;
|
|
314
314
|
const cacheDir = (_a = this.options.deps) == null ? void 0 : _a.cacheDir;
|
|
315
315
|
if (cacheDir && id.includes(cacheDir)) {
|
|
316
|
-
if (!id.startsWith(this.server.config.root))
|
|
316
|
+
if (!id.startsWith(utils.withTrailingSlash(this.server.config.root)))
|
|
317
317
|
id = pathe.join(this.server.config.root, id);
|
|
318
318
|
const timeout = setTimeout(() => {
|
|
319
319
|
throw new Error(`ViteNodeServer: ${id} not found. This is a bug, please report it.`);
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TransformResult, ViteDevServer } from 'vite';
|
|
2
2
|
import { E as EncodedSourceMap } from './types.d-7442d07f.js';
|
|
3
|
-
import { g as DebuggerOptions, D as DepsHandlingOptions, f as ViteNodeServerOptions, F as FetchResult, e as ViteNodeResolveId } from './types-
|
|
4
|
-
import 'vite/types/hot';
|
|
3
|
+
import { g as DebuggerOptions, D as DepsHandlingOptions, f as ViteNodeServerOptions, F as FetchResult, e as ViteNodeResolveId } from './types-0f31b933.js';
|
|
5
4
|
|
|
6
5
|
declare class Debugger {
|
|
7
6
|
options: DebuggerOptions;
|
package/dist/server.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, promises } from 'node:fs';
|
|
|
3
3
|
import { join, resolve, relative, normalize } from 'pathe';
|
|
4
4
|
import createDebug from 'debug';
|
|
5
5
|
import { isValidNodeImport } from 'mlly';
|
|
6
|
-
import { isNodeBuiltin, slash, toArray, normalizeModuleId, toFilePath } from './utils.mjs';
|
|
6
|
+
import { isNodeBuiltin, slash, toArray, withTrailingSlash, normalizeModuleId, toFilePath } from './utils.mjs';
|
|
7
7
|
import { KNOWN_ASSET_TYPES } from './constants.mjs';
|
|
8
8
|
import c from 'picocolors';
|
|
9
9
|
import { withInlineSourcemap } from './source-map.mjs';
|
|
@@ -240,7 +240,7 @@ class ViteNodeServer {
|
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
async resolveId(id, importer, transformMode) {
|
|
243
|
-
if (importer && !importer.startsWith(this.server.config.root))
|
|
243
|
+
if (importer && !importer.startsWith(withTrailingSlash(this.server.config.root)))
|
|
244
244
|
importer = resolve(this.server.config.root, importer);
|
|
245
245
|
const mode = transformMode ?? (importer && this.getTransformMode(importer) || "ssr");
|
|
246
246
|
return this.server.pluginContainer.resolveId(id, importer, { ssr: mode === "ssr" });
|
|
@@ -304,7 +304,7 @@ class ViteNodeServer {
|
|
|
304
304
|
let result;
|
|
305
305
|
const cacheDir = (_a = this.options.deps) == null ? void 0 : _a.cacheDir;
|
|
306
306
|
if (cacheDir && id.includes(cacheDir)) {
|
|
307
|
-
if (!id.startsWith(this.server.config.root))
|
|
307
|
+
if (!id.startsWith(withTrailingSlash(this.server.config.root)))
|
|
308
308
|
id = join(this.server.config.root, id);
|
|
309
309
|
const timeout = setTimeout(() => {
|
|
310
310
|
throw new Error(`ViteNodeServer: ${id} not found. This is a bug, please report it.`);
|
package/dist/source-map.cjs
CHANGED
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var pathe = require('pathe');
|
|
6
|
+
var utils = require('./utils.cjs');
|
|
6
7
|
var path = require('path');
|
|
7
8
|
var fs = require('fs');
|
|
9
|
+
require('node:url');
|
|
10
|
+
require('module');
|
|
8
11
|
|
|
9
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
13
|
|
|
@@ -871,15 +874,17 @@ function withInlineSourcemap(result, options) {
|
|
|
871
874
|
let code = result.code;
|
|
872
875
|
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
|
|
873
876
|
return result;
|
|
874
|
-
|
|
875
|
-
|
|
877
|
+
if ("sources" in map) {
|
|
878
|
+
map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
|
|
879
|
+
if (!source)
|
|
880
|
+
return source;
|
|
881
|
+
if (pathe.isAbsolute(source)) {
|
|
882
|
+
const actualPath = !source.startsWith(utils.withTrailingSlash(options.root)) && source.startsWith("/") ? pathe.resolve(options.root, source.slice(1)) : source;
|
|
883
|
+
return pathe.relative(pathe.dirname(options.filepath), actualPath);
|
|
884
|
+
}
|
|
876
885
|
return source;
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
return pathe.relative(pathe.dirname(options.filepath), actualPath);
|
|
880
|
-
}
|
|
881
|
-
return source;
|
|
882
|
-
});
|
|
886
|
+
});
|
|
887
|
+
}
|
|
883
888
|
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`, "gm");
|
|
884
889
|
while (OTHER_SOURCE_MAP_REGEXP.test(code))
|
|
885
890
|
code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
|
package/dist/source-map.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { isAbsolute, resolve as resolve$2, relative, dirname } from 'pathe';
|
|
2
|
+
import { withTrailingSlash } from './utils.mjs';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import fs from 'node:fs';
|
|
5
|
+
import 'node:url';
|
|
6
|
+
import 'node:module';
|
|
4
7
|
|
|
5
8
|
const comma = ','.charCodeAt(0);
|
|
6
9
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
@@ -862,15 +865,17 @@ function withInlineSourcemap(result, options) {
|
|
|
862
865
|
let code = result.code;
|
|
863
866
|
if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
|
|
864
867
|
return result;
|
|
865
|
-
|
|
866
|
-
|
|
868
|
+
if ("sources" in map) {
|
|
869
|
+
map.sources = (_a = map.sources) == null ? void 0 : _a.map((source) => {
|
|
870
|
+
if (!source)
|
|
871
|
+
return source;
|
|
872
|
+
if (isAbsolute(source)) {
|
|
873
|
+
const actualPath = !source.startsWith(withTrailingSlash(options.root)) && source.startsWith("/") ? resolve$2(options.root, source.slice(1)) : source;
|
|
874
|
+
return relative(dirname(options.filepath), actualPath);
|
|
875
|
+
}
|
|
867
876
|
return source;
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
return relative(dirname(options.filepath), actualPath);
|
|
871
|
-
}
|
|
872
|
-
return source;
|
|
873
|
-
});
|
|
877
|
+
});
|
|
878
|
+
}
|
|
874
879
|
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`, "gm");
|
|
875
880
|
while (OTHER_SOURCE_MAP_REGEXP.test(code))
|
|
876
881
|
code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
|
|
@@ -1,6 +1,127 @@
|
|
|
1
|
-
import { ViteHotContext } from 'vite/types/hot';
|
|
2
1
|
import { E as EncodedSourceMap } from './types.d-7442d07f.js';
|
|
3
2
|
|
|
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
|
+
'vite:ws:connect': WebSocketConnectionPayload
|
|
73
|
+
'vite:ws:disconnect': WebSocketConnectionPayload
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface WebSocketConnectionPayload {
|
|
77
|
+
/**
|
|
78
|
+
* @experimental
|
|
79
|
+
* We expose this instance experimentally to see potential usage.
|
|
80
|
+
* This might be removed in the future if we didn't find reasonable use cases.
|
|
81
|
+
* If you find this useful, please open an issue with details so we can discuss and make it stable API.
|
|
82
|
+
*/
|
|
83
|
+
webSocket: WebSocket
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface InvalidatePayload {
|
|
87
|
+
path: string
|
|
88
|
+
message: string | undefined
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type InferCustomEventPayload<T extends string> =
|
|
92
|
+
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
93
|
+
|
|
94
|
+
type ModuleNamespace = Record<string, any> & {
|
|
95
|
+
[Symbol.toStringTag]: 'Module'
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
interface ViteHotContext {
|
|
99
|
+
readonly data: any
|
|
100
|
+
|
|
101
|
+
accept(): void
|
|
102
|
+
accept(cb: (mod: ModuleNamespace | undefined) => void): void
|
|
103
|
+
accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
|
|
104
|
+
accept(
|
|
105
|
+
deps: readonly string[],
|
|
106
|
+
cb: (mods: Array<ModuleNamespace | undefined>) => void,
|
|
107
|
+
): void
|
|
108
|
+
|
|
109
|
+
acceptExports(
|
|
110
|
+
exportNames: string | readonly string[],
|
|
111
|
+
cb?: (mod: ModuleNamespace | undefined) => void,
|
|
112
|
+
): void
|
|
113
|
+
|
|
114
|
+
dispose(cb: (data: any) => void): void
|
|
115
|
+
prune(cb: (data: any) => void): void
|
|
116
|
+
invalidate(message?: string): void
|
|
117
|
+
|
|
118
|
+
on<T extends string>(
|
|
119
|
+
event: T,
|
|
120
|
+
cb: (payload: InferCustomEventPayload<T>) => void,
|
|
121
|
+
): void
|
|
122
|
+
send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
|
|
123
|
+
}
|
|
124
|
+
|
|
4
125
|
declare const DEFAULT_REQUEST_STUBS: Record<string, Record<string, unknown>>;
|
|
5
126
|
declare class ModuleCacheMap extends Map<string, ModuleCache> {
|
|
6
127
|
normalizePath(fsPath: string): string;
|
|
@@ -174,4 +295,4 @@ interface DebuggerOptions {
|
|
|
174
295
|
loadDumppedModules?: boolean;
|
|
175
296
|
}
|
|
176
297
|
|
|
177
|
-
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, Awaitable as a, FetchFunction as b, ResolveIdFunction as c, ModuleCache as d, ViteNodeResolveId as e, ViteNodeServerOptions as f, DebuggerOptions as g,
|
|
298
|
+
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, Awaitable as a, FetchFunction as b, ResolveIdFunction as c, ModuleCache as d, ViteNodeResolveId as e, ViteNodeServerOptions as f, DebuggerOptions as g, CustomEventMap as h, ViteNodeRunner as i, HMRPayload as j, DEFAULT_REQUEST_STUBS as k };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { A as Arrayable, a as Awaitable, C as CreateHotContextFunction, g as DebuggerOptions, D as DepsHandlingOptions, b as FetchFunction, F as FetchResult, H as HotContext, d as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, c as ResolveIdFunction, S as StartOfSourceMap, e as ViteNodeResolveId, V as ViteNodeRunnerOptions, f as ViteNodeServerOptions } from './types-0f31b933.js';
|
|
2
2
|
export { D as DecodedSourceMap, E as EncodedSourceMap } from './types.d-7442d07f.js';
|
|
3
|
-
export { A as Arrayable, a as Awaitable, C as CreateHotContextFunction, g as DebuggerOptions, D as DepsHandlingOptions, b as FetchFunction, F as FetchResult, H as HotContext, d as ModuleCache, M as ModuleCacheMap, N as Nullable, R as RawSourceMap, c as ResolveIdFunction, S as StartOfSourceMap, e as ViteNodeResolveId, V as ViteNodeRunnerOptions, f as ViteNodeServerOptions } from './types-e8623e9c.js';
|
package/dist/utils.cjs
CHANGED
|
@@ -17,7 +17,7 @@ function slash(str) {
|
|
|
17
17
|
}
|
|
18
18
|
const VALID_ID_PREFIX = "/@id/";
|
|
19
19
|
function normalizeRequestId(id, base) {
|
|
20
|
-
if (base && id.startsWith(base))
|
|
20
|
+
if (base && id.startsWith(withTrailingSlash(base)))
|
|
21
21
|
id = `/${id.slice(base.length)}`;
|
|
22
22
|
if (driveRegexp && !(driveRegexp == null ? void 0 : driveRegexp.test(id)) && (driveOppositeRegext == null ? void 0 : driveOppositeRegext.test(id)))
|
|
23
23
|
id = id.replace(driveOppositeRegext, `${drive}$1`);
|
|
@@ -67,11 +67,11 @@ function toFilePath(id, root) {
|
|
|
67
67
|
let { absolute, exists } = (() => {
|
|
68
68
|
if (id.startsWith("/@fs/"))
|
|
69
69
|
return { absolute: id.slice(4), exists: true };
|
|
70
|
-
if (!id.startsWith(root) && id.startsWith("/")) {
|
|
70
|
+
if (!id.startsWith(withTrailingSlash(root)) && id.startsWith("/")) {
|
|
71
71
|
const resolved = pathe.resolve(root, id.slice(1));
|
|
72
72
|
if (fs.existsSync(cleanUrl(resolved)))
|
|
73
73
|
return { absolute: resolved, exists: true };
|
|
74
|
-
} else if (id.startsWith(root) && fs.existsSync(cleanUrl(id))) {
|
|
74
|
+
} else if (id.startsWith(withTrailingSlash(root)) && fs.existsSync(cleanUrl(id))) {
|
|
75
75
|
return { absolute: id, exists: true };
|
|
76
76
|
}
|
|
77
77
|
return { absolute: id, exists: false };
|
|
@@ -122,6 +122,11 @@ function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
|
122
122
|
longerDir = pathe.dirname(longerDir);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
+
function withTrailingSlash(path) {
|
|
126
|
+
if (path[path.length - 1] !== "/")
|
|
127
|
+
return `${path}/`;
|
|
128
|
+
return path;
|
|
129
|
+
}
|
|
125
130
|
function createImportMetaEnvProxy() {
|
|
126
131
|
const booleanKeys = [
|
|
127
132
|
"DEV",
|
|
@@ -164,3 +169,4 @@ exports.setCacheData = setCacheData;
|
|
|
164
169
|
exports.slash = slash;
|
|
165
170
|
exports.toArray = toArray;
|
|
166
171
|
exports.toFilePath = toFilePath;
|
|
172
|
+
exports.withTrailingSlash = withTrailingSlash;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { N as Nullable, A as Arrayable } from './types-
|
|
2
|
-
import 'vite/types/hot';
|
|
1
|
+
import { N as Nullable, A as Arrayable } from './types-0f31b933.js';
|
|
3
2
|
import './types.d-7442d07f.js';
|
|
4
3
|
|
|
5
4
|
declare const isWindows: boolean;
|
|
@@ -25,6 +24,7 @@ declare function isNodeBuiltin(id: string): boolean;
|
|
|
25
24
|
declare function toArray<T>(array?: Nullable<Arrayable<T>>): Array<T>;
|
|
26
25
|
declare function getCachedData<T>(cache: Map<string, T>, basedir: string, originalBasedir: string): NonNullable<T> | undefined;
|
|
27
26
|
declare function setCacheData<T>(cache: Map<string, T>, data: T, basedir: string, originalBasedir: string): void;
|
|
27
|
+
declare function withTrailingSlash(path: string): string;
|
|
28
28
|
declare function createImportMetaEnvProxy(): NodeJS.ProcessEnv;
|
|
29
29
|
|
|
30
|
-
export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, getCachedData, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, setCacheData, slash, toArray, toFilePath };
|
|
30
|
+
export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, getCachedData, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
|
package/dist/utils.mjs
CHANGED
|
@@ -13,7 +13,7 @@ function slash(str) {
|
|
|
13
13
|
}
|
|
14
14
|
const VALID_ID_PREFIX = "/@id/";
|
|
15
15
|
function normalizeRequestId(id, base) {
|
|
16
|
-
if (base && id.startsWith(base))
|
|
16
|
+
if (base && id.startsWith(withTrailingSlash(base)))
|
|
17
17
|
id = `/${id.slice(base.length)}`;
|
|
18
18
|
if (driveRegexp && !(driveRegexp == null ? void 0 : driveRegexp.test(id)) && (driveOppositeRegext == null ? void 0 : driveOppositeRegext.test(id)))
|
|
19
19
|
id = id.replace(driveOppositeRegext, `${drive}$1`);
|
|
@@ -63,11 +63,11 @@ function toFilePath(id, root) {
|
|
|
63
63
|
let { absolute, exists } = (() => {
|
|
64
64
|
if (id.startsWith("/@fs/"))
|
|
65
65
|
return { absolute: id.slice(4), exists: true };
|
|
66
|
-
if (!id.startsWith(root) && id.startsWith("/")) {
|
|
66
|
+
if (!id.startsWith(withTrailingSlash(root)) && id.startsWith("/")) {
|
|
67
67
|
const resolved = resolve(root, id.slice(1));
|
|
68
68
|
if (existsSync(cleanUrl(resolved)))
|
|
69
69
|
return { absolute: resolved, exists: true };
|
|
70
|
-
} else if (id.startsWith(root) && existsSync(cleanUrl(id))) {
|
|
70
|
+
} else if (id.startsWith(withTrailingSlash(root)) && existsSync(cleanUrl(id))) {
|
|
71
71
|
return { absolute: id, exists: true };
|
|
72
72
|
}
|
|
73
73
|
return { absolute: id, exists: false };
|
|
@@ -118,6 +118,11 @@ function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
|
118
118
|
longerDir = dirname(longerDir);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
+
function withTrailingSlash(path) {
|
|
122
|
+
if (path[path.length - 1] !== "/")
|
|
123
|
+
return `${path}/`;
|
|
124
|
+
return path;
|
|
125
|
+
}
|
|
121
126
|
function createImportMetaEnvProxy() {
|
|
122
127
|
const booleanKeys = [
|
|
123
128
|
"DEV",
|
|
@@ -144,4 +149,4 @@ function createImportMetaEnvProxy() {
|
|
|
144
149
|
});
|
|
145
150
|
}
|
|
146
151
|
|
|
147
|
-
export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, getCachedData, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, setCacheData, slash, toArray, toFilePath };
|
|
152
|
+
export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, getCachedData, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, setCacheData, slash, toArray, toFilePath, withTrailingSlash };
|