Make Oxygen deployment flows standalone#3819
Conversation
Allow the Oxygen Vite plugin to work without Hydrogen registering all deployment defaults. The plugin now defaults the Vite build output to dist, infers an Oxygen compatibility date from the resolved @Shopify/hydrogen package when no date is registered, and falls back to 2026-04-01 for non-calver Hydrogen versions. Keep explicit compatibility dates registered by the Hydrogen plugin authoritative, and add focused coverage for default build options, inferred oxygen.json emission, explicit-date precedence, and graceful metadata failures. Co-authored-by: Codex <codex@openai.com> Assisted-By: devx/cfcff76e-c93f-4252-a696-0009d08d7009
Add Hydrogen deploy flags for explicit client assets and worker output directories, and resolve deploy directories from flags, Vite output, then dist fallbacks. Use the package build script via node --run build for custom output deployments and 0.0.0-preview Hydrogen versions so those projects do not go through the Hydrogen runBuild hook. Keep explicit --build-command values authoritative. Co-authored-by: Codex <codex@openai.com>
Prefer Vite's environment-specific SSR and client output directories when resolving deploy output paths, then fall back to the existing server-to-client naming convention. Expand the CLI changeset to describe Vite output detection and the node --run build fallback for standalone output deployments. Co-authored-by: Codex <codex@openai.com>
Stop forcing a dist build output from the Mini Oxygen Vite plugin, while keeping compatibility-date inference self-contained. Preserve configured worker entry module IDs for SSR build fallback, including virtual and package IDs, and prepend a clearer Mini Oxygen response when Vite cannot load the configured worker entry. Co-authored-by: Codex <codex@openai.com>
Move worker-specific resolve conditions out of the top-level Vite resolver so client modules keep normal browser conditions. Keep helper error text out of the dev worker entry runtime exports so Miniflare only sees the default handler. Co-authored-by: Codex <codex@openai.com>
Regenerate the OCLIF manifest so the deploy command exposes the new assets and worker directory flags plus the updated build-command description. Co-authored-by: Codex <codex@openai.com>
Keep the missing-entry message private to the worker entry and hardcode the expected text in the test instead of adding a shared helper module. Co-authored-by: Codex <codex@openai.com>
Remove the remaining missing-entry message constant and assert the literal text directly in worker entry tests. Co-authored-by: Codex <codex@openai.com>
Prevent the Mini Oxygen Vite plugin from writing oxygen.json during client builds so the metadata only lands with the server worker output. Update tests and the changeset accordingly. Co-authored-by: Codex <codex@openai.com>
Run vite preview through Mini Oxygen by creating a preview runtime from the built worker output, with previewEntry support and default server entry discovery. Move the shared Miniflare request conversion into Vite utilities and cover the preview output resolution paths in tests. Co-authored-by: OpenAI <noreply@openai.com>
Load Vite environment variables for standalone Mini Oxygen dev and preview when no env bindings are provided by plugin options or the Hydrogen CLI. Skip the fallback when env or envPromise is registered, preserving CLI-provided bindings. Co-authored-by: OpenAI <codex@openai.com>
|
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
Co-authored-by: OpenAI <codex@openai.com>
This reverts commit ae28577.
| return `${versionMatch[1]}-${String(month).padStart(2, '0')}-01`; | ||
| } | ||
|
|
||
| export function getHydrogenCompatibilityDate(root = process.cwd()) { |
There was a problem hiding this comment.
The original idea was put the unlikely compat date breaking changes behind Hydrogen's calver releases. We could also decouple it and just update mini-oxygen package once in a while, even if it's a major bump.
Some Vite-based tools finalize build.ssr after the early config hook, so env.isSsrBuild can be false even for the eventual SSR worker build. Use the resolved Vite config when deciding whether to emit oxygen.json, while keeping the early hook behavior for the build.ssr entry fallback. Add regression coverage for SSR builds that are only visible in configResolved. Co-authored-by: OpenAI <codex@openai.com>
| }, | ||
| configResolved(resolvedConfig) { | ||
| root = resolvedConfig.root; | ||
| isSsrBuild = Boolean(resolvedConfig.build.ssr); |
There was a problem hiding this comment.
Certain tools like Vinxi doesn't get env.isSsrBuild: true because Vite resolves that too early. Getting it from the configResolved seems to work better for these tools.
fredericoo
left a comment
There was a problem hiding this comment.
hard to tophat, seems like it works. would like clearer instructions, but it looks 100% backwards compat so we are fine
You need to use the changes in this other PR. From there, it's basically testing that |
Why: custom Oxygen deployments may use the Hydrogen deploy command without installing @Shopify/hydrogen, so deployment metadata detection should not fail or resolve the CLI's own dependency by accident. Read the app-local @Shopify/hydrogen package.json directly, return undefined when it is missing or malformed, and type the package JSON read before using its version field. Co-authored-by: OpenAI <codex@openai.com>
Why: the workspace and Shopify CLI already require Node 22+, so the Hydrogen CLI package should not continue advertising Node 20 compatibility. Align the @shopify/cli-hydrogen engines field with the supported Node runtime range by requiring Node 22 or Node 24. Co-authored-by: OpenAI <codex@openai.com>
846c7e7 to
66a6a66
Compare
Why: custom Oxygen deployments should not fail when @Shopify/hydrogen metadata is unavailable, but apps that do install Hydrogen should still be read through Node package resolution instead of a hardcoded node_modules path. Keep the original require.resolve(..., {paths: [root]}) behavior, return undefined when resolution or package parsing fails, and guard the version field with the PackageJson type. Adjust the deploy test resolver so Vitest does not leak workspace Hydrogen into app-local resolution cases. Co-authored-by: OpenAI <codex@openai.com>
Summary
Validation
Testing
Check this other branch to test these changes in the skeleton template. Test also without those changes to ensure it works without breaking changes.