From 714951ca854e949834f9b5375342684849f5c260 Mon Sep 17 00:00:00 2001 From: Aris Riswanto <62107426+arisris@users.noreply.github.com> Date: Wed, 28 Aug 2024 20:15:45 +0700 Subject: [PATCH] feat(dev-server): Add Initial bun adapter (#166) * Initial bun adapter * format * add changeset --- .changeset/moody-trains-drive.md | 5 +++++ packages/dev-server/src/adapter/bun.ts | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 .changeset/moody-trains-drive.md create mode 100644 packages/dev-server/src/adapter/bun.ts diff --git a/.changeset/moody-trains-drive.md b/.changeset/moody-trains-drive.md new file mode 100644 index 0000000..55862b5 --- /dev/null +++ b/.changeset/moody-trains-drive.md @@ -0,0 +1,5 @@ +--- +'@hono/vite-dev-server': minor +--- + +Add Initial bun adapter diff --git a/packages/dev-server/src/adapter/bun.ts b/packages/dev-server/src/adapter/bun.ts new file mode 100644 index 0000000..d386f74 --- /dev/null +++ b/packages/dev-server/src/adapter/bun.ts @@ -0,0 +1,20 @@ +import type { Adapter } from '../types' + +export const bunAdapter = (): Adapter => { + if (typeof globalThis.navigator === 'undefined') { + // @ts-expect-error not typed well + globalThis.navigator = { + userAgent: 'Bun', + } + } else { + Object.defineProperty(globalThis.navigator, 'userAgent', { + value: 'Bun', + writable: false, + }) + } + return { + env: process.env, + } +} + +export default bunAdapter