Skip to content

API Bun.build(...) doesn't read JSX directives from bunfig.toml (but CLI "bun build" does) #19556

Open

Description

@egnor

What version of Bun is running?

1.2.12+32a47ae45

What platform is your computer?

Linux 6.12.3-061203-generic x86_64 x86_64

What steps can reproduce the bug?

in this example I'm using jsx-dom as an example JSX provider (that isn't React), and configuring it in bunfig.toml...

  1. install bun
  2. create these files:package.json
{
  "name": "test",
  "dependencies": {
    "jsx-dom": "^8.1.6"
  }
}

bunfig.toml

jsx = "react-jsx"
jsxImportSource = "jsx-dom"

test.jsx

return  <h1>Hello World!</h1>;

run_bun.js

Bun.build({ entrypoints: [ "test.jsx" ] });
  1. run bun install (to get jsx-dom)

  2. run bun build test.jsx, I get a whole bunch of output (including the jsx-dom runtime), ending with...

// test.jsx
return /* @__PURE__ */ jsx("h1", {
  children: "Hello World!"
}, undefined, false, undefined, this);
  1. run bun run_bun.sh, I get:
error: Could not resolve: "react/jsx-dev-runtime". Maybe you need to "bun install"?
    at /home/egnor/test/test.jsx

Bun v1.2.12 (Linux x64 baseline)

What is the expected behavior?

Expected: Bun.build({ entrypoints: ["test.jsx"] }) and bun build test.jsx would do roughly the same thing, both process bunfig.toml, and both succeed in translating this file with the specified settings

What do you see instead?

Actual: bun build test.jsx works, but Bun.build({ entrypoints: ["test.jsx"] }) does not, as it doesn't seem to be using the relevant parts of bunfig.toml.

(If it's not intended that bunfig.toml get read when using the API, this should surely be documented.)

Note that if the settings are made in the "compilerOptions" section of jsconfig.json instead of bunfig.toml, Bun.build(...) does work.

Additional information

(It would also be nice to be able to provide these settings in Bun.build(...)'s options?)

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

    bugSomething isn't workingbundlerSomething to do with the bundler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions