fix: Bun compatibility for build scripts and runtime detection
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// NEVER convert to top-level import - breaks browser/Vite builds (web-ui)
|
||||
let _os: typeof import("node:os") | null = null;
|
||||
if (typeof process !== "undefined" && process.versions?.node) {
|
||||
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) {
|
||||
import("node:os").then((m) => {
|
||||
_os = m;
|
||||
});
|
||||
|
||||
@@ -3,8 +3,8 @@ let _existsSync: typeof import("node:fs").existsSync | null = null;
|
||||
let _homedir: typeof import("node:os").homedir | null = null;
|
||||
let _join: typeof import("node:path").join | null = null;
|
||||
|
||||
// Eagerly load in Node.js environment only
|
||||
if (typeof process !== "undefined" && process.versions?.node) {
|
||||
// Eagerly load in Node.js/Bun environment only
|
||||
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) {
|
||||
import("node:fs").then((m) => {
|
||||
_existsSync = m.existsSync;
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// NEVER convert to top-level imports - breaks browser/Vite builds (web-ui)
|
||||
let _randomBytes: typeof import("node:crypto").randomBytes | null = null;
|
||||
let _http: typeof import("node:http") | null = null;
|
||||
if (typeof process !== "undefined" && process.versions?.node) {
|
||||
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) {
|
||||
import("node:crypto").then((m) => {
|
||||
_randomBytes = m.randomBytes;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user