Skip to content
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

Make it easier to add extra babel plugins #8

Open
rb1193 opened this issue Nov 8, 2020 · 4 comments
Open

Make it easier to add extra babel plugins #8

rb1193 opened this issue Nov 8, 2020 · 4 comments
Assignees
Labels
wontfix This will not be worked on

Comments

@rb1193
Copy link

rb1193 commented Nov 8, 2020

To add a new babel plugin to the configuration, I had to override the entire "module" key in my project's webpack.config.js, which required me to copy all the babel configuration functions from webpack.common.js into my project's config file.

Fortunately for this project I can manage without this particular Babel plugin, so I decided not to bother as it would mean not being able to benefit from future changes to the webpack config in this package.

I'm not exactly sure what the best solution is for this - the mergeWithRules() function in https://github.com/survivejs/webpack-merge might provide a way forward. Alternatively it may be better to allow projects to pass extra configuration parameters to the webpack rules configuration functions (e.g. configureBabelLoader, configureEsLint - these could be exported). That could also get pretty messy though. I don't want to get too deeply into this at the moment but if I have time I will try to revisit.

@hatzipanis
Copy link
Member

Good feedback, cheers @rb1193!

@rb1193
Copy link
Author

rb1193 commented Nov 15, 2020

Having spent a bit more time considering this I think it probably isn't realistic. Given that Facebook haven't found a way to do it in https://github.com/facebook/create-react-app haven't found a way to do it, I'd say it's pretty unlikely that we'd succeed where they have failed. They instead provide an "eject" command that simply duplicates all the webpack configs into your project.

Should we provide a similar eject command? Thoughts @judereid @thejoshsmith @hatzipanis ?

@rb1193 rb1193 added the wontfix This will not be worked on label Nov 15, 2020
@judereid
Copy link
Contributor

judereid commented Nov 16, 2020

@rb1193 Just had a quick play around with this. For the specific issue here (adding babel plugins), it is currently possible to override the babel config by installing the desired plugin directly on the project and placing a .babelrc in the project root. This does appear to do some kind of 'merge', in that both plugins in the .babelrc and webpack config will be applied. I couldn't find any docs on this though so not sure exactly how it works.

An eject could be a worthwhile addition though depending on how much effort it is. It would be fairly trivial to just copy over the configurations and dependencies manually as it it right now.

cc @thejoshsmith

@moacode
Copy link

moacode commented Nov 16, 2020

This is an interesting topic and probably warrants a wider discussion. My gut feeling after talking with @rb1193 yesterday is that perhaps we're better off providing an eject method if developers need to deviate from the standard config.

If the goal is to provide a zero config "ready to go" Webpack setup then to me it seems like if you need functionality outside of that, you're better off having a custom config.

Let's do some investigation and have a chat at the next dev meeting perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants