Skip to content

docs: list the --outfile and external differences from esbuild - #48092

Open
robobun wants to merge 2 commits into
mainfrom
robobun/f8cc2bea/esbuild-page-outfile-external-rows
Open

robobun wants to merge 2 commits into
mainfrom
robobun/f8cc2bea/esbuild-page-outfile-external-rows

Conversation

@robobun

@robobun robobun commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • docs/bundler/esbuild.mdx says "No differences" for --outfile (line 47) and for external (line 124). Both differ from esbuild 0.28.1.
  • --outfile: a build without --compile fails when it also emits an asset, a CSS file, or an external source map. bun build ignores --outfile when --outdir is set (src/runtime/cli/Arguments.rs:2997). esbuild writes that file next to the outfile, and reports Cannot use both "outfile" and "outdir".
  • external: Bun compares a * pattern with the import text only (src/resolver/resolver.rs:1013). --external './lib/*' bundles ../lib/l imported from src/. esbuild keeps that import external.

Fix

  • Replace the two cells with the differences. No other row changes.
  • Each cell keeps the column width, so the diff is 2 lines and prettier --check passes.
  • Verified: the rows in Notes on a debug build of main (7ca0042) and on esbuild 0.28.1. The --outfile rows ran again on 1.4.3-canary after the last edit.

Background

  • The page is the migration guide from esbuild. "No differences" tells the reader that a flag needs no change.
  • esbuild checks an external two times. The first check uses the import text. The second check uses the file path, for an entry that starts with ./, ../ or /. Bun's wildcard check has only the first step.
  • The outfile row of the JavaScript API table (line 155) is not in this PR. docs: fix examples that do not run or type-check as written #41734 changes that row, and Add outfile to Bun.build #12629 asks for the key.
Notes

Files: index.ts imports ./lib/l. nested.ts imports ./src/a, and src/a.ts imports ../lib/l. svg.ts imports ./l.svg. css.ts imports ./s.css.

Command bun (main 7ca0042) esbuild 0.28.1 (--bundle)
svg.ts --outfile o/x.js (esbuild: --loader:.svg=file) exit 1, cannot write multiple output files without an output directory writes o/x.js and o/l-<hash>.svg
css.ts --outfile o/x.js exit 1, Multiple files share the same output path writes o/x.js and o/x.css
index.ts --outfile o/x.js --sourcemap=external exit 1, cannot use an external source map without --outdir writes o/x.js and o/x.js.map
index.ts --outfile x.js --outdir out exit 0, writes out/index.js, no x.js exit 1, Cannot use both "outfile" and "outdir"
nested.ts --external './lib/*' lib/l.ts is bundled import { l } from "./lib/l" stays
index.ts --external './lib/l.ts' lib/l.ts is bundled import { l } from "./lib/l.ts" stays
nested.ts --external './lib/l' import { l } from "../lib/l" stays, as written import { l } from "./lib/l", relative to the output directory

no test proof · iteration 0 · docs-only change; test-proof not applicable

The esbuild migration page said "No differences" for both rows.

`bun build --outfile` writes exactly one file. A build that also emits
an asset, a CSS file or an external source map fails, and `--outfile`
is ignored when `--outdir` is set. esbuild writes the second file next
to the outfile and rejects the two flags together.

`external` matches a `*` pattern against the import path as written,
compares a file path before the import is resolved to a file, and
keeps a matched import path as written. esbuild also matches by file
path and rewrites such an import relative to the output directory.
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 33 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7ca0042 and 9dd1e11.

Files selected for processing: 1

  • docs/bundler/esbuild.mdx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@robobun

robobun commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 1:27 PM PT - Nov 8th, 2026

✅ @robobun, your commit 9dd1e11751997b357b23ee090595cdb906adbd13 passed in Build #138958! 🎉


🧪   To try this PR locally:

bunx bun-pr 48092

That installs a local version of the PR into your bun-48092 executable, so you can run:

bun-48092 --bun

@robobun

robobun commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator Author

Status: ready for review. Docs only, 2 lines in docs/bundler/esbuild.mdx.

How to reproduce the two differences (bun at main 7ca0042, esbuild 0.28.1):

mkdir -p lib src
echo 'export const l = 1;' > lib/l.ts
echo 'import { l } from "../lib/l"; export const a = l + 1;' > src/a.ts
echo 'import { a } from "./src/a"; console.log(a);' > nested.ts

# external: bun bundles lib/l.ts, esbuild keeps the import
bun build ./nested.ts --external './lib/*'
esbuild ./nested.ts --bundle --format=esm '--external:./lib/*'

# --outfile with --outdir: bun writes out/nested.js and no x.js, esbuild exits 1
bun build ./nested.ts --outfile x.js --outdir out
esbuild ./nested.ts --bundle --outfile=x.js --outdir=out

The outfile row of the JavaScript API table is not in this PR. #41734 changes that row, and #12629 asks for the key.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

The sentence was false. `bun build ./index.ts --outfile o/x.js
--sourcemap=linked` exits 0 and writes the bundle and its map, so the
build writes two files.

The row now names only the cases that fail without `--outdir`: an
asset, a CSS file, or an external source map. With `--compile` those
builds succeed, so the sentence says "Without `--compile`".

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

@robobun
robobun requested a review from Jarred-Sumner November 8, 2026 21:34

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants