-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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.build always assume "react-jsxdev" even when set "react-jsx" #3768
Comments
This seems to affect |
Same here. I use a custom JSX implementation ( |
Unfortunately I couldn't even get it to work by setting NODE_ENV to production. Just before giving up completely on bundling react libraries with Bun, I happened to find that changing external from
|
|
Just ran into this myself. Looks like it was an intentional design decision. I'm not really sure what's meant by:
Seems like we should, at the very least, fix the documentation. But I would prefer if Bun did what its documentation currently says and use |
Until current version 1.1.16, it seems this error still exists. There is no difference when choosing
When I built a package module for react, using jsxDev resulted in an error on the production.
|
Although the comment is a bit outdated, I found that using // main.ts
import React from 'hono/jsx';
// The same problem will occur with hono/jsx module
globalThis.React = React; {
"compilerOptions": {
"jsx": "react"
}
} |
@PunchlY I'm not sure what errors you're referring to, but this doesn't seem to have anything to do with this issue. |
@jordanbtucker |
After breaking my head on this for > 5 hours, thank you! Next.js was always complaining (using shared UI package here built with Bun) with Thus replacing them all with jsx did the trick. P.S. adapted it to the below: // Your build script
await Bun.build({ ... });
// Patch the output
for (const file of await Array.fromAsync(new Glob("dist/**/*.js").scan())) {
const content = await Bun.file(file).text();
await Bun.write(file, content.replace(/jsxDEV/g, 'jsx').replace(/react\/jsx-dev-runtime/g, 'react/jsx-runtime'));
} |
I just encountered the same issue. Replacing all occurrences of My solution was changing the build command in the bun run build.ts To the following: NODE_ENV=production bun run build.ts This worked wonders. It might be that Bun does not correctly recognize the production env variable specified in the |
What version of Bun is running?
0.7.0
What platform is your computer?
Darwin 22.5.0 arm64 arm
What steps can reproduce the bug?
run:
make sure to set
{jsx: "react-jsx" }
in your tsconfigWhat is the expected behavior?
You will see the output always use:
jsx_dev_runtime.jsxDEV("div", {
What do you see instead?
instead of
jsx_runtime.jsx("div", {
Additional information
Why bun always use "react-jsxdev" instead of following tsconfig ?
The text was updated successfully, but these errors were encountered: