-
Notifications
You must be signed in to change notification settings - Fork 259
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
Back to Vite 🎉 #1728
Back to Vite 🎉 #1728
Conversation
* Worker entry module that wraps the user app's entry module. | ||
*/ | ||
async fetch(request: Request, env: ViteEnv, ctx: any) { | ||
env.__VITE_SETUP_ENV(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this method do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It modifies globalThis
with an utility for the Subrequest Profiler. Once Vite is stable, we can deprecate the code we have in remix-oxygen
for this and move it here.
To see more details around how this works, check wrappedBindings
in the mini-oxygen.ts
file. The setupScripts
part comes from the Hydrogen plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks good for an unstable release. Though there's probably lots of interesting scenarios to test.
Experimental Vite support! This uses the new ViteRuntime released in Vite 5.1.0-beta.6 to make Hydrogen/Remix run on workerd instead of polyfilling APIs.
I've started this as a CLI command to make things easier but we might be able to extract it later as a plugin (most of the Vite code is already separated from the CLI itself).A good chunk of this comes from sapphi-red/vite-envs, especially around WS/HMR.
GraphiQL, Subrequest Profiler, log enhancements, worker devtools, etc. are already integrated 🎉
There are a few things that are not working properly yet:
SourcemapsNeed to make a proper CLI command for vite-build.Fix CSS loading delay in devTo test this locally:
npm i
npm run build:pkg -- --force
cd examples/vite
,npm run dev
|| orLOCAL_DEV=true h2 init --template vite
to scaffold a new one.Here's a diagram showing roughly the flow: https://www.tldraw.com/v/VJ2EJE5bJwrBaPYERLjBw?viewport=-284,-93,2090,1186&page=page:U22fjHfK0cK0yNoOgsNYZ