mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
refactor: unify bun compiled detection with windows support
- Add shared isBunCompiled() function for consistent runtime detection - Support Windows virtual filesystem paths (/~BUN/) alongside Linux/macOS (/$bunfs/) - Use Bun.main for reliable detection instead of process.argv[1] - Remove redundant $bunfs checks from cli/src/index.ts - Update cli/src/utils/bunRuntime.ts to use shared detection function - Create server/src/utils/bunCompiled.ts for server-side compilation check
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
/** Bun embeds compiled code in a virtual filesystem: /$bunfs/ (Linux/macOS) or /~BUN/ (Windows) */
|
||||
export function isBunCompiled(): boolean {
|
||||
return Bun.main.includes('$bunfs') || Bun.main.includes('/~BUN/');
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import type { Server as BunServer } from 'bun'
|
||||
import type { Server as SocketEngine } from '@socket.io/bun-engine'
|
||||
import type { WebSocketData } from '@socket.io/bun-engine'
|
||||
import { loadEmbeddedAssetMap, type EmbeddedWebAsset } from './embeddedAssets'
|
||||
import { isBunCompiled } from '../utils/bunCompiled'
|
||||
|
||||
function findWebappDistDir(): { distDir: string; indexHtmlPath: string } {
|
||||
const candidates = [
|
||||
@@ -163,7 +164,7 @@ export async function startWebServer(options: {
|
||||
jwtSecret: Uint8Array
|
||||
socketEngine: SocketEngine
|
||||
}): Promise<BunServer<WebSocketData>> {
|
||||
const isCompiled = Bun.main?.startsWith('/$bunfs') ?? false
|
||||
const isCompiled = isBunCompiled()
|
||||
const embeddedAssetMap = isCompiled ? await loadEmbeddedAssetMap() : null
|
||||
const app = createWebApp({
|
||||
getSyncEngine: options.getSyncEngine,
|
||||
|
||||
Reference in New Issue
Block a user