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

[WIP] Babel Autoinstall #1772

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/transforms/babel.js
Expand Up @@ -107,6 +107,21 @@ async function getBabelConfig(asset) {
// Merge the babel-preset-env config and the babelrc if needed
if (babelrc && !shouldIgnoreBabelrc(asset.name, babelrc)) {
if (envConfig) {
// Auto Install any missing babel plugins
if(babelrc.plugins){
for(let plugin of babelrc.plugins){
let pluginName = getPluginName(plugin);
await localRequire(`babel-plugin-${pluginName}`, asset.name)
}
}

// Autoinstall any missing babel presets
if(babelrc.presets){
for(let preset of babelrc.presets){
await localRequire(`babel-preset-${preset}`, asset.name)
}
}

// Filter out presets that are already applied by babel-preset-env
if (Array.isArray(babelrc.presets)) {
babelrc.presets = babelrc.presets.filter(preset => {
Expand Down