-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@hono/vite-dev-server] feature request: Support wrangler.toml #24
Comments
BTW not sure if you are already aware but this should now be much easier to implement as there’s a new getBindingsProxy function in Miniflare cloudflare/workers-sdk#4523 so could be a great opportunity to simplify and remove a lot of code |
Wow, I wanted this one! |
What's best way to do d1 migrations when using the vite setup? With wrangler you would do: In the binding docs it says miniflare will create db at
Is there a way to have a command like |
Ah ok, if there is no prior state, it'll create a random d1 object. But if you create
Altho it does move this initial db into a random location when you start server... so after that you either |
Hi folks, Just for clarity, you can make use of wrangler.toml configuration using the getBindingsProxy. And you can implement it like this Note: the export default defineConfig(async () => {
const { env, dispose } = await getPlatformProxy({ configPath: './wrangler.toml' })
return {
plugins: [
devServer({
plugins: [
{ onServerClose: dispose, env },
],
}),
],
}
}) |
@yusukebe Hello, I tried this but I'm getting errors around durable objects. I'm investigating now... import devServer from '@hono/vite-dev-server';
import { defineConfig } from 'vite';
import { getPlatformProxy } from 'wrangler';
export default defineConfig(async () => {
const { env, dispose } = await getPlatformProxy();
return {
plugins: [
devServer({
env,
plugins: [
{
onServerClose: dispose,
},
],
}),
],
};
}); Error:
|
If you can use Variables, KV, etc. and only Durable Objects are not working, then I think it is a Wrangler issue. I think there was a discussion about that among the Cloudflare team. I don't have time right now, so I'd appreciate it if you could look into it there. |
There are still a few issues remaining, but by including the following settings, most cases should work. import devServer from '@hono/vite-dev-server';
import { defineConfig } from 'vite';
import { getPlatformProxy } from 'wrangler';
export default defineConfig(async () => {
const { env, dispose, caches } = await getPlatformProxy();
Object.defineProperties(globalThis, {
caches: { value: caches, writable: true, configurable: true },
scheduler: { // To use scheduler.wait API
value: {
wait: () => {},
},
writable: true,
configurable: true,
},
});
return {
build: {
rollupOptions: {
external: ['__STATIC_CONTENT_MANIFEST'],
},
},
ssr: {
external: ['__STATIC_CONTENT_MANIFEST'],
},
plugins: [
devServer({
adapter: {
env,
onServerClose: dispose,
},
entry: './src/worker.ts',
}),
],
};
}); |
Are you using a serve-static from |
@yusukebe Yes, it works fine on wrangler dev |
@Code-Hex Hi, I'm looking for use |
@ducan-ne I'm sorry, I don't have the experienced. |
Thank you for developing such an incredible toolset and web framework!
I am considering switching from Wrangler to Vite + dev-Server. However, since my
wrangler.toml
file already contains numerous environment variables and bindings, I thought it would be beneficial if these could be automatically reflected in @hono/vite-dev-server.Items I would like to be automatically loaded:
Btw, Wrangler seems to be using
@iarna/toml
to read toml file.The text was updated successfully, but these errors were encountered: