Awesome
babel-preset-modern-node
Babel preset for building modern node apps with the least amount of transformations as possible.
Deprecated - No longer maintained
My focus has left the node ecosystem and also the awesome babel-team came up with babel-preset-env. So please do yourself a favor and switch over to babel-preset-env.
Thank you for your patience and using this module in the first place!
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
)loose = true|false
- Module loader to use (default:
commonjs
)modules = (false|commonjs|amd|umd|systemjs)
- Min node version compatibility (default:
process.versions.node
)version = "5.10.2"
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.
Special extras
- 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
becomesfoo["default"]
default: "bar"
becomes"default": "bar"