vite-node 0.34.1 → 0.34.3
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 +1 -2
- package/dist/cli.mjs +1 -1
- package/dist/client.cjs +2 -1
- package/dist/client.d.ts +1 -2
- package/dist/client.mjs +3 -2
- package/dist/hmr.d.ts +4 -81
- package/dist/index.d.ts +1 -2
- package/dist/server.cjs +10 -0
- package/dist/server.d.ts +4 -2
- package/dist/server.mjs +10 -0
- package/dist/{types-e8623e9c.d.ts → types-2dc895bd.d.ts} +111 -2
- package/dist/types.d.ts +1 -2
- package/dist/utils.cjs +26 -0
- package/dist/utils.d.ts +3 -3
- package/dist/utils.mjs +26 -1
- package/package.json +1 -1
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');
|
|
@@ -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.3";
|
|
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.3";
|
|
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.cjs
CHANGED
|
@@ -63,6 +63,7 @@ const clientStub = {
|
|
|
63
63
|
removeStyle: () => {
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
+
const env = utils.createImportMetaEnvProxy();
|
|
66
67
|
const DEFAULT_REQUEST_STUBS = {
|
|
67
68
|
"/@vite/client": clientStub,
|
|
68
69
|
"@vite/client": clientStub
|
|
@@ -275,7 +276,7 @@ ${getStack()}`), 2e3);
|
|
|
275
276
|
const { Object: Object2, Reflect: Reflect2, Symbol: Symbol2 } = this.getContextPrimitives();
|
|
276
277
|
const modulePath = utils.cleanUrl(moduleId);
|
|
277
278
|
const href = node_url.pathToFileURL(modulePath).href;
|
|
278
|
-
const meta = { url: href };
|
|
279
|
+
const meta = { url: href, env };
|
|
279
280
|
const exports = Object2.create(null);
|
|
280
281
|
Object2.defineProperty(exports, Symbol2.toStringTag, {
|
|
281
282
|
value: "Module",
|
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-2dc895bd.js';
|
package/dist/client.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
|
4
4
|
import vm from 'node:vm';
|
|
5
5
|
import { resolve } from 'pathe';
|
|
6
6
|
import createDebug from 'debug';
|
|
7
|
-
import { normalizeModuleId, slash, isInternalRequest, isNodeBuiltin, VALID_ID_PREFIX, normalizeRequestId, toFilePath, cleanUrl, isPrimitive } from './utils.mjs';
|
|
7
|
+
import { createImportMetaEnvProxy, normalizeModuleId, slash, isInternalRequest, isNodeBuiltin, VALID_ID_PREFIX, normalizeRequestId, toFilePath, cleanUrl, isPrimitive } from './utils.mjs';
|
|
8
8
|
import { extractSourceMap } from './source-map.mjs';
|
|
9
9
|
import 'node:fs';
|
|
10
10
|
|
|
@@ -36,6 +36,7 @@ const clientStub = {
|
|
|
36
36
|
removeStyle: () => {
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
+
const env = createImportMetaEnvProxy();
|
|
39
40
|
const DEFAULT_REQUEST_STUBS = {
|
|
40
41
|
"/@vite/client": clientStub,
|
|
41
42
|
"@vite/client": clientStub
|
|
@@ -248,7 +249,7 @@ ${getStack()}`), 2e3);
|
|
|
248
249
|
const { Object: Object2, Reflect: Reflect2, Symbol: Symbol2 } = this.getContextPrimitives();
|
|
249
250
|
const modulePath = cleanUrl(moduleId);
|
|
250
251
|
const href = pathToFileURL(modulePath).href;
|
|
251
|
-
const meta = { url: href };
|
|
252
|
+
const meta = { url: href, env };
|
|
252
253
|
const exports = Object2.create(null);
|
|
253
254
|
Object2.defineProperty(exports, Symbol2.toStringTag, {
|
|
254
255
|
value: "Module",
|
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-2dc895bd.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-2dc895bd.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
|
@@ -287,6 +287,16 @@ class ViteNodeServer {
|
|
|
287
287
|
}
|
|
288
288
|
return this.transformPromiseMap.get(id);
|
|
289
289
|
}
|
|
290
|
+
async transformModule(id, transformMode) {
|
|
291
|
+
if (transformMode !== "web")
|
|
292
|
+
throw new Error('`transformModule` only supports `transformMode: "web"`.');
|
|
293
|
+
const normalizedId = utils.normalizeModuleId(id);
|
|
294
|
+
const mod = this.server.moduleGraph.getModuleById(normalizedId);
|
|
295
|
+
const result = (mod == null ? void 0 : mod.transformResult) || await this.server.transformRequest(normalizedId);
|
|
296
|
+
return {
|
|
297
|
+
code: result == null ? void 0 : result.code
|
|
298
|
+
};
|
|
299
|
+
}
|
|
290
300
|
getTransformMode(id) {
|
|
291
301
|
var _a, _b, _c, _d;
|
|
292
302
|
const withoutQuery = id.split("?")[0];
|
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-2dc895bd.js';
|
|
5
4
|
|
|
6
5
|
declare class Debugger {
|
|
7
6
|
options: DebuggerOptions;
|
|
@@ -40,6 +39,9 @@ declare class ViteNodeServer {
|
|
|
40
39
|
getSourceMap(source: string): EncodedSourceMap | null;
|
|
41
40
|
fetchModule(id: string, transformMode?: 'web' | 'ssr'): Promise<FetchResult>;
|
|
42
41
|
transformRequest(id: string, filepath?: string): Promise<TransformResult | null | undefined>;
|
|
42
|
+
transformModule(id: string, transformMode?: 'web' | 'ssr'): Promise<{
|
|
43
|
+
code: string | undefined;
|
|
44
|
+
}>;
|
|
43
45
|
getTransformMode(id: string): "web" | "ssr";
|
|
44
46
|
private _fetchModule;
|
|
45
47
|
protected processTransformResult(filepath: string, result: TransformResult): Promise<TransformResult>;
|
package/dist/server.mjs
CHANGED
|
@@ -278,6 +278,16 @@ class ViteNodeServer {
|
|
|
278
278
|
}
|
|
279
279
|
return this.transformPromiseMap.get(id);
|
|
280
280
|
}
|
|
281
|
+
async transformModule(id, transformMode) {
|
|
282
|
+
if (transformMode !== "web")
|
|
283
|
+
throw new Error('`transformModule` only supports `transformMode: "web"`.');
|
|
284
|
+
const normalizedId = normalizeModuleId(id);
|
|
285
|
+
const mod = this.server.moduleGraph.getModuleById(normalizedId);
|
|
286
|
+
const result = (mod == null ? void 0 : mod.transformResult) || await this.server.transformRequest(normalizedId);
|
|
287
|
+
return {
|
|
288
|
+
code: result == null ? void 0 : result.code
|
|
289
|
+
};
|
|
290
|
+
}
|
|
281
291
|
getTransformMode(id) {
|
|
282
292
|
var _a, _b, _c, _d;
|
|
283
293
|
const withoutQuery = id.split("?")[0];
|
|
@@ -1,6 +1,115 @@
|
|
|
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
|
+
}
|
|
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
|
+
|
|
4
113
|
declare const DEFAULT_REQUEST_STUBS: Record<string, Record<string, unknown>>;
|
|
5
114
|
declare class ModuleCacheMap extends Map<string, ModuleCache> {
|
|
6
115
|
normalizePath(fsPath: string): string;
|
|
@@ -174,4 +283,4 @@ interface DebuggerOptions {
|
|
|
174
283
|
loadDumppedModules?: boolean;
|
|
175
284
|
}
|
|
176
285
|
|
|
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,
|
|
286
|
+
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-2dc895bd.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
|
@@ -122,9 +122,35 @@ function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
|
122
122
|
longerDir = pathe.dirname(longerDir);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
+
function createImportMetaEnvProxy() {
|
|
126
|
+
const booleanKeys = [
|
|
127
|
+
"DEV",
|
|
128
|
+
"PROD",
|
|
129
|
+
"SSR"
|
|
130
|
+
];
|
|
131
|
+
return new Proxy(process.env, {
|
|
132
|
+
get(_, key) {
|
|
133
|
+
if (typeof key !== "string")
|
|
134
|
+
return void 0;
|
|
135
|
+
if (booleanKeys.includes(key))
|
|
136
|
+
return !!process.env[key];
|
|
137
|
+
return process.env[key];
|
|
138
|
+
},
|
|
139
|
+
set(_, key, value) {
|
|
140
|
+
if (typeof key !== "string")
|
|
141
|
+
return true;
|
|
142
|
+
if (booleanKeys.includes(key))
|
|
143
|
+
process.env[key] = value ? "1" : "";
|
|
144
|
+
else
|
|
145
|
+
process.env[key] = value;
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
125
150
|
|
|
126
151
|
exports.VALID_ID_PREFIX = VALID_ID_PREFIX;
|
|
127
152
|
exports.cleanUrl = cleanUrl;
|
|
153
|
+
exports.createImportMetaEnvProxy = createImportMetaEnvProxy;
|
|
128
154
|
exports.getCachedData = getCachedData;
|
|
129
155
|
exports.hashRE = hashRE;
|
|
130
156
|
exports.isInternalRequest = isInternalRequest;
|
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-2dc895bd.js';
|
|
3
2
|
import './types.d-7442d07f.js';
|
|
4
3
|
|
|
5
4
|
declare const isWindows: boolean;
|
|
@@ -25,5 +24,6 @@ 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 createImportMetaEnvProxy(): NodeJS.ProcessEnv;
|
|
28
28
|
|
|
29
|
-
export { VALID_ID_PREFIX, cleanUrl, getCachedData, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, setCacheData, slash, toArray, toFilePath };
|
|
29
|
+
export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, getCachedData, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, setCacheData, slash, toArray, toFilePath };
|
package/dist/utils.mjs
CHANGED
|
@@ -118,5 +118,30 @@ function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
|
118
118
|
longerDir = dirname(longerDir);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
+
function createImportMetaEnvProxy() {
|
|
122
|
+
const booleanKeys = [
|
|
123
|
+
"DEV",
|
|
124
|
+
"PROD",
|
|
125
|
+
"SSR"
|
|
126
|
+
];
|
|
127
|
+
return new Proxy(process.env, {
|
|
128
|
+
get(_, key) {
|
|
129
|
+
if (typeof key !== "string")
|
|
130
|
+
return void 0;
|
|
131
|
+
if (booleanKeys.includes(key))
|
|
132
|
+
return !!process.env[key];
|
|
133
|
+
return process.env[key];
|
|
134
|
+
},
|
|
135
|
+
set(_, key, value) {
|
|
136
|
+
if (typeof key !== "string")
|
|
137
|
+
return true;
|
|
138
|
+
if (booleanKeys.includes(key))
|
|
139
|
+
process.env[key] = value ? "1" : "";
|
|
140
|
+
else
|
|
141
|
+
process.env[key] = value;
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
121
146
|
|
|
122
|
-
export { VALID_ID_PREFIX, cleanUrl, getCachedData, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, setCacheData, slash, toArray, toFilePath };
|
|
147
|
+
export { VALID_ID_PREFIX, cleanUrl, createImportMetaEnvProxy, getCachedData, hashRE, isInternalRequest, isNodeBuiltin, isPrimitive, isWindows, normalizeModuleId, normalizeRequestId, queryRE, setCacheData, slash, toArray, toFilePath };
|