fix: fall back to node when bun and tsx are not installed#3130
Open
jlaustill wants to merge 4 commits into
Open
fix: fall back to node when bun and tsx are not installed#3130jlaustill wants to merge 4 commits into
jlaustill wants to merge 4 commits into
Conversation
Three related changes to make the CLI work in Node-only environments: 1. entrypoint.js: runner selection was `bun || tsx` with no further fallback. Any system without both bun and tsx would fail at spawn. Now: `bun || tsx || process.execPath` (the current node binary). 2. cli/build/worker-pool.ts: import.meta.dir is a Bun-only property. Replace with a cross-runtime shim that prefers import.meta.dir (Bun), then import.meta.dirname (Node >=21.2), then dirname(fileURLToPath(…)). 3. cli/snapshot/worker-pool.ts: same import.meta.dir fix as above. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- worker-pool.ts (build + snapshot): fix broken __metaDirname reference caused by replace_all matching import.meta.dir inside import.meta.dirname; use proper ImportMetaWithDir cast covering both .dir (Bun) and .dirname (Node >=21.2); move all imports above the shim const; run biome format - entrypoint.js: apply biome format (semicolons + indentation) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous commit applied biome from a mismatched npm-installed version, producing tabs + semicolons. Restore both worker-pool files from upstream and apply only the minimal patch needed: add dirname/fileURLToPath imports and the __metaDir shim in the original project style (2-space indent, no semicolons), then replace all import.meta.dir usages with __metaDir. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ners) entrypoint.js: restore from upstream and apply only the runner change in the original style — 2-space indent, no semicolons, ternary broken to match biome 1.9.3 line-length rules. snapshot/worker-pool.ts: consolidate the jsBundledPath.join() call to one line — __metaDir is shorter than import.meta.dir so the line now fits within 80 chars and biome collapses it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Problem
Three separate issues cause
tsci dev(andbuild/snapshot) to fail hard on Node-only systems:1.
cli/entrypoint.js— no fallback beyondtsxIf neither
bunnortsxis installed the spawned process fails.tsxisn't a guaranteed dependency on every dev machine, and it shouldn't be a hard requirement just to run compiled JS.2 & 3.
cli/build/worker-pool.tsandcli/snapshot/worker-pool.ts—import.meta.diris Bun-onlyimport.meta.diris a Bun extension; it isundefinedin Node, causingpath.jointo throw once the worker entrypoint path is resolved.Fix
entrypoint.js: chain a finalprocess.execPathfallback so the current Node binary is always available:worker-pool.ts(both): add a one-time cross-runtime__metaDirshim at the top of each file, then replace allimport.meta.dirusages:Tested
Verified
tsci devstarts and serves the preview on a system with Node 24 and no Bun installed.🤖 Generated with Claude Code