-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Source babel-preset-env targets from package.json
- Add .babelrc.js and use the browserslist defined in package.json to set targets for babel-preset-env. - Reference .babelrc.js from .babelrc file because babel@6 does not support common js module for defining config.
- Loading branch information
1 parent
affdc01
commit 406784a
Showing
2 changed files
with
31 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,8 @@ | ||
{ | ||
"presets": [ | ||
["env", { | ||
"modules": false, | ||
"targets": { | ||
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"] | ||
} | ||
}], | ||
"stage-2" | ||
], | ||
"plugins": ["transform-runtime"]{{#if_or unit e2e}}, | ||
"presets": ["./.babelrc.js"]{{#if_or unit e2e}}, | ||
"env": { | ||
"test": { | ||
"presets": ["env", "stage-2"]{{#if_eq runner "karma"}}, | ||
"plugins": ["istanbul"]{{/if_eq}}{{#if_eq runner "jest"}}, | ||
"plugins": ["transform-es2015-modules-commonjs", "dynamic-import-node"]{{/if_eq}} | ||
"presets": ["./.babelrc.js"] | ||
} | ||
}{{/if_or}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const pkg = require('./package.json') | ||
|
||
module.exports = function babelConfig() { {{#if_or unit e2e}} | ||
if (process.env.NODE_ENV === 'test') { | ||
return { | ||
presets: ['env', 'stage-2']{{#if_eq runner "karma"}}, | ||
plugins: ['istanbul']{{/if_eq}}{{#if_eq runner "jest"}}, | ||
plugins: ['transform-es2015-modules-commonjs', 'dynamic-import-node']{{/if_eq}} | ||
} | ||
}{{/if_or}} | ||
return { | ||
presets: [ | ||
[ | ||
'env', | ||
{ | ||
modules: false, | ||
// This shouldn't be necessary once `@babel/preset-env` is out of beta. | ||
targets: { | ||
browsers: pkg.browserslist | ||
} | ||
} | ||
], | ||
'stage-2' | ||
], | ||
plugins: ['transform-runtime'] | ||
} | ||
} |