babel-plugin-minify-dead-code-elimination
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -775,3 +775,3 @@ "use strict"; | ||
// `function.name` all minifiers do it and hence became a standard. | ||
"FunctionExpression|ClassExpression"(path) { | ||
"FunctionExpression"(path) { | ||
if (!this.keepFnName) { | ||
@@ -782,2 +782,9 @@ removeUnreferencedId(path); | ||
// remove class names | ||
"ClassExpression"(path) { | ||
if (!this.keepClassName) { | ||
removeUnreferencedId(path); | ||
} | ||
}, | ||
// Put the `var` in the left if feasible. | ||
@@ -831,21 +838,29 @@ ForInStatement(path) { | ||
}, | ||
Program(path) { | ||
var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
_ref4$opts = _ref4.opts; | ||
Program: { | ||
exit(path) { | ||
var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
_ref4$opts = _ref4.opts; | ||
_ref4$opts = _ref4$opts === undefined ? {} : _ref4$opts; | ||
var _ref4$opts$optimizeRa = _ref4$opts.optimizeRawSize, | ||
optimizeRawSize = _ref4$opts$optimizeRa === undefined ? false : _ref4$opts$optimizeRa, | ||
_ref4$opts$keepFnName = _ref4$opts.keepFnName, | ||
keepFnName = _ref4$opts$keepFnName === undefined ? false : _ref4$opts$keepFnName, | ||
_ref4$opts$keepFnArgs = _ref4$opts.keepFnArgs, | ||
keepFnArgs = _ref4$opts$keepFnArgs === undefined ? false : _ref4$opts$keepFnArgs; | ||
_ref4$opts = _ref4$opts === undefined ? {} : _ref4$opts; | ||
var _ref4$opts$optimizeRa = _ref4$opts.optimizeRawSize, | ||
optimizeRawSize = _ref4$opts$optimizeRa === undefined ? false : _ref4$opts$optimizeRa, | ||
_ref4$opts$keepFnName = _ref4$opts.keepFnName, | ||
keepFnName = _ref4$opts$keepFnName === undefined ? false : _ref4$opts$keepFnName, | ||
_ref4$opts$keepClassN = _ref4$opts.keepClassName, | ||
keepClassName = _ref4$opts$keepClassN === undefined ? false : _ref4$opts$keepClassN, | ||
_ref4$opts$keepFnArgs = _ref4$opts.keepFnArgs, | ||
keepFnArgs = _ref4$opts$keepFnArgs === undefined ? false : _ref4$opts$keepFnArgs; | ||
// We need to run this plugin in isolation. | ||
path.traverse(main, { | ||
functionToBindings: new Map(), | ||
optimizeRawSize, | ||
keepFnName, | ||
keepFnArgs | ||
}); | ||
traverse.clearCache(); | ||
path.scope.crawl(); | ||
// We need to run this plugin in isolation. | ||
path.traverse(main, { | ||
functionToBindings: new Map(), | ||
optimizeRawSize, | ||
keepFnName, | ||
keepClassName, | ||
keepFnArgs | ||
}); | ||
} | ||
} | ||
@@ -852,0 +867,0 @@ } |
{ | ||
"name": "babel-plugin-minify-dead-code-elimination", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/babel/babili#readme", |
@@ -15,4 +15,6 @@ # babel-plugin-minify-dead-code-elimination | ||
console.log(x); | ||
function unused() { | ||
return 5; | ||
} | ||
} | ||
foo(0 && bar()); | ||
``` | ||
@@ -28,3 +30,2 @@ | ||
} | ||
foo(0); | ||
``` | ||
@@ -35,3 +36,3 @@ | ||
```sh | ||
$ npm install babel-plugin-minify-dead-code-elimination | ||
npm install babel-plugin-minify-dead-code-elimination | ||
``` | ||
@@ -60,3 +61,3 @@ | ||
```sh | ||
$ babel --plugins minify-dead-code-elimination script.js | ||
babel --plugins minify-dead-code-elimination script.js | ||
``` | ||
@@ -76,1 +77,2 @@ | ||
+ `keepFnArgs` - prevent plugin from removing function args. Useful for code depending on `fn.length` | ||
+ `keepClassName` - prevent mangler from altering class names. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39346
1031
74