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).
The following table lists all relevant Babel transform plugins for ECMAScript features up to ES2021.
The State column is one of:
-
✓ included — The plugin is included in this preset, i.e. njs doesn’t support this feature (or part of it) yet.
-
✗ not needed — The plugin is not needed, i.e. njs already supports this feature.
-
⚠ incompatible — The plugin is not compatible with njs, i.e. requires features that njs doesn’t support yet.
Plugin | ECMAScript | State | Notes |
---|---|---|---|
ES3 |
✗ not needed |
||
ES3 |
✗ not needed |
||
ES3 |
✗ not needed |
||
ES5 |
✗ not needed |
||
ES2015 |
✗ not needed |
||
ES2015 |
✗ not needed |
||
ES2015 |
✗ not needed |
since njs 0.6.0 |
|
ES2015 |
✓ included |
||
ES2015 |
✗ not needed |
since njs 0.3.4 |
|
ES2015 |
✓ included |
||
ES2015 |
✗ not needed |
||
ES2015 |
✗ not needed |
||
ES2015 |
⚠ incompatible |
||
ES2015 |
✗ not needed |
||
ES2015 |
✗ not needed |
||
ES2015 |
✗ not needed |
||
ES2015 |
✓ included |
||
ES2015 |
✓ included |
Only rest parameters are supported. |
|
ES2015 |
✗ not needed |
||
ES2015 |
✓ included |
||
ES2015 |
✗ not needed |
since njs 0.6.0 |
|
ES2015 |
✗ not needed |
||
ES2015 |
✗ not needed |
||
ES2015 |
✗ not needed |
Supported, but not in identifiers (e.g. variable name). |
|
ES2015 |
✓ included |
||
ES2016 |
✗ not needed |
||
ES2017 |
✗ not needed |
since njs 0.7.0 |
|
ES2018 |
⚠ incompatible |
njs doesn’t support generators yet |
|
ES2018 |
✓ included |
||
ES2018 |
✗ not needed |
||
ES2018 |
✓ included |
||
ES2018 |
✓ included |
||
ES2019 |
✓ included |
||
ES2019 |
✗ not needed |
||
ES2020 |
⚠ incompatible |
njs has only limited support of ES modules. |
|
ES2020 |
✓ included |
||
ES2020 |
✗ not needed |
||
ES2020 |
✓ included |
||
ES2021 |
✓ included |
||
ES2021 |
✗ not needed |
The following assumptions are enabled for better performance and match with the behaviour of the TypeScript transpiler.
This project is licensed under MIT License.