Skip to main content

@babel/plugin-transform-reserved-words

info

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

JavaScript
var abstract = 1;
var x = abstract + 1;

Out

JavaScript
var _abstract = 1;
var x = _abstract + 1;

Installation​

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

Usage​

babel.config.json
{
"plugins": ["@babel/plugin-transform-reserved-words"]
}

Via CLI​

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

Via Node API​

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

References​