babel-plugin-minify-mangle-names

Context- and scope- aware variable renaming.

MIT 87 个版本
安装
npm install babel-plugin-minify-mangle-names
yarn add babel-plugin-minify-mangle-names
pnpm add babel-plugin-minify-mangle-names
bun add babel-plugin-minify-mangle-names
README

babel-plugin-minify-mangle-names

Context- and scope- aware variable renaming.

Example

In

var globalVariableName = 42;
function foo() {
  var longLocalVariableName = 1;
  if (longLocalVariableName) {
    console.log(longLocalVariableName);
  }
}

Out

var globalVariableName = 42;
function foo() {
  var a = 1;
  if (a) {
    console.log(a);
  }
}

Installation

npm install babel-plugin-minify-mangle-names --save-dev

Usage

.babelrc

// without options
{
  "plugins": ["minify-mangle-names"]
}
// with options
{
  "plugins": [
    ["minify-mangle-names", { "exclude": { "foo": true, "bar": true} }]
  ]
}

Via CLI

babel --plugins minify-mangle-names script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["minify-mangle-names"]
});

Options

  • exclude - A plain JS Object with keys as identifier names and values indicating whether to exclude (default: {})
  • eval - mangle identifiers in scopes accessible by eval (default: false)
  • keepFnName - prevent mangler from altering function names. Useful for code depending on fn.name (default: false)
  • topLevel - mangle topLevel Identifiers (default: false)
  • keepClassName - prevent mangler from altering class names (default: false).
版本列表
0.5.1 2022-05-06
0.5.0-alpha.9 2018-09-23
0.5.0 2018-09-24
0.4.3 2018-05-14
0.4.2 2018-05-14
0.4.1 2018-05-03
0.4.0 2018-04-08
0.3.0 2018-01-31
0.2.0 2017-08-14
0.1.3 2017-06-13
0.1.2 2017-05-23
0.1.1 2017-05-22
0.1.0 2017-05-22
0.0.8 2017-03-03
0.0.7 2017-02-08
0.0.6 2017-01-17
0.0.5 2016-11-21
0.0.4 2016-10-31
0.0.3 2016-09-20
0.0.2 2016-08-31
0.0.1 2016-08-26