-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Custom react jsxImportSource
output syntax
#2704
Comments
Thanks but it's not the same thing actually. I don't write |
The React team has decided that these suffixes are part of the contract of the React-specific JSX transform. If you are using the React-specific JSX transform then you need to follow the contract. The React team are in control of how React works, so it's their decision to make. This is also in esbuild's documentation: https://esbuild.github.io/api/#jsx-import-source:
The community tried doing what you suggested, but it broke things and was reverted:
So I'm not going to add this to esbuild. As a library author, the way to fix this is to use the |
@evanw Thanks for the reply. I understand neither I learned about the export const Dummy = () => {
return <div>text</div>;
}; When I bundle it by import { jsx } from "react/jsx-runtime";
var Dummy = () => {
return /* @__PURE__ */ jsx("div", {
children: "text"
});
}; When I use import { Dummy } from 'pkg-a/xxx' |
I'm still not quite sure what your use case is, but it's worth mentioning that node has a corresponding |
I'll create a repo to illustrate later. |
Hi @evanw , sorry for the delay, I created a demo. And here is the case, when you run // src/index.tsx
import { jsx } from "react/jsx-runtime";
var Demo = (props) => {
return /* @__PURE__ */ jsx("div", { className: "Demo", children: "text" });
};
export {
Demo
}; And all I want to achieve is that append a - import { jsx } from "react/jsx-runtime";
+ import { jsx } from "react/jsx-runtime.js"; Then if others use my package, they don't even need to think about this issue we discussed above, I'll handle it under the hood. |
Quick question:
Is there a way to change the output
import {} from 'react/jsx-runtime'
toimport {} from 'react/jsx-runtime.js
Background:
I wrote a lib which use jsx syntax internally, and I use tsup to bundle it to
.js
and.mjs
files. Then I encountered this problem: facebook/create-react-app#11769 , which is a feature ofmjs
file according to this comment. And there are some solutions:As a library author, I don't think either of them is a good alternative. I want to ship my package as soon as possible and cover the fix before delivered. Is there any workaround to achieve what I want? Thanks in advance.
The text was updated successfully, but these errors were encountered: