oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.25k stars 2.77k forks source link

Bun.Transpiler using { jsxImportSource: "solid-js" } outputs React code #3528

Open martwz opened 1 year ago

martwz commented 1 year ago

What version of Bun is running?

0.6.13

What platform is your computer?

Darwin 22.5.0 Darwin Kernel Version 22.5.0: Mon Apr 24 20:52:24 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6000 arm64 arm

What steps can reproduce the bug?

const transpiler = new Bun.Transpiler({
  loader: "tsx",
  tsconfig: {
    compilerOptions: { jsx: "react-jsx", jsxImportSource: "solid-js" },
  },
});
const result = transpiler.transformSync(`console.log(<div>hello world</div>)`);
console.log(result); // console.log(React.createElement("div", null, "hello world"));

What is the expected behavior?

Expected result to be wrapped in Solidjs's jsx.

What do you see instead?

React.createElement("div", null, "hello world")

Additional information

No response

LowByteFox commented 1 year ago

Set jsxFactory to what solid-js uses

tsconfig docs

Hope it helps

But even with autoImportJSX set to true bun doesn't generate code to import the function only when tsconfig is not set

DaniGuardiola commented 11 months ago

FYI, I built a plugin to compile Solid.js with Bun - https://github.com/DaniGuardiola/bun-plugin-solid