Skip to content

Bun.build() tsconfig option doesn't resolve path aliases (CLI works) #26793

Closed

Description

@arshad-yaseen

What version of Bun is running?

1.3.8+b64edcb49

What platform is your computer?

Darwin 24.6.0 arm64 arm

What steps can reproduce the bug?

Create these files first:

// src/index.ts
import { sum } from "@/utils";

export { sum }
// src/utils.ts
export function sum() {}
// tsconfig.custom.json
// note: this is a custom tsconfig file
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}
// build.ts
await Bun.build({
  entrypoints: ["./src/index.ts"],
  outdir: "dist",
  tsconfig: "./tsconfig.custom.json"
})

Now run:

bun build.ts

You will see this error:

1 | import { sum } from "@/utils";
                        ^
error: Could not resolve: "@/utils". Maybe you need to "bun install"?
    at /Users/admin/Desktop/bun-reproduce-build-api-custom-tsconfig-issue/src/index.ts:1:21

Bun v1.3.8 (macOS arm64)

You can also reproduce like this:

  • git clone https://github.com/arshad-yaseen/bun-reproduce-build-api-custom-tsconfig-issue.git
  • cd bun-reproduce-build-api-custom-tsconfig-issue
  • Run: bun run build

What is the expected behavior?

Expected to resolve the path aliases correctly and build successfully.

What do you see instead?

The build fails with a resolution error (see error output in reproduction steps above).

Additional information

Interestingly, the tsconfig option in the Bun.build() API is equivalent to the --tsconfig-override option in the CLI. However, when building the same entrypoint using the CLI with --tsconfig-override, the path aliases resolve properly and the build succeeds.

For example, this command works:

bun build src/index.ts --tsconfig-override=tsconfig.custom.json --outdir=dist

However, I still see this grayed-out error in the CLI output:

Bundled 2 modules in 5ms

Internal error: directory mismatch for directory "/Users/admin/Desktop/bun-reproduce-build-api-custom-tsconfig-issue/tsconfig.custom.json", fd 3. You don't need to do anything, but this indicates a bug.
  index.js  52 bytes  (entry point)

Activity

  1. added
    bug
    on Feb 7, 2026
  2. changed the title [-]`tsconfig` option in `Bun.build` API not working[/-] [+]`Bun.build()` `tsconfig` option doesn't resolve path aliases (CLI works)[/+] on Feb 7, 2026
  3. jesterfraud commented on Feb 19, 2026

    @jesterfraud

    I'm guessing we're relying on random chance for this issue being addressed out of the 4.8k open issues and 1.3k open pull requests right now. 🙁

  4. robobun commented on Nov 17, 2026

    @robobun
    Collaborator

    This is fixed on main.

    What I ran, on Linux x64 (the report is from macOS): the four files from the report (build.ts, tsconfig.custom.json, src/index.ts, src/utils.ts), run with bun build.ts and with the report's bun build --tsconfig-override command.

    • Bun v1.3.8: fails the build with error: Could not resolve: "@/utils". Maybe you need to "bun install"?, and the CLI build with --tsconfig-override prints Internal error: directory mismatch.
    • main (d3d074e32): resolves @/utils through tsconfig.custom.json and writes dist/index.js with function sum() {} in three runs out of three, and the CLI build prints no internal error line.

    The first release that passes is Bun v1.4.3.
    The fix is #44361.

    If this still fails for you on the latest Bun, comment here with the version and the output, and the issue can be reopened.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions