@babel/plugin-transform-reserved-words

Some words were reserved in ES3 as potential future keywords but were notreserved in ES5 and later. This plugin, to be used when targeting ES3environments, 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

.babelrc

  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").transform("code", {
  2. plugins: ["@babel/plugin-transform-reserved-words"]
  3. });

References