babel-plugin-yui-compressor-fix-reserved-keywords

Babel plugin to automatically rename/fixup variable names, accessors and property names, and statements that trigger YUI compressor bugs.

Usage no npm install needed!

<script type="module">
  import babelPluginYuiCompressorFixReservedKeywords from 'https://cdn.skypack.dev/babel-plugin-yui-compressor-fix-reserved-keywords';
</script>

README

babel-plugin-yui-compressor-fix-reserved-keywords

Babel plugin to automatically rename/fixup variable names, accessors and property names, and statements that trigger YUI compressor bugs.

Note: it will not fixup stuff that is too new for YUI compressor to know about so you should add it late to your list of plugins.

Example

In

var short = function char() {
    debugger;
    return {
        default: 'yes'
    }.default;
}();

Out

var _short = function _char() {
    return {
        'default': 'yes'
    }['default'];
}();

Installation

$ npm install babel-plugin-yui-compressor-fix-reserved-keywords

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["yui-compressor-fix-reserved-keywords"]
}

Via CLI

$ babel --plugins yui-compressor-fix-reserved-keywords script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["yui-compressor-fix-reserved-keywords"]
});