Skip to content

Add typed JSON output to hydrogen build --watch - #4256

Merged
gonzaloriestra merged 1 commit into
gonzalo/hydrogen-json-watch-codegenfrom
gonzalo/hydrogen-json-watch-build
Oct 28, 2026
Merged

gonzaloriestra merged 1 commit into
gonzalo/hydrogen-json-watch-codegenfrom
gonzalo/hydrogen-json-watch-build

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Fixes https://github.com/shop/issues-develop/issues/24323.

Agents need structured rebuild results and errors while production build watchers keep running. build --json currently rejects --watch.

WHAT is this pull request doing?

Add typed JSONL records for watch startup, build cycles, output paths, recoverable compilation errors, and shutdown. Coordinate client and server watchers with a temporary trigger so client-only edits, including plugin-managed inputs, complete their JSON cycles. Ignore repeated trigger notifications for an already-consumed client build when reporting cycles and invoking server callbacks.

Close both Vite watchers on cancellation and clean up the client watcher and trigger if server setup fails. Keep finite JSON results and text presentation intact, refresh schema help and the manifest, and add a minor changeset.

HOW to test your changes?

In a Hydrogen 2026-04 project, run shopify hydrogen build --watch --json > /tmp/hydrogen-build.jsonl 2> /tmp/hydrogen-build.log. Change a server source file, introduce a syntax error, then fix it. Check that failures are followed by successful rebuild records with existing artifact paths. Edit a client-only entry or a file watched by a client plugin and verify another completed cycle. Press Ctrl-C and verify watch-stopped and exit 130. Compare text watch output and finite build --json; inspect build --json-schema.

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset
  • I've added tests to cover my changes
  • I've added or updated the documentation

@shopify

shopify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Oxygen deployed a preview of your gonzalo/hydrogen-json-watch-build branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment October 28, 2026 8:41 AM

Learn more about Hydrogen's GitHub integration.

@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-watch-build branch from 157138a to 6833438 Compare October 23, 2026 13:24
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-watch-build branch from 6833438 to 0d29b8e Compare October 26, 2026 12:44
@gonzaloriestra
gonzaloriestra marked this pull request as ready for review October 26, 2026 13:15
@gonzaloriestra
gonzaloriestra requested a review from a team as a code owner October 26, 2026 13:15
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-watch-build branch from 0d29b8e to bb116d2 Compare October 26, 2026 13:53
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-watch-build branch from bb116d2 to 8aeaa68 Compare October 26, 2026 14:17

@fredericoo fredericoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank u so much, this is great! gotta do a few fixes but overall it's near done! lmk when you change it so we merge it asap

Comment thread packages/cli/src/commands/hydrogen/build-watch.integration.test.ts
Comment thread packages/cli/src/commands/hydrogen/build.ts
Comment thread packages/cli/src/commands/hydrogen/build.ts
Comment thread packages/cli/src/commands/hydrogen/build-watch.test.ts
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-watch-build branch from 8aeaa68 to ddf9db1 Compare October 27, 2026 10:17
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-watch-build branch from ddf9db1 to 9560e39 Compare October 27, 2026 10:45

@fredericoo fredericoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for turning these around so quickly! the trigger dedupe and the JSON-only comment are sorted, but the cycle: 4 flake still reproduces and the slimmed-down unit test lost the normal-stop cleanup checks - details inline

Comment thread packages/cli/src/commands/hydrogen/build-watch.integration.test.ts
Comment thread packages/cli/src/commands/hydrogen/build.ts
Comment thread packages/cli/src/commands/hydrogen/build.ts
Comment thread packages/cli/src/commands/hydrogen/build-watch.test.ts
@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-watch-build branch from 9560e39 to ede9303 Compare October 27, 2026 15:23

@fredericoo fredericoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all sorted, thanks! looped the build suite 40 times (plus 20 under CPU load) with no flakes, and the new normal-stop test catches each cleanup line being removed. LGTM

one thing for a follow-up: a doubled fs event still gives JSON consumers an extra build-started/build-failed pair, so skipping client cycles with no changes would be worth doing at some point

@gonzaloriestra
gonzaloriestra force-pushed the gonzalo/hydrogen-json-watch-build branch from ede9303 to 0f5b5fc Compare October 28, 2026 08:39
@gonzaloriestra
gonzaloriestra added this pull request to the merge queue Oct 28, 2026
Merged via the queue into 2026-04 with commit c58ea05 Oct 28, 2026
26 of 38 checks passed
@gonzaloriestra
gonzaloriestra deleted the gonzalo/hydrogen-json-watch-build branch October 28, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants