Skip to content

Commit

Permalink
fix(dev-server): use ssrLoadModule instead of Runtime API (#138)
Browse files Browse the repository at this point in the history
* fix(dev-server): use `ssrLoadModule` instead of Runtime API

revert #129

* add changeset
  • Loading branch information
yusukebe authored May 10, 2024
1 parent bdc1ce7 commit 6dd041a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-chefs-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/vite-dev-server': patch
---

use `ssrLoadModule` instead of Runtime API
2 changes: 1 addition & 1 deletion packages/dev-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can develop your application with Vite. It's fast.
- Support any `fetch`-based applications.
- Hono applications run on.
- Fast by Vite.
- HMR
- HMR (Only for the client side).
- Plugins are available, e.g., Cloudflare Pages.
- Also runs on Bun.

Expand Down
4 changes: 1 addition & 3 deletions packages/dev-server/src/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export const defaultOptions: Required<Omit<DevServerOptions, 'env' | 'cf' | 'ada

export function devServer(options?: DevServerOptions): VitePlugin {
const entry = options?.entry ?? defaultOptions.entry
let runtime: ViteRuntime
const plugin: VitePlugin = {
name: '@hono/vite-dev-server',
configureServer: async (server) => {
Expand All @@ -95,11 +94,10 @@ export function devServer(options?: DevServerOptions): VitePlugin {
}
}
}
runtime ??= await createViteRuntime(server)
let appModule

try {
appModule = await runtime.executeEntrypoint(entry)
appModule = await server.ssrLoadModule(entry)
} catch (e) {
return next(e)
}
Expand Down

0 comments on commit 6dd041a

Please sign in to comment.