We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
1.1.38
Darwin 23.6.0 x86_64 i386
Create demo.tsx:
demo.tsx
/** @jsx h */ const h = () => "hello world"; console.log(<div></div>);
Run bun demo.tsx
bun demo.tsx
It should print "hello world"
error: Cannot find module 'react/jsx-dev-runtime' from '/path/to/demo.tsx'
I just want to use JSX, I don't want to depend on React.
This works like a charm:
tsc demo.tsx --jsx react node demo.js
So tsc allows me to use JSX without React. The compiled code demo.js is:
demo.js
/** @jsx h */ var h = function () { return "hello world"; }; console.log(h("div", null));
Bun should do the same instead of require 'react/jsx-dev-runtime'. Because the code has nothing to do with React.
'react/jsx-dev-runtime'
tsx works without any issue: tsx index.tsx.
tsx index.tsx
The text was updated successfully, but these errors were encountered:
On windows is a bit different:
bun demo.tsx downloads React automatically and outputs this:
{ $$typeof: Symbol(react.transitional.element), type: "div", key: null, props: {}, _owner: null, ref: null, _store: { validated: 0, }, _debugInfo: null, }
And if I try to build it: bun build demo.tsx --outdir .\out
bun build demo.tsx --outdir .\out
error: Could not resolve: "react/jsx-dev-runtime". Maybe you need to "bun install"? at path\to\demo.tsx
Sorry, something went wrong.
I find that the issue disappears if I create a tsconfig.json file with content:
tsconfig.json
{ "compilerOptions": { "jsx": "react" } }
A demo project: https://github.com/tylerlong/bun-jsx-without-react-demo
if I create a tsconfig.json file with content:
Same result with bunfig.toml:
bunfig.toml
jsx = "react"
No branches or pull requests
What version of Bun is running?
1.1.38
What platform is your computer?
Darwin 23.6.0 x86_64 i386
What steps can reproduce the bug?
Create
demo.tsx
:Run
bun demo.tsx
What is the expected behavior?
It should print "hello world"
What do you see instead?
I just want to use JSX, I don't want to depend on React.
Additional information
This works like a charm:
So tsc allows me to use JSX without React. The compiled code
demo.js
is:Bun should do the same instead of require
'react/jsx-dev-runtime'
.Because the code has nothing to do with React.
tsx works without any issue:
tsx index.tsx
.The text was updated successfully, but these errors were encountered: