A Babel preset for transforming JavaScript code with modern language features into code compatible with njs (NGINX JavaScript).
This preset includes support for all the ECMAScript features up to ES2021 — see Plugins for a complete list.
TIP: Take a look at njs-typescript-starter for a complete starter template for developing njs scripts for NGINX server in TypeScript (including integration tests).
Installation
npm install --save-dev babel-preset-njs
yarn add --dev babel-preset-njs
Compatibility Matrix
preset-njs | njs | Babel |
---|
0.1.0 – 0.2.1 | ≥ 0.5.0 | 7 |
0.7.0 | ≥ 0.7.0 | 7 |
Usage
With a Configuration File (Recommended)
{
"presets": ["babel-preset-njs"]
}
Via CLI
babel --presets babel-preset-njs script.js
Via Node API
require('@babel/core').transform('code', {
presets: [require('babel-preset-njs')],
})
Plugins
The list of included Babel plugins is available here.
References
License
This project is licensed under MIT License.