honojs / vite-plugins

Vite Plugins for Hono
https://hono.dev
130 stars 34 forks source link

TypeError: Class extends value undefined is not a constructor or null #186

Closed axelrindle closed 1 month ago

axelrindle commented 1 month ago

Consider the following vite.config.ts:

import { defineConfig } from 'vite'
import devServer from '@hono/vite-dev-server'

const entry = 'src/index.tsx'

export default defineConfig({
    plugins: [
        devServer({
            entry,
        })
    ]
})

Running bunx vite emits the following:

failed to load config from ./vite.config.ts
error when starting dev server:
TypeError: Class extends value undefined is not a constructor or null
    at file://./node_modules/@hono/node-server/dist/index.mjs:20:15
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
    at async loadConfigFromBundledFile (file://./node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:66634:15)
    at async loadConfigFromFile (file://./node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:66475:24)
    at async resolveConfig (file://./node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:66083:24)
    at async _createServer (file://./node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:62701:18)
    at async CAC.<anonymous> (file://./node_modules/vite/dist/node/cli.js:735:20)

I use the following versions:

what version
bun 1.1.29
hono 4.6.3
@hono/vite-dev-server 0.16.0
vite 5.4.8
yusukebe commented 1 month ago

Hi @axelrindle

I can't reproduce it. If you want our help, please provide a minimal project to reproduce it.

axelrindle commented 1 month ago

I fixed it by running bunx --bun vite (forcing the bun runtime instead of Node).

I guess the error was an old Node version I have installed (16.18), but can't confirm this.

Closing this here.