Skip to content

Migrate to TSDown#3623

Open
frandiox wants to merge 15 commits intofd-vite-8from
fd-tsdown
Open

Migrate to TSDown#3623
frandiox wants to merge 15 commits intofd-vite-8from
fd-tsdown

Conversation

@frandiox
Copy link
Copy Markdown
Contributor

Since Vite 8 uses Rolldown I thought we could migrate the build tool also to it. TSDown is the successor of TSUp 🙃

Build time improves by ~33%

frandiox and others added 15 commits March 21, 2026 21:06
Create a fetchable mini-oxygen SSR environment using Vite 8's environment APIs and move runtime lifecycle management into a dedicated environment module.

Keep Hydrogen and CLI option passing compatible via registerPluginOptions while routing dev requests through server.environments.ssr and preserving build-time compatibility_date handling.

Update the custom workerd module runner bridge for Vite 8's invoke contract, including getBuiltins support and fetchModule options forwarding, so local SSR still runs inside MiniOxygen.

Upgrade workspace Vite dependencies to v8, switch example/template configs to native resolve.tsconfigPaths, and add the environment API refactor plan document.

Co-authored-by: Codex <codex@openai.com>
Replace mini-oxygen's custom /__vite_fetch_module bridge with a service binding that forwards Vite runner invoke payloads to the SSR environment's built-in handleInvoke() path.

This removes bespoke request parsing and builtins serialization while keeping the current fetchable SSR environment and Hydrogen/CLI runtime option flow intact.

Co-authored-by: Codex <codex@openai.com>
Drop the leftover unused Hydrogen plugin lookup in dev, and switch MiniOxygen and bundle analyzer asset emission to emitFile() so Vite 8/Rolldown no longer warns about mutating the bundle object.

Co-authored-by: OpenAI Codex <codex@openai.com>
Align CLI internal MiniOxygen typing with monorepo source types, make the bundle analyzer tolerate Vite 8 and Rolldown RenderedModule typing, and fix MiniOxygen proxy port parsing strictness.

Co-authored-by: OpenAI Codex <codex@openai.com>
Drop the leftover __VITE_ROOT runtime binding from the MiniOxygen Vite worker bridge now that the Vite 8 Environment API path no longer uses it.

Co-authored-by: OpenAI Codex <codex@openai.com>
Throw on late runtime reconfiguration, remove the refactor plan doc, and add coverage for MiniOxygen's Vite environment lifecycle.

Co-authored-by: OpenAI Codex <codex@openai.com>
- Upgrade vitest from ^1.0.4 to ^3.2.4 in packages/cli (only package still on v1, which only supports Vite ^5)
- Update build test assertions to match Vite 8 renamed log messages

Co-Authored-By: Claude <noreply@anthropic.com>
Three bugs were preventing HMR from working after the migration to
Vite's Environment API:

1. `server.watch: null` (accidentally introduced in #2722) caused Vite
   to create a NoopWatcher, so no file-change events were ever emitted.
   Removed it to restore chokidar.

2. The SSR environment was passed `transport: context.ws` (the same
   WebSocket server the browser uses). Because `isWebSocketServer` is
   true on that object, Vite used it directly as the SSR environment's
   hot channel. When the SSR module graph found no React Fast Refresh
   boundaries (SSR code has none), it sent `full-reload` over that
   shared WebSocket — hard-refreshing the browser on every file change.
   Dropping the transport gives the SSR environment a noop hot channel
   so those events are silently discarded.

3. `@vite/client` was never injected into HTML responses from workerd,
   so the browser never established a WebSocket connection to Vite's
   HMR server. React Router's <Scripts /> already injects the
   inject-hmr-runtime preamble; the only missing piece was @vite/client.
   Now injected via a simple string replace on HTML responses.

Server-side invalidation (route handlers, server.ts) is handled by a
new watcher listener in environment.ts: when a file in the SSR module
graph changes, the mini-oxygen instance is disposed so the next request
starts a fresh workerd with a clean module-runner cache.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Remove redundant MiniOxygen watcher and HTML injection cleanup while keeping the SSR environment request-driven.

Co-authored-by: Codex <codex@openai.com>
Remove the custom MiniOxygen environment marker/getter and read the entrypoint error handler from plugin state instead.

Co-authored-by: Codex <codex@openai.com>
Update MiniOxygen Vite runtime comments to reflect the current request-driven server refresh model and inspector behavior.

Co-authored-by: Codex <codex@openai.com>
Document the warmup timing and SSR environment replacement behavior in MiniOxygen's Vite environment integration.

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
@frandiox frandiox requested a review from a team as a code owner March 25, 2026 18:37
@github-actions
Copy link
Copy Markdown
Contributor

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset.
If the changes are user-facing and should cause a version bump, run pnpm run changeset add to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to examples or documentation, you do not need to add a changeset.

@shopify
Copy link
Copy Markdown
Contributor

shopify bot commented Mar 25, 2026

Oxygen deployed a preview of your fd-tsdown branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment March 25, 2026 6:37 PM

Learn more about Hydrogen's GitHub integration.

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.

1 participant