hydrogen
hydrogen copied to clipboard
Build watch
This is a prerequisite for supporting h2 debug cpu
in Vite. Features:
- Add
--watch
toh2 build
- Add
--build --watch --codegen
toh2 preview
- Support
--diff
inh2 preview
Note
Miniflare is currently not compatible with CSP nonces and WS connections. Therefore, live reload doesn't work with h2 preview --build --watch
until that's fixed and you need to refresh the browser manually.
I've reported the problem here: https://github.com/cloudflare/workers-sdk/issues/5829
Oxygen deployed a preview of your fd-build-watch
branch. Details:
Storefront | Status | Preview link | Deployment details | Last update (UTC) |
---|---|---|---|---|
third-party-queries-caching | ✅ Successful (Logs) | Preview deployment | Inspect deployment | May 23, 2024 6:14 AM |
subscriptions | ✅ Successful (Logs) | Preview deployment | Inspect deployment | May 23, 2024 6:13 AM |
custom-cart-method | ✅ Successful (Logs) | Preview deployment | Inspect deployment | May 23, 2024 6:13 AM |
vite | ✅ Successful (Logs) | Preview deployment | Inspect deployment | May 23, 2024 6:13 AM |
Skeleton (skeleton.hydrogen.shop) | ✅ Successful (Logs) | Preview deployment | Inspect deployment | May 23, 2024 6:13 AM |
optimistic-cart-ui | ✅ Successful (Logs) | Preview deployment | Inspect deployment | May 23, 2024 6:13 AM |
Learn more about Hydrogen's GitHub integration.
Testing notes:
✅ - skeleton template - h2 build --watch
- successfully rebuilds as I modify files (everything I tried except the vite config, which I don't think matters)
✅ - skeleton template - h2 preview --build
❌ - skeleton template - h2 preview
failed
✅ - skeleton template -
h2 preview --build --watch --codegen
- Modifying files rebuilds, and also changing queries updates the codegen
❌ - infinite-scroll example - h2 build --watch --diff
- It built successfully, just watch didn't rebuild when I modified the collection route.
❌ - infinite-scroll example - h2 preview --diff
- Fails with a similar error as above. Does preview
now require a --build
arg?
❌ - infinite-scroll example - h2 preview --build --watch --codegen --diff
- built successfully, but also does not rebuild when I modify the route (or the query, codegen doesn't rerun).
@blittle Thanks for the thorough review! Most problem were due to a bad last minute copy-paste 🤦
❌ - skeleton template - h2 preview failed
diff
had default: false
so Oclif thinks the flag is provided... and it then triggered the requirement on build
. I've removed all the default: false
values to make them undefined
instead, which doesn't create this problem.
❌ - infinite-scroll example - h2 build --watch --diff - It built successfully, just watch didn't rebuild when I modified the collection route.
Copy-pasted code and forgot to enable the watcher for the diff folder 🙃
❌ - infinite-scroll example - h2 preview --diff - Fails with a similar error as above. Does preview now require a --build arg?
Yes, it does. I've added a comment in the code to explain this because I even forgot about it myself when you mentioned it:
// Diff in preview only makes sense when combined with --build.
// Without the build flag, preview only needs access to the existing
// `dist` directory in the project, so there's no need to merge the
// project with the skeleton template in a temporary directory.
❌ - infinite-scroll example - h2 preview --build --watch --codegen --diff - built successfully, but also does not rebuild when I modify the route (or the query, codegen doesn't rerun).
Same thing, forgot to enable the watcher. Note that codegen reruns but we are ignoring the changes in Git.
I think this is all now fixed in the recent commints 👍
I can only repro this issue 50% of the time or so, but when running h2 build --watch --diff
inside infinite-scroll
example. I modify a file, it rebuilds, and then I try and kill the process (ctr + c) but the process doesn't die. It just infinitely keeps printing this error:
I have to kill the whole terminal to get it to stop.
I can only repro this issue 50% of the time or so, but when running h2 build --watch --diff inside infinite-scroll example. I modify a file, it rebuilds, and then I try and kill the process (ctr + c) but the process doesn't die. It just infinitely keeps printing this error:
@blittle I was only able to reproduce this very few times. It looks like even when we close Rollup watchers, the build still continues and then it starts failing synchronously when it can't find the diff files that we just removed on process exit.
I've added a few changes to try to ensure the build exits before we remove files so that we don't go into an infinite sync error loop. I'm not able to reproduce it after these changes but maybe I was just lucky. Please try it again but, in any case, these errors only happens with --diff
so it's probably not a big issue.