Skip to content

[@hono/vite-dev-server]: Client-side dependencies returning 404 when using @hono/vite-dev-server with Deno. #362

@vhespanha

Description

@vhespanha

When using @hono/vite-dev-server with Deno, requests for pre-bundled client dependencies (from .vite/deps/) hit the Hono router instead of being served by Vite, resulting in 404s for all of them.

I have been able to reproduce it here: https://github.com/vhespanha/hono-vite-deno-repro. Run it and you'll see the bundled dep requests (cowsay in this case) hitting the router. This behavior is not present in Node.

I think the root cause is that .vite/deps is not present on the exclude list. But for whatever reason NodeJS doesn't care about that and works anyways.

I have been able to fix it by simply doing:

plugins: [devServer({
  entry: "./server.ts",
  exclude: [
    /^\/.vite\/.+$/,
    ...defaultOptions.exclude,
  ],
})],

But I'm also gonna be opening a PR to include the .vite/* directories to the aforementioned exclude list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions