diff --git a/.changeset/gorgeous-rings-sneeze.md b/.changeset/gorgeous-rings-sneeze.md new file mode 100644 index 0000000..ae61d75 --- /dev/null +++ b/.changeset/gorgeous-rings-sneeze.md @@ -0,0 +1,5 @@ +--- +'@hono/vite-dev-server': minor +--- + +Add initial nodejs adapter diff --git a/packages/dev-server/src/adapter/node.ts b/packages/dev-server/src/adapter/node.ts new file mode 100644 index 0000000..7c0932b --- /dev/null +++ b/packages/dev-server/src/adapter/node.ts @@ -0,0 +1,19 @@ +import type { Adapter } from '../types' +export const nodeAdapter = (): Adapter => { + if (typeof globalThis.navigator === 'undefined') { + // @ts-expect-error not typed well + globalThis.navigator = { + userAgent: 'Node.js', + } + } else { + Object.defineProperty(globalThis.navigator, 'userAgent', { + value: 'Node.js', + writable: false, + }) + } + return { + env: process.env, + } +} + +export default nodeAdapter