vite-node 5.3.0 → 6.0.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/README.md +3 -3
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +14 -18
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +502 -4
- package/dist/constants.mjs +33 -3
- package/dist/{dist-B2ebky9O.mjs → dist-2eHC7DTD.mjs} +26 -27
- package/dist/hmr.d.mts +1 -1
- package/dist/hmr.mjs +227 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -3
- package/dist/{server-Bk_vRgMj.mjs → server-Bdy4M7lM.mjs} +14 -18
- package/dist/server.d.mts +1 -1
- package/dist/server.mjs +4 -7
- package/dist/{source-map-CysB5F9m.mjs → source-map-BFKsz_pY.mjs} +47 -56
- package/dist/source-map.d.mts +1 -1
- package/dist/source-map.mjs +2 -4
- package/dist/{types-EZz9rsDw.d.mts → types-Bl6mw_Ii.d.mts} +64 -4
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +1 -3
- package/dist/utils.d.mts +1 -1
- package/dist/utils.mjs +188 -3
- package/package.json +17 -14
- package/dist/client-C7yCjfvf.mjs +0 -505
- package/dist/constants-DRkacFwN.mjs +0 -34
- package/dist/hmr-qEG3qSgW.mjs +0 -230
- package/dist/types-55T_-8KG.mjs +0 -1
- package/dist/utils-ExLpYVUV.mjs +0 -190
package/dist/hmr-qEG3qSgW.mjs
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { t as C } from "./dist-B2ebky9O.mjs";
|
|
2
|
-
import { f as normalizeRequestId } from "./utils-ExLpYVUV.mjs";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
import { createDebug } from "obug";
|
|
5
|
-
import { EventEmitter } from "node:events";
|
|
6
|
-
|
|
7
|
-
//#region src/hmr/emitter.ts
|
|
8
|
-
function createHmrEmitter() {
|
|
9
|
-
return new EventEmitter();
|
|
10
|
-
}
|
|
11
|
-
function viteNodeHmrPlugin() {
|
|
12
|
-
const emitter = createHmrEmitter();
|
|
13
|
-
return {
|
|
14
|
-
name: "vite-node:hmr",
|
|
15
|
-
config() {
|
|
16
|
-
if (process.platform === "darwin" && process.env.VITE_TEST_WATCHER_DEBUG) return { server: { watch: {
|
|
17
|
-
useFsEvents: false,
|
|
18
|
-
usePolling: false
|
|
19
|
-
} } };
|
|
20
|
-
},
|
|
21
|
-
configureServer(server) {
|
|
22
|
-
const _send = server.ws.send;
|
|
23
|
-
server.emitter = emitter;
|
|
24
|
-
server.ws.send = function(payload) {
|
|
25
|
-
_send(payload);
|
|
26
|
-
emitter.emit("message", payload);
|
|
27
|
-
};
|
|
28
|
-
const environments = server.environments;
|
|
29
|
-
if (environments) environments.ssr.hot.send = function(payload) {
|
|
30
|
-
_send(payload);
|
|
31
|
-
emitter.emit("message", payload);
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/hmr/hmr.ts
|
|
39
|
-
const debugHmr = createDebug("vite-node:hmr");
|
|
40
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
41
|
-
function getCache(runner) {
|
|
42
|
-
if (!cache.has(runner)) cache.set(runner, {
|
|
43
|
-
hotModulesMap: /* @__PURE__ */ new Map(),
|
|
44
|
-
dataMap: /* @__PURE__ */ new Map(),
|
|
45
|
-
disposeMap: /* @__PURE__ */ new Map(),
|
|
46
|
-
pruneMap: /* @__PURE__ */ new Map(),
|
|
47
|
-
customListenersMap: /* @__PURE__ */ new Map(),
|
|
48
|
-
ctxToListenersMap: /* @__PURE__ */ new Map(),
|
|
49
|
-
messageBuffer: [],
|
|
50
|
-
isFirstUpdate: false,
|
|
51
|
-
pending: false,
|
|
52
|
-
queued: []
|
|
53
|
-
});
|
|
54
|
-
return cache.get(runner);
|
|
55
|
-
}
|
|
56
|
-
function sendMessageBuffer(runner, emitter) {
|
|
57
|
-
const maps = getCache(runner);
|
|
58
|
-
maps.messageBuffer.forEach((msg) => emitter.emit("custom", msg));
|
|
59
|
-
maps.messageBuffer.length = 0;
|
|
60
|
-
}
|
|
61
|
-
async function reload(runner, files) {
|
|
62
|
-
Array.from(runner.moduleCache.keys()).forEach((fsPath) => {
|
|
63
|
-
if (!fsPath.includes("node_modules")) runner.moduleCache.delete(fsPath);
|
|
64
|
-
});
|
|
65
|
-
return Promise.all(files.map((file) => runner.executeId(file)));
|
|
66
|
-
}
|
|
67
|
-
async function notifyListeners(runner, event, data) {
|
|
68
|
-
const cbs = getCache(runner).customListenersMap.get(event);
|
|
69
|
-
if (cbs) await Promise.all(cbs.map((cb) => cb(data)));
|
|
70
|
-
}
|
|
71
|
-
async function queueUpdate(runner, p) {
|
|
72
|
-
const maps = getCache(runner);
|
|
73
|
-
maps.queued.push(p);
|
|
74
|
-
if (!maps.pending) {
|
|
75
|
-
maps.pending = true;
|
|
76
|
-
await Promise.resolve();
|
|
77
|
-
maps.pending = false;
|
|
78
|
-
const loading = [...maps.queued];
|
|
79
|
-
maps.queued = [];
|
|
80
|
-
(await Promise.all(loading)).forEach((fn) => fn && fn());
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async function fetchUpdate(runner, { path, acceptedPath }) {
|
|
84
|
-
path = normalizeRequestId(path);
|
|
85
|
-
acceptedPath = normalizeRequestId(acceptedPath);
|
|
86
|
-
const maps = getCache(runner);
|
|
87
|
-
const mod = maps.hotModulesMap.get(path);
|
|
88
|
-
if (!mod) return;
|
|
89
|
-
const isSelfUpdate = path === acceptedPath;
|
|
90
|
-
let fetchedModule;
|
|
91
|
-
const qualifiedCallbacks = mod.callbacks.filter(({ deps }) => deps.includes(acceptedPath));
|
|
92
|
-
if (isSelfUpdate || qualifiedCallbacks.length > 0) {
|
|
93
|
-
const disposer = maps.disposeMap.get(acceptedPath);
|
|
94
|
-
if (disposer) await disposer(maps.dataMap.get(acceptedPath));
|
|
95
|
-
try {
|
|
96
|
-
[fetchedModule] = await reload(runner, [acceptedPath]);
|
|
97
|
-
} catch (e) {
|
|
98
|
-
warnFailedFetch(e, acceptedPath);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return () => {
|
|
102
|
-
for (const { deps, fn } of qualifiedCallbacks) fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));
|
|
103
|
-
const loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;
|
|
104
|
-
console.log(`${C.cyan("[vite-node]")} hot updated: ${loggedPath}`);
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function warnFailedFetch(err, path) {
|
|
108
|
-
if (!(err instanceof Error) || !err.message.match("fetch")) console.error(err);
|
|
109
|
-
console.error(`[hmr] Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`);
|
|
110
|
-
}
|
|
111
|
-
async function handleMessage(runner, emitter, files, payload) {
|
|
112
|
-
const maps = getCache(runner);
|
|
113
|
-
switch (payload.type) {
|
|
114
|
-
case "connected":
|
|
115
|
-
sendMessageBuffer(runner, emitter);
|
|
116
|
-
break;
|
|
117
|
-
case "update":
|
|
118
|
-
await notifyListeners(runner, "vite:beforeUpdate", payload);
|
|
119
|
-
await Promise.all(payload.updates.map((update) => {
|
|
120
|
-
if (update.type === "js-update") return queueUpdate(runner, fetchUpdate(runner, update));
|
|
121
|
-
console.error(`${C.cyan("[vite-node]")} no support css hmr.}`);
|
|
122
|
-
return null;
|
|
123
|
-
}));
|
|
124
|
-
await notifyListeners(runner, "vite:afterUpdate", payload);
|
|
125
|
-
break;
|
|
126
|
-
case "full-reload":
|
|
127
|
-
await notifyListeners(runner, "vite:beforeFullReload", payload);
|
|
128
|
-
maps.customListenersMap.delete("vite:beforeFullReload");
|
|
129
|
-
await reload(runner, files);
|
|
130
|
-
break;
|
|
131
|
-
case "custom":
|
|
132
|
-
await notifyListeners(runner, payload.event, payload.data);
|
|
133
|
-
break;
|
|
134
|
-
case "prune":
|
|
135
|
-
await notifyListeners(runner, "vite:beforePrune", payload);
|
|
136
|
-
payload.paths.forEach((path) => {
|
|
137
|
-
const fn = maps.pruneMap.get(path);
|
|
138
|
-
if (fn) fn(maps.dataMap.get(path));
|
|
139
|
-
});
|
|
140
|
-
break;
|
|
141
|
-
case "error": {
|
|
142
|
-
await notifyListeners(runner, "vite:error", payload);
|
|
143
|
-
const err = payload.err;
|
|
144
|
-
console.error(`${C.cyan("[vite-node]")} Internal Server Error\n${err.message}\n${err.stack}`);
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function createHotContext(runner, emitter, files, ownerPath) {
|
|
150
|
-
debugHmr("createHotContext", ownerPath);
|
|
151
|
-
const maps = getCache(runner);
|
|
152
|
-
if (!maps.dataMap.has(ownerPath)) maps.dataMap.set(ownerPath, {});
|
|
153
|
-
const mod = maps.hotModulesMap.get(ownerPath);
|
|
154
|
-
if (mod) mod.callbacks = [];
|
|
155
|
-
const newListeners = /* @__PURE__ */ new Map();
|
|
156
|
-
maps.ctxToListenersMap.set(ownerPath, newListeners);
|
|
157
|
-
function acceptDeps(deps, callback = () => {}) {
|
|
158
|
-
const mod$1 = maps.hotModulesMap.get(ownerPath) || {
|
|
159
|
-
id: ownerPath,
|
|
160
|
-
callbacks: []
|
|
161
|
-
};
|
|
162
|
-
mod$1.callbacks.push({
|
|
163
|
-
deps,
|
|
164
|
-
fn: callback
|
|
165
|
-
});
|
|
166
|
-
maps.hotModulesMap.set(ownerPath, mod$1);
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
get data() {
|
|
170
|
-
return maps.dataMap.get(ownerPath);
|
|
171
|
-
},
|
|
172
|
-
acceptExports(_, callback) {
|
|
173
|
-
acceptDeps([ownerPath], callback && (([mod$1]) => callback(mod$1)));
|
|
174
|
-
},
|
|
175
|
-
accept(deps, callback) {
|
|
176
|
-
if (typeof deps === "function" || !deps) acceptDeps([ownerPath], ([mod$1]) => deps && deps(mod$1));
|
|
177
|
-
else if (typeof deps === "string") acceptDeps([deps], ([mod$1]) => callback && callback(mod$1));
|
|
178
|
-
else if (Array.isArray(deps)) acceptDeps(deps, callback);
|
|
179
|
-
else throw new TypeError("invalid hot.accept() usage.");
|
|
180
|
-
},
|
|
181
|
-
dispose(cb) {
|
|
182
|
-
maps.disposeMap.set(ownerPath, cb);
|
|
183
|
-
},
|
|
184
|
-
prune(cb) {
|
|
185
|
-
maps.pruneMap.set(ownerPath, cb);
|
|
186
|
-
},
|
|
187
|
-
invalidate() {
|
|
188
|
-
notifyListeners(runner, "vite:invalidate", {
|
|
189
|
-
path: ownerPath,
|
|
190
|
-
message: void 0,
|
|
191
|
-
firstInvalidatedBy: ownerPath
|
|
192
|
-
});
|
|
193
|
-
return reload(runner, files);
|
|
194
|
-
},
|
|
195
|
-
on(event, cb) {
|
|
196
|
-
const addToMap = (map) => {
|
|
197
|
-
const existing = map.get(event) || [];
|
|
198
|
-
existing.push(cb);
|
|
199
|
-
map.set(event, existing);
|
|
200
|
-
};
|
|
201
|
-
addToMap(maps.customListenersMap);
|
|
202
|
-
addToMap(newListeners);
|
|
203
|
-
},
|
|
204
|
-
off(event, cb) {
|
|
205
|
-
const removeFromMap = (map) => {
|
|
206
|
-
const existing = map.get(event);
|
|
207
|
-
if (existing === void 0) return;
|
|
208
|
-
const pruned = existing.filter((l) => l !== cb);
|
|
209
|
-
if (pruned.length === 0) {
|
|
210
|
-
map.delete(event);
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
map.set(event, pruned);
|
|
214
|
-
};
|
|
215
|
-
removeFromMap(maps.customListenersMap);
|
|
216
|
-
removeFromMap(newListeners);
|
|
217
|
-
},
|
|
218
|
-
send(event, data) {
|
|
219
|
-
maps.messageBuffer.push(JSON.stringify({
|
|
220
|
-
type: "custom",
|
|
221
|
-
event,
|
|
222
|
-
data
|
|
223
|
-
}));
|
|
224
|
-
sendMessageBuffer(runner, emitter);
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
//#endregion
|
|
230
|
-
export { sendMessageBuffer as a, reload as i, getCache as n, createHmrEmitter as o, handleMessage as r, viteNodeHmrPlugin as s, createHotContext as t };
|
package/dist/types-55T_-8KG.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/utils-ExLpYVUV.mjs
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { builtinModules } from "node:module";
|
|
2
|
-
import { existsSync, promises } from "node:fs";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
|
-
import { dirname, join, resolve } from "pathe";
|
|
6
|
-
|
|
7
|
-
//#region src/utils.ts
|
|
8
|
-
const isWindows = process.platform === "win32";
|
|
9
|
-
const drive = isWindows ? process.cwd()[0] : null;
|
|
10
|
-
const driveOpposite = drive ? drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase() : null;
|
|
11
|
-
const driveRegexp = drive ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${drive}(\:[\\/])`) : null;
|
|
12
|
-
const driveOppositeRegext = driveOpposite ? /* @__PURE__ */ new RegExp(`(?:^|/@fs/)${driveOpposite}(\:[\\/])`) : null;
|
|
13
|
-
function slash(str) {
|
|
14
|
-
return str.replace(/\\/g, "/");
|
|
15
|
-
}
|
|
16
|
-
const bareImportRE = /^(?![a-z]:)[\w@](?!.*:\/\/)/i;
|
|
17
|
-
function isBareImport(id) {
|
|
18
|
-
return bareImportRE.test(id);
|
|
19
|
-
}
|
|
20
|
-
const VALID_ID_PREFIX = "/@id/";
|
|
21
|
-
function normalizeRequestId(id, base) {
|
|
22
|
-
if (base && id.startsWith(withTrailingSlash(base))) id = `/${id.slice(base.length)}`;
|
|
23
|
-
if (driveRegexp && !driveRegexp?.test(id) && driveOppositeRegext?.test(id)) id = id.replace(driveOppositeRegext, `${drive}$1`);
|
|
24
|
-
if (id.startsWith("file://")) {
|
|
25
|
-
const { file, postfix } = splitFileAndPostfix(id);
|
|
26
|
-
return fileURLToPath(file) + postfix;
|
|
27
|
-
}
|
|
28
|
-
return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
|
|
29
|
-
}
|
|
30
|
-
const postfixRE = /[?#].*$/;
|
|
31
|
-
function cleanUrl(url) {
|
|
32
|
-
return url.replace(postfixRE, "");
|
|
33
|
-
}
|
|
34
|
-
function splitFileAndPostfix(path) {
|
|
35
|
-
const file = cleanUrl(path);
|
|
36
|
-
return {
|
|
37
|
-
file,
|
|
38
|
-
postfix: path.slice(file.length)
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const internalRequestRegexp = /* @__PURE__ */ new RegExp(`^/?(?:${["@vite/client", "@vite/env"].join("|")})$`);
|
|
42
|
-
function isInternalRequest(id) {
|
|
43
|
-
return internalRequestRegexp.test(id);
|
|
44
|
-
}
|
|
45
|
-
const prefixedBuiltins = new Set([
|
|
46
|
-
"node:sea",
|
|
47
|
-
"node:sqlite",
|
|
48
|
-
"node:test",
|
|
49
|
-
"node:test/reporters"
|
|
50
|
-
]);
|
|
51
|
-
const builtins = new Set([
|
|
52
|
-
...builtinModules,
|
|
53
|
-
"assert/strict",
|
|
54
|
-
"diagnostics_channel",
|
|
55
|
-
"dns/promises",
|
|
56
|
-
"fs/promises",
|
|
57
|
-
"path/posix",
|
|
58
|
-
"path/win32",
|
|
59
|
-
"readline/promises",
|
|
60
|
-
"stream/consumers",
|
|
61
|
-
"stream/promises",
|
|
62
|
-
"stream/web",
|
|
63
|
-
"timers/promises",
|
|
64
|
-
"util/types",
|
|
65
|
-
"wasi"
|
|
66
|
-
]);
|
|
67
|
-
function normalizeModuleId(id) {
|
|
68
|
-
if (prefixedBuiltins.has(id)) return id;
|
|
69
|
-
if (id.startsWith("file://")) return fileURLToPath(id);
|
|
70
|
-
return id.replace(/\\/g, "/").replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/");
|
|
71
|
-
}
|
|
72
|
-
function isPrimitive(v) {
|
|
73
|
-
return v !== Object(v);
|
|
74
|
-
}
|
|
75
|
-
function toFilePath(id, root) {
|
|
76
|
-
let { absolute, exists } = (() => {
|
|
77
|
-
if (id.startsWith("/@fs/")) return {
|
|
78
|
-
absolute: id.slice(4),
|
|
79
|
-
exists: true
|
|
80
|
-
};
|
|
81
|
-
if (!id.startsWith(withTrailingSlash(root)) && id.startsWith("/")) {
|
|
82
|
-
const resolved = resolve(root, id.slice(1));
|
|
83
|
-
if (existsSync(cleanUrl(resolved))) return {
|
|
84
|
-
absolute: resolved,
|
|
85
|
-
exists: true
|
|
86
|
-
};
|
|
87
|
-
} else if (id.startsWith(withTrailingSlash(root)) && existsSync(cleanUrl(id))) return {
|
|
88
|
-
absolute: id,
|
|
89
|
-
exists: true
|
|
90
|
-
};
|
|
91
|
-
return {
|
|
92
|
-
absolute: id,
|
|
93
|
-
exists: false
|
|
94
|
-
};
|
|
95
|
-
})();
|
|
96
|
-
if (absolute.startsWith("//")) absolute = absolute.slice(1);
|
|
97
|
-
return {
|
|
98
|
-
path: isWindows && absolute.startsWith("/") ? slash(fileURLToPath(pathToFileURL(absolute.slice(1)).href)) : absolute,
|
|
99
|
-
exists
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const NODE_BUILTIN_NAMESPACE = "node:";
|
|
103
|
-
function isNodeBuiltin(id) {
|
|
104
|
-
if (prefixedBuiltins.has(id)) return true;
|
|
105
|
-
return builtins.has(id.startsWith(NODE_BUILTIN_NAMESPACE) ? id.slice(5) : id);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Convert `Arrayable<T>` to `Array<T>`
|
|
109
|
-
*
|
|
110
|
-
* @category Array
|
|
111
|
-
*/
|
|
112
|
-
function toArray(array) {
|
|
113
|
-
if (array === null || array === void 0) array = [];
|
|
114
|
-
if (Array.isArray(array)) return array;
|
|
115
|
-
return [array];
|
|
116
|
-
}
|
|
117
|
-
function getCachedData(cache, basedir, originalBasedir) {
|
|
118
|
-
const pkgData = cache.get(getFnpdCacheKey(basedir));
|
|
119
|
-
if (pkgData) {
|
|
120
|
-
traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
121
|
-
cache.set(getFnpdCacheKey(dir), pkgData);
|
|
122
|
-
});
|
|
123
|
-
return pkgData;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function setCacheData(cache, data, basedir, originalBasedir) {
|
|
127
|
-
cache.set(getFnpdCacheKey(basedir), data);
|
|
128
|
-
traverseBetweenDirs(originalBasedir, basedir, (dir) => {
|
|
129
|
-
cache.set(getFnpdCacheKey(dir), data);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function getFnpdCacheKey(basedir) {
|
|
133
|
-
return `fnpd_${basedir}`;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Traverse between `longerDir` (inclusive) and `shorterDir` (exclusive) and call `cb` for each dir.
|
|
137
|
-
* @param longerDir Longer dir path, e.g. `/User/foo/bar/baz`
|
|
138
|
-
* @param shorterDir Shorter dir path, e.g. `/User/foo`
|
|
139
|
-
*/
|
|
140
|
-
function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
141
|
-
while (longerDir !== shorterDir) {
|
|
142
|
-
cb(longerDir);
|
|
143
|
-
longerDir = dirname(longerDir);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function withTrailingSlash(path) {
|
|
147
|
-
if (path[path.length - 1] !== "/") return `${path}/`;
|
|
148
|
-
return path;
|
|
149
|
-
}
|
|
150
|
-
function createImportMetaEnvProxy() {
|
|
151
|
-
const booleanKeys = [
|
|
152
|
-
"DEV",
|
|
153
|
-
"PROD",
|
|
154
|
-
"SSR"
|
|
155
|
-
];
|
|
156
|
-
return new Proxy(process.env, {
|
|
157
|
-
get(_, key) {
|
|
158
|
-
if (typeof key !== "string") return;
|
|
159
|
-
if (booleanKeys.includes(key)) return !!process.env[key];
|
|
160
|
-
return process.env[key];
|
|
161
|
-
},
|
|
162
|
-
set(_, key, value) {
|
|
163
|
-
if (typeof key !== "string") return true;
|
|
164
|
-
if (booleanKeys.includes(key)) process.env[key] = value ? "1" : "";
|
|
165
|
-
else process.env[key] = value;
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
const packageCache = /* @__PURE__ */ new Map();
|
|
171
|
-
async function findNearestPackageData(basedir) {
|
|
172
|
-
const originalBasedir = basedir;
|
|
173
|
-
while (basedir) {
|
|
174
|
-
const cached = getCachedData(packageCache, basedir, originalBasedir);
|
|
175
|
-
if (cached) return cached;
|
|
176
|
-
const pkgPath = join(basedir, "package.json");
|
|
177
|
-
if ((await promises.stat(pkgPath).catch(() => {}))?.isFile()) {
|
|
178
|
-
const pkgData = JSON.parse(await promises.readFile(pkgPath, "utf8"));
|
|
179
|
-
if (packageCache) setCacheData(packageCache, pkgData, basedir, originalBasedir);
|
|
180
|
-
return pkgData;
|
|
181
|
-
}
|
|
182
|
-
const nextBasedir = dirname(basedir);
|
|
183
|
-
if (nextBasedir === basedir) break;
|
|
184
|
-
basedir = nextBasedir;
|
|
185
|
-
}
|
|
186
|
-
return {};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
//#endregion
|
|
190
|
-
export { withTrailingSlash as _, getCachedData as a, isNodeBuiltin as c, normalizeModuleId as d, normalizeRequestId as f, toFilePath as g, toArray as h, findNearestPackageData as i, isPrimitive as l, slash as m, cleanUrl as n, isBareImport as o, setCacheData as p, createImportMetaEnvProxy as r, isInternalRequest as s, VALID_ID_PREFIX as t, isWindows as u };
|