Vercel Edge - Zod Openapi
Error: The Edge Function "api/index" is referencing unsupported modules: - @hono: hono/utils/url
this is what happens when i add openAPIHono to project. Does it mean swagger is not supported in edge runtime?
@draew6
We cannot know with that much information. Please share the minimal code or project to reproduce.
@yusukebe
app.ts
import { swaggerUI } from '@hono/swagger-ui'
import { OpenAPIHono} from '@hono/zod-openapi'
import { Hono } from 'hono'
const app = new OpenAPIHono()
//const app = new Hono()
app.get("/balance", async (c) => {
return c.json([])
})
app.get('/', swaggerUI({ url: '/doc'}))
export default app
api/index.ts
import { handle } from 'hono/vercel'
import app from '../app.js'
export const config = {
runtime: 'edge'
}
export default handle(app)
vercel.json
{
"rewrites": [
{
"source": "/(.*)",
"destination": "/api"
}
]
}
after trying to deploy with vercel command(CLI) its gives me
Error: The Edge Function "api/index" is referencing unsupported modules: - @hono: hono/utils/url It works with Hono instance or if I disable Edge
@draew6
Thanks. But, I can't reproduce the problem. The following project works well!
https://github.com/yusukebe/vercel-zod-openapi
@yusukebe hmm weird, i just cloned and typed "vercel"
did you use "vercel" instead of "vercel dev" ?
What else can I do to debug it?
I am on vercel hobby if it matters
@draew6
AH, sorry! I only use vercel dev, but when I use vercel command to deploy, it fails.
This is certainly an error I've never seen before and don't know how to resolve. Hmm
I am also getting the same issue here, along with the hono/jsx/jsx-runtime module.
I think the issue here is that Edge Functions (along with some other bundlers/runtimes) seem to struggle with resolving package.json#exports (at least nested modules – ie. hono/x/y).
A possible solution could be to create proxy packages (a package.json in a subdirectory that have resolvers to the dist files). Here is an example.
Hello @draew6, Did you fix the problem with @jxom 's solution? Can you share your fix ?
@jxom @kevinbalicot sorry, i am new to this. How would that look like in my example please?
I have the same error. Any updates on this?
Same problem. Any updates?