@babel/plugin-transform-reserved-words

NOTE: This plugin is included in @babel/preset-env

Some words were reserved in ES3 as potential future keywords but were not reserved in ES5 and later. This plugin, to be used when targeting ES3 environments, renames variables from that set of words.

Example

In

  1. var abstract = 1;
  2. var x = abstract + 1;

Out

  1. var _abstract = 1;
  2. var x = _abstract + 1;

Installation

  1. npm install --save-dev @babel/plugin-transform-reserved-words

Usage

  1. {
  2. "plugins": ["@babel/plugin-transform-reserved-words"]
  3. }

Via CLI

  1. babel --plugins @babel/plugin-transform-reserved-words script.js

Via Node API

  1. require("@babel/core").transformSync("code", {
  2. plugins: ["@babel/plugin-transform-reserved-words"],
  3. });

References