Babel preset for building modern node apps with the least amount of
transformations as possible.
![devDependencies](https://david-dm.org/michaelcontento/babel-preset-modern-node/dev-status.svg)
![npm downloads](https://img.shields.io/npm/dm/babel-preset-modern-node.svg?style=flat-square)
Installation
npm install --save-dev babel-preset-modern-node
Usage
Simply use this preset as any other. Following options can be passed to
configure babel-preset-modern-node
to your taste:
- Set loose mode optimizations (default:
false
)
- Module loader to use (default:
commonjs
)
modules = (false|commonjs|amd|umd|systemjs)
- Min node version compatibility (default:
process.versions.node
)
Via .babelrc
(recommended)
{
"presets": ["modern-node"]
}
Or:
{
"presets": [["modern-node", { "loose": true, ... }]]
}
Via CLI
babel script.js --presets modern-node
Via Node API
require('babel-core').transform('code', {
presets: ['modern-node'],
})
Or:
require('babel-core').transform('code', {
presets: [['modern-node', { "loose": true, ... }]],
})
Compatibility
This preset currently supports ES2015 and ES2016 support for all minor node
versions starting at v0.12
.
Notes on Array.includes
This preset does not modify the global space / prototypes! Due to this we're
not able to fully support ES2016's Array.includes
see here for more details.
- If you project contains a
package.json
the super global __VERSION__
will be set accordingly
- Strict mode will be enabled
- Restricted keywords will always be quoted
foo.default
becomes foo["default"]
default: "bar"
becomes "default": "bar"