Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Should shakapacker support JSX and React by default for Babel #55

Closed
justin808 opened this issue Feb 7, 2022 · 1 comment
Closed

Should shakapacker support JSX and React by default for Babel #55

justin808 opened this issue Feb 7, 2022 · 1 comment

Comments

@justin808
Copy link
Member

justin808 commented Feb 7, 2022

I had previously moved React support to docs in rails/webpacker#3224.

Given that esbuild and swc will support JSX by default, maybe the babel config should be moved back?

I'm also working on https://github.com/shakacode/react-on-webpacker/ which could make that configuration easier.

@tomdracz
Copy link
Collaborator

tomdracz commented Feb 7, 2022

In two minds about this.

On one hand, it would it would bring it closer to other loaders and follow similar thing to TS or SASS - config is there and you just need to install the package.

Still, esbuild and SWC do support it without additional package (like preset-react) so it makes sense for it to be there. Having the support there also makes things bit easier - both SWC and esbuild need to have different loader flag based on whether the file is tsx, jsx, ts or js. It's non obvious how to get this going so opted to take care of this problem for users. The drawback is, some people still use react without jsx/tsx extensions but that's not supported here - I'm enforcing convention on you (although don't think anything would happen if we're enabled jsx for JS files and tsx for TS files, that's essentially what we end up with babel).

Also, if we bring in the default for preset-react it makes it harder to configure additional options - you're not just adding new preset - you have to find the current one, merge the options etc Bit of a pain and don't think it's easy to do this in a backwards compatible manner.

All in all, I would veer towards getting https://github.com/shakacode/react-on-webpacker tested and ready and perhaps offering similar options for SWC and esbuild to streamline the config. If we get the latter right, we could make jsx non default for both to align all loaders.

@shakacode shakacode locked and limited conversation to collaborators Feb 8, 2022
@justin808 justin808 converted this issue into discussion #61 Feb 8, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants