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
Re-use babel.config.js in babel-loader in an explicit way #899
Comments
You can either specify |
I did not find these specified anywhere in the README. Should they be in the So let's say I have this config in options: {
plugins: [
['@babel/plugin-proposal-class-properties'],,
['@babel/plugin-proposal-object-rest-spread'],
],
presets: [
['@babel/preset-env', { targets: "defaults" }]
]
}, And this in module.exports = {
plugins: [
['./client/node_modules/babel-plugin-transform-amd-to-commonjs'],
['./client/node_modules/@babel/plugin-proposal-class-properties'],
['./client/node_modules/@babel/plugin-transform-spread'],
],
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
}; then the final config for options: {
plugins: [
['./client/node_modules/babel-plugin-transform-amd-to-commonjs'],
['@babel/plugin-proposal-class-properties'],,
['@babel/plugin-proposal-object-rest-spread'],
],
presets: [
['@babel/preset-env', { targets: "defaults" }]
]
}, I suppose I should actually test this to see what I get. I assume that would break because the path will be incorrect in the merged example. Maybe I am just attacking this wrong, but it should be quite common to have a webpack config in a |
The first line in the "Options" section of the README is "See the babel options", which links exactly to where these options are documented 😅 If I understood your goals correctly, you can remove the |
Thanks! |
I'm submitting a feature request
Webpack Version:
4.46.0
Babel Core Version:
"@babel/core": "7.13.15"
Babel Loader Version:
8.2.2
Please tell us about your environment:
Linux
Current behavior:
I have these files:
client/webpack.config.dev.js
babel.config.js
The webpack config contains the
babel-loader
specific options and presets to build my app. But I need to duplicate these into ababel.config.js
because both ESLint via@babel/eslint-parser
as well as Jest via thetransforms
config need the same babel configuration to run. This means three different applications using the babel config.Expected/desired behavior:
I would want to specify in my
babel-loader
config to instead use thebabel.config.js
to configure how it behaves. I would want to specify a file path tobabel.config.js
in thebabel-loader
config.What is the motivation / use case for changing the behavior?
It lets developers focus on configuring babel in one location, instead of multiple. This saves time as well as potential bugs where developers forget to update two locations.
Additional context
If the
webpack.config.dev.js
andbabel.config.js
files exist in the same directory there already seems to be a merge of configs where thebabel.config.js
takes precedence. See #823 for discussion around this.Maybe a simple solution would be to specify a
"search": "upwards"
or something forbabel-loader
to find thebabel.config.js
to still keep the merging?The text was updated successfully, but these errors were encountered: