Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun HTML dev server ignore JSX config #17998

Open
lexcao opened this issue Mar 8, 2025 · 0 comments
Open

Bun HTML dev server ignore JSX config #17998

lexcao opened this issue Mar 8, 2025 · 0 comments
Labels
bake:dev hot-reloading dev server for client+server applications bug Something isn't working bundler Something to do with the bundler

Comments

@lexcao
Copy link

lexcao commented Mar 8, 2025

What version of Bun is running?

1.2.4

What platform is your computer?

Darwin 24.3.0 x86_64 i386

What steps can reproduce the bug?

index.jsx

function createElement(type, props, ...children) {
  console.log("MyReact.createElement called");
  return {
    type,
    props: {
      ...props,
      children,
    },
  };
}

const MyReact = {
  createElement,
};

const element = (
  <div id="foo">
    <h1>Hello MyReact</h1>
  </div>
);

console.log(element);

bunfig.toml

jsx = "react"
jsxFactory = "MyReact.createElement"

index.html

<!DOCTYPE html>
<html lang=en>

<head>
  <title>Learn React</title>
  <script src="./index.jsx" type="module"></script>
</head>

<body>
  <div id="root"></div>
</body>

</html>

What is the expected behavior?

Everything works as expected When I use bun run index.jsx and bun build index.html --outdir out

The jsxFactory is ignored when I use bun index.html

What do you see instead?

The output of the build is correct.

function createElement(type, props, ...children) {
  console.log("MyReact.createElement called");
  return {
    type,
    props: {
      ...props,
      children
    }
  };
}
var MyReact = {
  createElement
};
var element = /* @__PURE__ */ MyReact.createElement("div", {
  id: "foo"
}, /* @__PURE__ */ MyReact.createElement("h1", null, "Hello MyReact"));
console.log(element);

But the HTML version prints the ReactElement, which means it is still using React.createElement.

Additional information

It still not works if I use the output of the build.
Which can be reproduced by the following steps

$ bun build index.html --outdir out
$ cd out && bun index.html

Both dev and production build ignore the JSX config.

@lexcao lexcao added bug Something isn't working needs triage labels Mar 8, 2025
@RiskyMH RiskyMH added bundler Something to do with the bundler bake:dev hot-reloading dev server for client+server applications and removed needs triage labels Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bake:dev hot-reloading dev server for client+server applications bug Something isn't working bundler Something to do with the bundler
Projects
None yet
Development

No branches or pull requests

2 participants