-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Babel config includes more plugins than it should #1665
Comments
@KyleAMathews This is probably related... I want to tweak the default env configuration so that it has So my initial idea was to add a exports.modifyWebpackConfig = ({ config, stage }) => {
if (stage === 'build-javascript') {
config.loader('js', (current) => {
console.log(JSON.stringify(current, null, 2));
return current;
});
}
return config;
}; And the output was... {
"test": {},
"exclude": {},
"loader": "babel",
"query": {
"presets": [
"C:\\git\\project\\node_modules\\babel-preset-env\\lib\\index.js",
"C:\\git\\project\\node_modules\\babel-preset-stage-3\\lib\\index.js",
"C:\\git\\project\\node_modules\\babel-preset-react\\lib\\index.js",
[
"C:\\git\\project\\node_modules\\babel-preset-env\\lib\\index.js",
{
"loose": true,
"uglify": true,
"modules": "commonjs",
"targets": {
"browsers": [
"> 1%",
"last 2 versions",
"IE >= 9"
]
},
"exclude": [
"transform-regenerator",
"transform-es2015-typeof-symbol"
]
}
],
"C:\\git\\project\\node_modules\\babel-preset-stage-0\\lib\\index.js",
"C:\\git\\project\\node_modules\\babel-preset-react\\lib\\index.js"
],
"plugins": [
"C:\\git\\project\\node_modules\\gatsby\\dist\\utils\\babel-plugin-extract-graphql.js",
"C:\\git\\projects\\node_modules\\babel-plugin-add-module-exports\\lib\\index.js",
"C:\\git\\project\\node_modules\\babel-plugin-transform-object-assign\\lib\\index.js"
],
"cacheDirectory": true
}
} This looks strange... then I realised, it is because i have a project level Thoughts? |
V2 fixes this issue so closing! |
Just noting this for posterity. https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/utils/babel-config.js#L149-L160
Babel preset env will try and only load plugins that are needed, but it's defeated in more modern envs by the
stage-0
preset. Here's what happens:stage
preset includes all the others above it, so stage-0 includes 1-4env
preset, but the stage-0 preset includes it so its included regardless.The text was updated successfully, but these errors were encountered: