Currently running same code in nodejs works while it throws error in bun. If we check for the runtime, the problem goes away.
Example working code:
if(!process.versions.bun){
// allows to run same elysia on bun and nodejs
// otherwise bun throws readonly error
// 78 | globalThis.Bun = ElysiaBun;
// TypeError: Attempted to assign to readonly property.
await import('@bogeychan/elysia-polyfills/node/index.js');
}
import { Elysia } from 'elysia';
const app = new Elysia().get('/', () => ({ hello: 'Node.js👋' })).listen(8080);
console.log(`Listening on http://localhost:${app.server!.port}`);
It would be awesome if the check was done inside the codebase directly so the polyfill does not trigger in the bun runtime.
Currently running same code in nodejs works while it throws error in bun. If we check for the runtime, the problem goes away.
Example working code:
It would be awesome if the check was done inside the codebase directly so the polyfill does not trigger in the bun runtime.