-
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
vite:esbuild gives warning for react fat arrow function components #2328
Comments
Sorry, but I have no idea how to reproduce this given your link. I'm not sure where to look to find the warning, and pressing the fork button doesn't seem to work without setting up an account. The terminal also doesn't work and I don't see a way to extract your code from that website. Can you provide a self-contained example that demonstrates the problem? The easiest thing would to just provide a single file that can be given to esbuild along with the esbuild command-line arguments, without involving Vite at all. |
I don't think this is an issue with I was able to "fix" the problem (or at least make it go away, YMMV) by adding the following to my
This solution is explained in the version |
@scott-lc That solution doesn't work for me. I get a |
@evanw Is there an easy way to find out exactly what flags vite uses when it calls esbuild? I'd be happy to create a minimal reproduction, but I'm not sure how to (easily) do it outside the context of vite. |
I am creating a reproduction in vite. Give me a few minutes. |
The link just randomly started working for me. Here's what I see now:
I assume there's some post-processing that Vite is doing to the source code before esbuild sees it. Maybe it's running Babel's JSX transform? I can't get Vite to do this locally, but I also have no idea how to use Vite. In any case, you should be able to disable this warning with |
I believe the issue is related to vite itself. The source that is passed to esbuild already has Thanks for looking into it. Closing this for now. The link to discussion on vite is here |
Bug opened in vite repo: vitejs/vite#8644 Reproduction is here: https://github.com/nareshbhatia/vite-esmbuild-issue |
I still don't have a way to reproduce this using Vite, but I'm assuming the issue is with Babel then esbuild. I'm going to try to detect when this happens and omit the warning in that case for the next release of esbuild. |
Please try my repo mentioned above: https://github.com/nareshbhatia/vite-esmbuild-issue. Easy to reproduce in two steps:
|
Thanks. I can reproduce it now, and I can confirm my fix above will avoid the warning. |
Thanks for the quick fix. Also it happens with |
This is the code that imitates how plugin-react transforms classic JSX runtime. (I've omitted |
The issue is related to not including @babel/preset-env @sapphi-red I have modified your example https://stackblitz.com/edit/node-f81xay?file=run.js,package.json,input.jsx and if you toggle the line in 10 and 11 it will show the warning |
@smeng9 Your example is converting ESM to CJS with babel. So I think both esbuild and @babel/plugin-transform-react-jsx-self is doing nothing wrong here. One way to solve this is to disable this warning automatically by plugin-react. |
After bumping the version from 0.14.44 to 0.14.45, projects created using vite react template with fat arrow functional components throws a lot of warnings about
I have made an example using codesandbox to illustrate the warning. https://codesandbox.io/s/silly-violet-b21kmm?file=/src/Test2.jsx
You can compare the difference between Test1, Test2, and Test3. In case the warning does not showup, you can click the fork button to relaunch the server.
The expected behavior should not have a warning for
<Test2 />
component.The text was updated successfully, but these errors were encountered: