Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
772 additions
and
445 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,34 +1,5 @@ | ||
{ | ||
"env": { | ||
"webpack": { | ||
"presets": [ | ||
["env", { | ||
"targets": { | ||
"node": "4.7", | ||
"browsers": [ | ||
"last 3 versions", | ||
"ie >= 11" | ||
] | ||
}, | ||
"modules": false | ||
}] | ||
], | ||
"plugins": ["transform-object-assign"] | ||
}, | ||
"test": { | ||
"presets": [ | ||
["env", { | ||
"targets": { | ||
"node": "4.7", | ||
"browsers": [ | ||
"last 3 versions", | ||
"ie >= 11" | ||
] | ||
} | ||
}] | ||
], | ||
"plugins": ["rewire", "transform-object-assign"], | ||
"sourceMaps": "inline" | ||
} | ||
} | ||
"presets": [ | ||
"./.babelrc.js" | ||
] | ||
} |
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,106 @@ | ||
// About this file: | ||
// Babel 7 introduces .babelrc.js files. The .babelrc file can be removed when Babel 7 is released. (https://github.com/babel/babel/pull/4892) | ||
|
||
// Babel 7 will also remove the 'env' option --> https://github.com/babel/babel/issues/4539#issuecomment-284870486 | ||
var env = process.env.BABEL_ENV || process.env.NODE_ENV | ||
|
||
var defaultBabelPresetEnvConfig = { | ||
// No module transformation, webpack will take care of this if necessary. | ||
'modules': false | ||
} | ||
|
||
// Latest browsers | ||
var browserBabelPresetEnvConfig = Object.assign({}, defaultBabelPresetEnvConfig, { | ||
'targets': { | ||
'browsers': [ | ||
'last 2 versions', | ||
'not ie < 13', | ||
'not android < 50' | ||
] | ||
} | ||
}) | ||
|
||
// Legacy browsers | ||
var legacyBabelPresetEnvConfig = Object.assign({}, defaultBabelPresetEnvConfig, { | ||
'targets': { | ||
'browsers': [ | ||
'last 5 versions', | ||
'not ie < 10' | ||
] | ||
} | ||
}) | ||
|
||
// Node | ||
var nodeBabelPresetEnvConfig = Object.assign({}, defaultBabelPresetEnvConfig, { | ||
'targets': { | ||
'node': '4.7' | ||
} | ||
}) | ||
|
||
// Combined node and browser environment for es6 modules version and tests | ||
var modulesBabelPresetEnvConfig = Object.assign({}, defaultBabelPresetEnvConfig, { | ||
'targets': Object.assign(legacyBabelPresetEnvConfig.targets, nodeBabelPresetEnvConfig.targets) | ||
}) | ||
|
||
var testBabelPresetEnvConfig = Object.assign({}, modulesBabelPresetEnvConfig, { | ||
// Tests need to transform modules | ||
'modules': 'commonjs' | ||
}) | ||
|
||
var plugins = [ | ||
'transform-object-rest-spread', | ||
'lodash', | ||
['inline-replace-variables', { | ||
// Inject version number into code | ||
'__VERSION__': require('./package.json').version | ||
}] | ||
] | ||
|
||
var babelConfig = { | ||
plugins | ||
} | ||
|
||
if (env === 'browser') { | ||
babelConfig = Object.assign(babelConfig, { | ||
'presets': [ | ||
['env', browserBabelPresetEnvConfig] | ||
] | ||
}) | ||
} | ||
|
||
if (env === 'legacy') { | ||
babelConfig = Object.assign(babelConfig, { | ||
'presets': [ | ||
['env', legacyBabelPresetEnvConfig] | ||
] | ||
}) | ||
} | ||
|
||
if (env === 'modules') { | ||
babelConfig = Object.assign(babelConfig, { | ||
'presets': [ | ||
['env', modulesBabelPresetEnvConfig] | ||
] | ||
}) | ||
} | ||
|
||
if (env === 'node') { | ||
babelConfig = Object.assign(babelConfig, { | ||
'presets': [ | ||
['env', nodeBabelPresetEnvConfig] | ||
] | ||
}) | ||
} | ||
|
||
if (env === 'test') { | ||
babelConfig = Object.assign(babelConfig, { | ||
'presets': [ | ||
['env', testBabelPresetEnvConfig] | ||
], | ||
'plugins': babelConfig.plugins.concat([ | ||
'rewire' | ||
]) | ||
}) | ||
} | ||
|
||
module.exports = babelConfig |
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 |
---|---|---|
|
@@ -3,5 +3,8 @@ module.exports = { | |
'plugins': [ | ||
'standard', | ||
'promise' | ||
] | ||
], | ||
'globals': { | ||
'__VERSION__': true | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.