Skip to content

Fix Bun Elysia entry point detection - #169

Merged
alexleventer merged 6 commits into
fly-apps:mainfrom
jay23606:fix/165-elysia-entrypoint
Oct 24, 2026
Merged

alexleventer merged 6 commits into
fly-apps:mainfrom
jay23606:fix/165-elysia-entrypoint

Conversation

@jay23606

Copy link
Copy Markdown
Contributor

Fixes #165

Change

For Bun projects without a start script, select an existing module or main entry (trying its .ts path when the declared file is missing), then a file from scripts.dev without --watch, and finally src/index.ts or the existing index.ts fallback. This makes the Elysia template generate a command for its actual src/index.ts entry.

Validation

  • Regression test on the clean base failed as expected: generated bun index.ts instead of bun src/index.ts.
  • The same regression test passed on this branch; all five Bun start-command tests passed.
  • npm run eslint passed.
  • Full npm test on 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 .dockerignore template errors. No files related to those failures changed.
  • Docker image build and HTTP smoke test were not run.

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
@alexleventer
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.
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
@alexleventer
alexleventer merged commit c34c62a into fly-apps:main Oct 24, 2026
11 checks passed
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.

Elysia (Bun): the container runs bun index.ts, but the entry file is src/index.ts

2 participants