Consider providing a v8/worker-based development runtime #105
Replies: 0 comments 4 replies
-
In another project I have similar to Hydrogen, the biggest source of problems for the users is basically differences in Node vs CFW runtime. Therefore, I agree having this runtime available locally (or somewhere fast enough) is a must for us at some point. The way I implemented this some time ago for that other project was basically with a build-watch in Vite and serving it from Miniflare. Even though it's not ideal, it is not so slow because Vite watches and rebuilds only things that change, and Miniflare can detect this and reload the server automatically. We could research how to plug Vite to Miniflare/OxygenRun more seamlessly, or build a new development server that replaces Vite. However, my gut tells me any of this would require a huge effort 😓 On the other hand, we could polyfill our current Vite/Node development environment with all the Web Standards and Worker/Oxygen APIs ( Thoughts? 🤔 About the polyfills, if |
Beta Was this translation helpful? Give feedback.
-
Right now, Hydrogen uses Vite which uses Node.js as the runtime.
It uses Node.js for a lot of reasons, but primarily:
require/import
other modules at runtime without bundlingHowever, with Oxygen being the primary target for Hydrogen deployments, and Oxygen being a worker/v8 runtime, we're asking developers to use a runtime they most likely won't be deploying to.
This could mean the developer introduces a dependency that isn't compatible with v8 isolates, or perhaps a node built-in that doesn't exist.
If we implement a way to use
oxygen-run
orminiflare
as the primary development server, it would solve this inconsistency. Cloudflare hascloudflare dev
which proxies to the edge to accomplish this same behavior, but it requires a bundle to be built each time (so it's slower).I think this would also be tricky to do considering Vite is written in Node.js. But I think others in the Vite community would find value here, and maybe it's something we can contribute upstream (like a bring-your-own-development-runtime plugin).
Pinging @frandiox for their thoughts! cc @genevieve who is leading the Oxygen runtime team and contributing to
oxygen-run
.Beta Was this translation helpful? Give feedback.
All reactions