Repository navigation
feat(cli): use oxc for typescript, better reloading of stacks - #1461
Merged
BlankParticle merged 9 commits intoSep 3, 2026
Merged
Conversation
Contributor
|
Install the packages built from this commit: Alchemyalchemy bun add https://pkg.ing/alchemy/89aa3cc@alchemy.run/better-auth bun add https://pkg.ing/@alchemy.run/better-auth/89aa3cc@alchemy.run/cloudflare-runtime bun add https://pkg.ing/@alchemy.run/cloudflare-runtime/89aa3cc@alchemy.run/frontend-frameworks bun add https://pkg.ing/@alchemy.run/frontend-frameworks/89aa3cc@alchemy.run/node-utils bun add https://pkg.ing/@alchemy.run/node-utils/89aa3cc@alchemy.run/pr-package bun add https://pkg.ing/@alchemy.run/pr-package/89aa3cc@alchemy.run/floci bun add https://pkg.ing/@alchemy.run/floci/89aa3ccDistilled@distilled.cloud/core bun add https://pkg.ing/@distilled.cloud/core/cb11c5b@distilled.cloud/aws bun add https://pkg.ing/@distilled.cloud/aws/cb11c5b@distilled.cloud/axiom bun add https://pkg.ing/@distilled.cloud/axiom/cb11c5b@distilled.cloud/cloudflare bun add https://pkg.ing/@distilled.cloud/cloudflare/cb11c5b@distilled.cloud/hetzner bun add https://pkg.ing/@distilled.cloud/hetzner/cb11c5b@distilled.cloud/neon bun add https://pkg.ing/@distilled.cloud/neon/cb11c5b@distilled.cloud/planetscale bun add https://pkg.ing/@distilled.cloud/planetscale/cb11c5b |
BlankParticle
force-pushed
the
t3code/node-dev-reload
branch
2 times, most recently
from
September 3, 2026 10:35
4fc2133 to
945b992
Compare
Replace the Node tsx watch process with an Oxc-backed import loader and dependency-aware chokidar watcher. Reload changed config module graphs in process on Node while retaining Bun's existing child-process behavior.
Both runtimes now reload from the exec child's own view of the stack graph instead of a native `--watch`, which hard-restarted the child with no teardown (stale widget left in scrollback) and never said why. - Log `Reloading stack: changed <files>` before every generation restart. - Node: the change listener detaches itself on delivery; `Effect.callback` only runs its cleanup on interruption, so each generation was leaving a listener behind. - Bun: `trackBunImports` records the project-local modules the stack loads through a runtime `Bun.plugin` load hook and watches them. Bun cannot evict evaluated modules, so a change tears the generation down and exits with `DEV_RELOAD_EXIT_CODE`; the `alchemy dev` supervisor respawns the child on that code while the sidecar spawner survives. - node-utils: the chokidar/debounce core moves into `DependencyWatcher`, shared by `ImportWatcher` and the new `watch-import-bun` entry.
Node's built-in TypeScript support is strip-only (no parameter properties, enums, or TSX) and Node 26 removed the `--experimental-transform-types` flag that `transformTypesFlags()` leaned on. In a checkout under Node 26 the local-provider sidecar was spawned with no flags at all, died on the first parameter property in alchemy's own source, and `alchemy dev` surfaced only "Interrupted." during "Computing plan". Every alchemy Node process now starts with alchemy's Oxc loader hooks instead, and never relies on Node's TypeScript support: - `bin/cli.js` gates Node on `module.registerHooks` (22.15+/23.5+/24+) and passes `--import` of `register-dev-mode.js` (checkout: Oxc plus src-condition resolution) or the new `register-oxc.js` (published). - `register-oxc.js` transpiles only the user's own TypeScript: alchemy and its dependencies run their built JavaScript, and anything under `node_modules` is left to Node, matching Node's own rule. - `nodeLoaderArgs(entry)` replaces `transformTypesFlags()` for the sidecar, the Vite dev/build runners, and the dev exec child. The sidecar also launches on `process.execPath` rather than PATH's `node`, so supervisor and sidecar never run different Node versions. - `registerOxc()` is idempotent for the global registration, so a process started with `--import` can call it again safely.
Resolution now matches what tsx layers over Node for a TypeScript codebase, for ESM and `require()` alike (Node's sync hooks serve both): - tsconfig `paths`/`baseUrl` aliases, discovered per importing file - `./x.js` meaning `x.ts` (source wins over an emitted sibling), plus the `.mjs`/`.cjs`/`.jsx` substitutions - extensionless specifiers and directory indexes, TypeScript first - package `exports` naming unbuilt JavaScript (checkout workspace packages) - JSON imports without an import attribute Candidates come from rolldown's `ResolverFactory` (tsconfig `auto`, `extensionAlias`, `mainFiles`); Node's resolver stays the authority and receives every candidate, so it decides formats, validates exports, and reports the canonical errors. Bare specifiers are probed without following symlinks so a linked workspace package still reads as a package and keeps going through the checkout's src-condition hook. The load hook honours Node's `module-typescript`/`commonjs-typescript` formats; a `.ts` in a CommonJS package that uses `import` runs as ESM, as Node's own syntax detection would. `.jsx` transpiles too. Source maps are switched on for the process so the inline maps reach stack traces. The register API gains `tsconfig: false`, and `tsImport()` mirrors tsx's one-shot namespaced import. The Bun tracker and the Node watcher scope the graph by real path, so symlinked roots (`/tmp` on macOS, linked checkouts) match what the runtimes report. The existing watch test no longer passes a flag Node 26 removed.
A plan whose resource references an undeployed stage reported its `InvalidReferenceError` only some of the time; otherwise dev printed a bare "Interrupted." and stopped. Same rate on main — `node --watch` just left the dead process around, so it was less visible. Two causes: - Resource diffs run concurrently and share memoized resolutions built with `Effect.cached`, which evaluates on the first caller's fiber. When that caller is cancelled, every waiter fails interrupt-only, and a fail-fast `Effect.all` lets that cancellation become the aggregate cause before the real failure arrives. - `devKeepAlive` treated an interrupt-only cause as Ctrl+C and exited. The plan now collects every diff's exit and reports real failures ahead of cancellations; the per-resource resolution memo runs in a detached fiber owned by the plan's own scope (`cachedInScope`), so a cancelled diff cannot poison it; and the keep-alive parks on internal interruptions too, printing the cause with a note that it is an engine/provider bug. Ctrl+C still tears the run down: it interrupts the fiber running the keep-alive rather than failing the effect it wraps. Verified on a stack with the failing shape against a remote state store: 5/5 runs report the error and park (2/5 died before, on main and here).
BlankParticle
force-pushed
the
t3code/node-dev-reload
branch
from
September 3, 2026 13:40
3317b7a to
132141b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace runtime-native watch supervisors with dependency-aware reloads owned by the exec child, and run Node TypeScript through Alchemy's Oxc loader instead of Node's strip-only support.
@alchemy.run/node-utils/register-oxc, with TypeScript, TSX, CommonJS, tsconfig paths, emitted-extension substitution, extensionless imports, JSON imports, and inline source maps.module.registerHooks-capable Node version.infra/andsrc/trees.tsImporthooks after both successful and failed imports.Failure handling
Plan diffs now collect their exits so a real provider or reference failure wins over sibling cancellation noise. Shared resource resolutions run in a plan-scoped detached fiber, preventing a cancelled caller from poisoning the memoized result. Dev reports internal interruption causes and waits for the next dependency change; Ctrl+C still tears down the run and prints
Exited..Stack
Depends on #1458 for the shared plan/dev terminal presentation and generation-scoped widget teardown.