Repository navigation
Fix Bun Elysia entry point detection - #169
Merged
Merged
Conversation
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
alexleventer
self-requested a review
October 22, 2026 23:41
Only fall back to the dev script and src/index.ts for Bun apps that declare no usable entry. A declared main/module that doesn't exist yet is kept as is, since it is likely build output, and SvelteKit keeps ./build/index.js.
An existing index.ts is what Bun apps without main or type: module have always run, so keep it. Only consider a module entry that exists, and only dev script arguments that are script files, so asset paths, directories and unset $VARs aren't picked as the entry.
alexleventer
approved these changes
Oct 24, 2026
Restore the main and type: module branches exactly, so a compiled main (e.g. index.js from tsc) is still run. Detection now only replaces the old bun index.ts fallback: an existing index.ts still wins, then an existing module (also .tsx/.mts), src/index.ts, the file run by the last bun command in the dev script, and a not yet built module.
For monorepo layouts like "cd apps/api && bun --watch src/index.ts", run the entry with bun --cwd so the app starts in the same directory as in development. Directories outside the app are ignored.
- the first file after bun is the entry; later arguments are its argv, and values of flags like --preload are skipped - cd doesn't carry out of subshells, background jobs or pipelines; bare cd, ./ and trailing slashes are handled - paths in the generated CMD always use forward slashes - a missing main or module foo.js points at its TypeScript source, as Bun 1.2+ resolves it but older versions don't, unless a build, prepare or postinstall script could produce it
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.
Fixes #165
Change
For Bun projects without a
startscript, select an existingmoduleormainentry (trying its.tspath when the declared file is missing), then a file fromscripts.devwithout--watch, and finallysrc/index.tsor the existingindex.tsfallback. This makes the Elysia template generate a command for its actualsrc/index.tsentry.Validation
bun index.tsinstead ofbun src/index.ts.npm run eslintpassed.npm teston this branch: 318 passing, 10 pending, 48 failing. The clean-base run also failed under the same WSL-mounted Windows checkout with unrelated CRLF-sensitive snapshots and.dockerignoretemplate errors. No files related to those failures changed.🤖 Generated with Claude Code