babel-preset-cordial v0.3.3
babel-preset-cordial
Babel preset used by @thebespokepixel/cordial
@thebespokepixel/cordial is a gulp4 and git-flow based build mastering tool that can create multi-personality npm/CommonJS/ES6+ packages from the CLI or within Tower 2 automatically up to ES2016/ES7 (stage-3). Handy for when you need to optimise against as much as is natively supported.
Includes transformers:
for node.js < v6.0.0
- es2015: Spread operator ()
- es2015: Parameters
- es2015: Sticky regex
- es2015: Unicode regex
for node.js < v6.5.0
- es2015: Destructuring
- es2015: Function name
for all node versions
- es2015: Modules to CommonJS
- es2016: Exponentiantion operator
- es2017: Trailing function commas (stage-3)
- es2017: Async functions-to-generator (stage-3)
Shimmed elements
Also adds corejs shims for the following 'untransformable' es2016/7 features missing in node.js v4.0.0 to v6.1.0, but only when used in sources:
for node.js < v6.0.0
- es2015: Reflect (corejs subset)
for node.js < v6.3.0
- es2016: Array.prototype.includes()
for all node versions
- es2017: Object.entries()
- es2017: Object.values()
- es2017: Object.getOwnPropertyDescriptors() (stage-3)
- es2017: String.prototype.padStart() (stage-3)
- es2017: String.prototype.padEnd() (stage-3)
Unhandled es2015+ language constructs:
- Array.prototype.values()
- Iterator closing (Destructuring, Map, Set etc)
- Symbol.species
- Tail call optimisation
- Correct prototype chains
- SIMD
- Proxy (node.js v6.0+ only)
- Refer to Node.green
Based on babel-preset-modern-node by Michael Contento.
Unlike babel-preset-modern-node, the builtin Array is extended to allow Array.prototype.includes.
Installation
npm install --save-dev babel-preset-cordialUsage
- Read "Configuring Babel 6" article for more information about babel@6 configuration.
- Decide which version of node you want to support
- Use
['cordial', {version: $VERSION}](e.g.['cordial', {version: '6.8'}]) as your preset, or['cordial', {version: 'es2015|es2016|es2017'}]for standards based output for rollup/tree shaking. - By default, import and export commands will NOT be transpiled to CommonJS' require in the output, enabling it's use with Rollup which requires es2015 module syntax. If you need CommonJS output, add
{modules: 'commonjs'}to the presets array. Also supported areamd,umdandsystemjsmodule syntaxes.
Via .babelrc
.babelrc
{
"presets": [
["cordial", {
"version": "6.8",
"modules": "commonjs"
}]
]
}Via Node API
require('babel-core').transform('code', {
presets: [
['cordial', {
version: '6.8',
modules: 'commonjs'
loose: true
}]
],
})9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago