Skip to content

Commit

Permalink
Run tests through babel globally. (gatsbyjs#1780)
Browse files Browse the repository at this point in the history
* Run tests through babel globally.

* Ignore tests in production environment.

* format
  • Loading branch information
dardub authored and KyleAMathews committed Aug 14, 2017
1 parent eb47799 commit 5535c85
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
9 changes: 7 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"sourceMaps": true,
"ignore": ["__tests__", "dist"],
"presets": [
"./.babelrc.js"
]
],
"ignore": ["dist"],
"env": {
"production": {
"ignore": ["__tests__", "dist"],
}
},
}
13 changes: 6 additions & 7 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ const r = m => require.resolve(m)

function preset(context, options = {}) {
const { browser = false, debug = false } = options
const { NODE_ENV, BABEL_ENV } = process.env;
const { NODE_ENV, BABEL_ENV } = process.env

const PRODUCTION = (BABEL_ENV || NODE_ENV) === "production"

const browserConfig = {
useBuiltIns: false,
targets: {
browsers: PRODUCTION
? [`last 4 versions`, `safari >= 7`, 'ie >= 9']
? [`last 4 versions`, `safari >= 7`, "ie >= 9"]
: [`last 2 versions`, `not ie <= 11`, `not android 4.4.3`],
uglify: PRODUCTION,
},
Expand All @@ -26,16 +26,15 @@ function preset(context, options = {}) {
presets: [
[
r("babel-preset-env"),
Object.assign({
Object.assign(
{
loose: true,
debug: !!debug,
useBuiltIns: true,
modules: "commonjs",
},
browser ?
browserConfig :
nodeConfig
)
browser ? browserConfig : nodeConfig
),
],
r("babel-preset-react"),
r("babel-preset-flow"),
Expand Down

0 comments on commit 5535c85

Please sign in to comment.