Repository navigation
Conversation
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.
|
Warning Review limit reachedYou'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. View limit details
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. |
|
Updated 1:27 PM PT - Nov 8th, 2026
✅ @robobun, your commit 9dd1e11751997b357b23ee090595cdb906adbd13 passed in 🧪 To try this PR locally: bunx bun-pr 48092That installs a local version of the PR into your bun-48092 --bun |
|
Status: ready for review. Docs only, 2 lines in 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=outThe |
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`".
Problem
docs/bundler/esbuild.mdxsays "No differences" for--outfile(line 47) and forexternal(line 124). Both differ from esbuild 0.28.1.--outfile: a build without--compilefails when it also emits an asset, a CSS file, or an external source map.bun buildignores--outfilewhen--outdiris set (src/runtime/cli/Arguments.rs:2997). esbuild writes that file next to the outfile, and reportsCannot use both "outfile" and "outdir".external: Bun compares a*pattern with the import text only (src/resolver/resolver.rs:1013).--external './lib/*'bundles../lib/limported fromsrc/. esbuild keeps that import external.Fix
prettier --checkpasses.--outfilerows ran again on 1.4.3-canary after the last edit.Background
./,../or/. Bun's wildcard check has only the first step.outfilerow 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 AddoutfiletoBun.build#12629 asks for the key.Notes
Files:
index.tsimports./lib/l.nested.tsimports./src/a, andsrc/a.tsimports../lib/l.svg.tsimports./l.svg.css.tsimports./s.css.--bundle)svg.ts --outfile o/x.js(esbuild:--loader:.svg=file)cannot write multiple output files without an output directoryo/x.jsando/l-<hash>.svgcss.ts --outfile o/x.jsMultiple files share the same output patho/x.jsando/x.cssindex.ts --outfile o/x.js --sourcemap=externalcannot use an external source map without --outdiro/x.jsando/x.js.mapindex.ts --outfile x.js --outdir outout/index.js, nox.jsCannot use both "outfile" and "outdir"nested.ts --external './lib/*'lib/l.tsis bundledimport { l } from "./lib/l"staysindex.ts --external './lib/l.ts'lib/l.tsis bundledimport { l } from "./lib/l.ts"staysnested.ts --external './lib/l'import { l } from "../lib/l"stays, as writtenimport { l } from "./lib/l", relative to the output directoryBun.build({ entrypoints: ["./nested.ts"], external: ["./lib/*"] })gives the same result as the CLI row.--outfilecell began with "Writes one file." That sentence was false, and the second commit removes it.index.ts --outfile o/x.js --sourcemap=linkedexits 0 and writesx.jsandx.js.map. The bare--sourcemapdoes the same.o/. That is Directories in --outfile are ignored with --sourcemap #19729 (open PR bun build: never derive an output directory from the entry point #41879). esbuild writeso/x.jsando/x.js.map. The cell makes no statement about a linked source map.--compile, an asset is embedded and an external source map is written next to the executable (1.4.3-canary). So the first sentence of the cell says "Without--compile".--outdir outin place of--outfile(1.4.3-canary).--outfilecell stale: bun build: never derive an output directory from the entry point #41879 (an external source map with--outfile) and the pending change forbun build:--outfileis ignored when used with--outdir, should error or infer output for single entry point #21406 (--outfilewith--outdir).bun build:--outfileis ignored when used with--outdir, should error or infer output for single entry point #21406 and Bun build doesn't respect relative paths correctly #25144 (the printed path of a file external).no test proof · iteration 0 · docs-only change; test-proof not applicable