babel-preset-njs

0.7.0 • Public • Published

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

# using npm:
npm install --save-dev babel-preset-njs
# or using yarn:
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.

Readme

Keywords

Package Sidebar

Install

npm i babel-preset-njs

Weekly Downloads

102

Version

0.7.0

License

MIT

Unpacked Size

17.4 kB

Total Files

6

Last publish

Collaborators

  • jirutka