Skip to content

Commit

Permalink
[mangle] blacklist -> exclude (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
boopathi authored Aug 18, 2017
1 parent 1b6893b commit 1c9d89b
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/babel-minify/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const mangleBooleanOpts = [
"mangle.keepClassName"
];

const mangleArrayOpts = ["mangle.blacklist"];
const mangleArrayOpts = ["mangle.exclude"];

const typeConsOpts = [
"typeConstructors.array",
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-plugin-minify-mangle-names/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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} }]
}
```

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ describe("mangle-names", () => {
[
mangler,
{
blacklist: { foo: false, bar: true },
exclude: { foo: false, bar: true },
topLevel: true
}
]
Expand Down
14 changes: 7 additions & 7 deletions packages/babel-plugin-minify-mangle-names/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = babel => {
charset,
program,
{
blacklist = {},
exclude = {},
keepFnName = false,
keepClassName = false,
eval: _eval = false,
Expand All @@ -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;
Expand All @@ -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];
}

/**
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-preset-minify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ or pass in options -
{
"presets": [["minify", {
"mangle": {
"blacklist": ["MyCustomError"]
"exclude": ["MyCustomError"]
},
"unsafe": {
"typeConstructors": false
Expand Down Expand Up @@ -117,7 +117,7 @@ tdz | Passed to [builtIns][builtIns], [evaluate][evaluate], [dea
{
"presets": [["minify", {
"mangle": {
"blacklist": ["ParserError", "NetworkError"]
"exclude": ["ParserError", "NetworkError"]
}
}]]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Object {
"keepClassName": true,
"keepFnName": true,
"mangle": Object {
"blacklist": Array [
"exclude": Array [
"foo",
"bar",
],
Expand All @@ -75,7 +75,7 @@ Object {
Array [
"babel-plugin-minify-mangle-names",
Object {
"blacklist": Array [
"exclude": Array [
"foo",
"bar",
],
Expand Down Expand Up @@ -104,7 +104,7 @@ Object {
"keepClassName": true,
"keepFnName": true,
"mangle": Object {
"blacklist": Array [
"exclude": Array [
"baz",
],
"keepClassName": false,
Expand All @@ -129,7 +129,7 @@ Object {
Array [
"babel-plugin-minify-mangle-names",
Object {
"blacklist": Array [
"exclude": Array [
"baz",
],
"keepClassName": false,
Expand Down Expand Up @@ -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",
],
Expand All @@ -202,7 +202,7 @@ Object {
Array [
"babel-plugin-minify-mangle-names",
Object {
"blacklist": Array [
"exclude": Array [
"foo",
"bar",
],
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-preset-minify/__tests__/options-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
});
});
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion packages/gulp-babel-minify/__tests__/gulp-babili-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("gulp-babel-minify", () => {
return new Promise((resolve, reject) => {
const stream = gulpBabelMinify({
mangle: {
blacklist: {
exclude: {
bar: true
}
}
Expand Down

0 comments on commit 1c9d89b

Please sign in to comment.