diff --git a/packages/babel-minify/src/cli.js b/packages/babel-minify/src/cli.js index 0e6c3bad9..9d18dddcf 100644 --- a/packages/babel-minify/src/cli.js +++ b/packages/babel-minify/src/cli.js @@ -43,7 +43,7 @@ const mangleBooleanOpts = [ "mangle.keepClassName" ]; -const mangleArrayOpts = ["mangle.blacklist"]; +const mangleArrayOpts = ["mangle.exclude"]; const typeConsOpts = [ "typeConstructors.array", diff --git a/packages/babel-plugin-minify-mangle-names/README.md b/packages/babel-plugin-minify-mangle-names/README.md index 79db6d8f2..858f1dca2 100644 --- a/packages/babel-plugin-minify-mangle-names/README.md +++ b/packages/babel-plugin-minify-mangle-names/README.md @@ -50,7 +50,7 @@ npm install babel-plugin-minify-mangle-names ```json // with options { - "plugins": ["minify-mangle-names", { "blacklist": { "foo": true, "bar": true} }] + "plugins": ["minify-mangle-names", { "exclude": { "foo": true, "bar": true} }] } ``` @@ -70,7 +70,7 @@ require("babel-core").transform("code", { ## Options -+ `blacklist` - A plain JS Object with keys as identifier names and values indicating whether to exclude ++ `exclude` - A plain JS Object with keys as identifier names and values indicating whether to exclude + `eval` - mangle identifiers in scopes accessible by eval + `keepFnName` - prevent mangler from altering function names. Useful for code depending on `fn.name` + `topLevel` - mangle topLevel Identifiers diff --git a/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js b/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js index 733b224cf..596363157 100644 --- a/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js +++ b/packages/babel-plugin-minify-mangle-names/__tests__/mangle-names-test.js @@ -396,7 +396,7 @@ describe("mangle-names", () => { [ mangler, { - blacklist: { foo: false, bar: true }, + exclude: { foo: false, bar: true }, topLevel: true } ] diff --git a/packages/babel-plugin-minify-mangle-names/src/index.js b/packages/babel-plugin-minify-mangle-names/src/index.js index 59d0a6dc8..5b6d5f8b2 100644 --- a/packages/babel-plugin-minify-mangle-names/src/index.js +++ b/packages/babel-plugin-minify-mangle-names/src/index.js @@ -24,7 +24,7 @@ module.exports = babel => { charset, program, { - blacklist = {}, + exclude = {}, keepFnName = false, keepClassName = false, eval: _eval = false, @@ -35,7 +35,7 @@ module.exports = babel => { this.program = program; // user passed options - this.blacklist = toObject(blacklist); + this.exclude = toObject(exclude); this.keepFnName = keepFnName; this.keepClassName = keepClassName; this.topLevel = topLevel; @@ -59,11 +59,11 @@ module.exports = babel => { } /** - * Tells if a variable name is blacklisted + * Tells if a variable name is excluded * @param {String} name */ - isBlacklist(name) { - return hop.call(this.blacklist, name) && this.blacklist[name]; + isExcluded(name) { + return hop.call(this.exclude, name) && this.exclude[name]; } /** @@ -313,8 +313,8 @@ module.exports = babel => { // 1. The scope in which it is declared // 2. The class's own scope (binding.path.isClassDeclaration() && binding.path === scope.path) || - // blacklisted - mangler.isBlacklist(oldName) || + // excluded + mangler.isExcluded(oldName) || // function names (mangler.keepFnName ? isFunction(binding.path) : false) || // class names diff --git a/packages/babel-preset-minify/README.md b/packages/babel-preset-minify/README.md index 33de53a43..5ebef54f7 100644 --- a/packages/babel-preset-minify/README.md +++ b/packages/babel-preset-minify/README.md @@ -30,7 +30,7 @@ or pass in options - { "presets": [["minify", { "mangle": { - "blacklist": ["MyCustomError"] + "exclude": ["MyCustomError"] }, "unsafe": { "typeConstructors": false @@ -117,7 +117,7 @@ tdz | Passed to [builtIns][builtIns], [evaluate][evaluate], [dea { "presets": [["minify", { "mangle": { - "blacklist": ["ParserError", "NetworkError"] + "exclude": ["ParserError", "NetworkError"] } }]] } diff --git a/packages/babel-preset-minify/__tests__/__snapshots__/options-tests.js.snap b/packages/babel-preset-minify/__tests__/__snapshots__/options-tests.js.snap index 8029ef685..1246e31d6 100644 --- a/packages/babel-preset-minify/__tests__/__snapshots__/options-tests.js.snap +++ b/packages/babel-preset-minify/__tests__/__snapshots__/options-tests.js.snap @@ -49,7 +49,7 @@ Object { "keepClassName": true, "keepFnName": true, "mangle": Object { - "blacklist": Array [ + "exclude": Array [ "foo", "bar", ], @@ -75,7 +75,7 @@ Object { Array [ "babel-plugin-minify-mangle-names", Object { - "blacklist": Array [ + "exclude": Array [ "foo", "bar", ], @@ -104,7 +104,7 @@ Object { "keepClassName": true, "keepFnName": true, "mangle": Object { - "blacklist": Array [ + "exclude": Array [ "baz", ], "keepClassName": false, @@ -129,7 +129,7 @@ Object { Array [ "babel-plugin-minify-mangle-names", Object { - "blacklist": Array [ + "exclude": Array [ "baz", ], "keepClassName": false, @@ -184,7 +184,7 @@ exports[`preset-options should pass options to respective plugin when its an obj Object { "input": Object { "mangle": Object { - "blacklist": Array [ + "exclude": Array [ "foo", "bar", ], @@ -202,7 +202,7 @@ Object { Array [ "babel-plugin-minify-mangle-names", Object { - "blacklist": Array [ + "exclude": Array [ "foo", "bar", ], diff --git a/packages/babel-preset-minify/__tests__/options-tests.js b/packages/babel-preset-minify/__tests__/options-tests.js index 416ce28b2..1cff46c53 100644 --- a/packages/babel-preset-minify/__tests__/options-tests.js +++ b/packages/babel-preset-minify/__tests__/options-tests.js @@ -64,7 +64,7 @@ describe("preset-options", () => { it("should pass options to respective plugin when its an object", () => { testOpts({ mangle: { - blacklist: ["foo", "bar"] + exclude: ["foo", "bar"] } }); }); @@ -78,14 +78,14 @@ describe("preset-options", () => { keepFnName: true, keepClassName: true, mangle: { - blacklist: ["foo", "bar"] + exclude: ["foo", "bar"] } }); testOpts({ keepFnName: true, keepClassName: true, mangle: { - blacklist: ["baz"], + exclude: ["baz"], keepFnName: false, keepClassName: false } diff --git a/packages/gulp-babel-minify/__tests__/gulp-babili-test.js b/packages/gulp-babel-minify/__tests__/gulp-babili-test.js index f3a38d3ce..4f0ca1137 100644 --- a/packages/gulp-babel-minify/__tests__/gulp-babili-test.js +++ b/packages/gulp-babel-minify/__tests__/gulp-babili-test.js @@ -39,7 +39,7 @@ describe("gulp-babel-minify", () => { return new Promise((resolve, reject) => { const stream = gulpBabelMinify({ mangle: { - blacklist: { + exclude: { bar: true } }