Comparing version 0.3.4 to 0.3.5
# butternut changelog | ||
## 0.3.5 | ||
* Remove unused class declarations ([#25](https://github.com/Rich-Harris/butternut/pull/25)) | ||
* Remove surplus whitespace around method arguments ([#23](https://github.com/Rich-Harris/butternut/issues/23)) | ||
* Insert space after `typeof` where necessary (#24](https://github.com/Rich-Harris/butternut/issues/24)) | ||
* Handle anonymous function as default export ([#28](https://github.com/Rich-Harris/butternut/issues/28)) | ||
## 0.3.4 | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "butternut", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Experimental ES2015-aware minifier", | ||
@@ -16,13 +16,10 @@ "main": "dist/butternut.cjs.js", | ||
"build": "rollup -c", | ||
"build:min": "rollup -c --environment MIN", | ||
"build:browser": "rollup -c --environment UMD", | ||
"build:all": "rollup -c && rollup -c --environment MIN && rollup -c --environment UMD", | ||
"bench": "node test/bench", | ||
"prebench": "npm run build", | ||
"test": "mocha test/test.js", | ||
"test:min": "export TEST_MIN=true && mocha test/test.js", | ||
"test:min": "cross-env TEST_MIN=true && mocha test/test.js", | ||
"pretest": "npm run build", | ||
"pretest:min": "npm run build:min", | ||
"prepublish": "npm run test:min && npm run build && npm run build:browser", | ||
"compare": "mkdir -p test/comparisons/uglify && mkdir -p test/comparisons/butternut && node test/compare.js", | ||
"precompare": "npm run build", | ||
"pretest:min": "npm run build:all", | ||
"prepublish": "npm run test:min", | ||
"lint": "eslint src" | ||
@@ -61,2 +58,3 @@ }, | ||
"console-group": "^0.3.3", | ||
"cross-env": "^5.0.0", | ||
"eslint": "^3.19.0", | ||
@@ -63,0 +61,0 @@ "filesize": "^3.5.9", |
@@ -170,3 +170,3 @@ import Node from './Node.js'; | ||
minify ( code ) { | ||
this.scope.mangle( code ); | ||
if ( this.scope ) this.scope.mangle( code ); // class declarations do not create their own scope | ||
@@ -173,0 +173,0 @@ const statements = this.body.filter( statement => !statement.skip ); |
@@ -10,2 +10,3 @@ import Class from './shared/Class.js'; | ||
initialise () { | ||
this.skip = true; | ||
this.id.declaration = this; | ||
@@ -12,0 +13,0 @@ |
@@ -10,14 +10,15 @@ import Function from './shared/Function.js'; | ||
initialise () { | ||
this.id.declaration = this; | ||
const scope = this.findScope( false ); | ||
this.body.createScope( scope ); | ||
this.skip = !!scope.parent; // guilty until proven innocent | ||
if ( this.id ) { // if not, it's a default export | ||
this.id.declaration = this; | ||
scope.addDeclaration( this.id, 'function' ); | ||
scope.addDeclaration( this.id, 'function' ); | ||
this.skip = !!scope.parent; // guilty until proven innocent | ||
} | ||
} | ||
minify ( code ) { | ||
if ( this.id.start > this.start + 9 ) { | ||
if ( this.id && this.id.start > this.start + 9 ) { | ||
code.overwrite( this.start + 8, this.id.start, this.generator ? '*' : ' ' ); | ||
@@ -24,0 +25,0 @@ } |
@@ -18,7 +18,16 @@ import Node from '../Node.js'; | ||
if ( p.computed ) { | ||
if ( p.key.start > p.start + 1 ) code.overwrite( p.start, p.key.start, '[' ); | ||
if ( p.value.start > p.key.end + 2 ) code.overwrite( p.key.end, p.value.start, ']:' ); | ||
if ( p.computed && p.method ) { | ||
code.overwrite( p.start, p.key.start, '[' ); | ||
code.overwrite( p.key.end, p.value.start, ']' ); | ||
} | ||
else if ( p.computed ) { | ||
code.overwrite( p.start, p.key.start, '[' ); | ||
code.overwrite( p.key.end, p.value.start, ']:' ); | ||
} | ||
else if ( p.method ) { | ||
code.remove( p.key.end, p.value.start ); | ||
} | ||
else { | ||
@@ -25,0 +34,0 @@ if ( p.value.start > p.key.end + 1 ) code.overwrite( p.key.end, p.value.start, ':' ); |
@@ -9,3 +9,3 @@ import Node from '../../Node.js'; | ||
minify ( code ) { | ||
const hasFunctionKeyword = this.type !== 'ArrowFunctionExpression' && this.parent.type !== 'MethodDefinition' && !this.parent.shorthand; | ||
const hasFunctionKeyword = this.type !== 'ArrowFunctionExpression' && this.parent.type !== 'MethodDefinition' && !this.parent.method; | ||
@@ -12,0 +12,0 @@ let lastEnd = ( this.id && !this.removeId ) ? this.id.end : this.start + ( hasFunctionKeyword ? 8 : 0 ); |
@@ -34,5 +34,2 @@ import Node from '../Node.js'; | ||
minify ( code ) { | ||
const len = this.operator.length; | ||
const start = this.start + ( len === 1 ? len : len + 1 ); | ||
const value = this.getValue(); | ||
@@ -44,6 +41,10 @@ if ( value !== UNKNOWN && value !== TRUTHY && value !== FALSY ) { | ||
else { | ||
if ( this.argument.start > start ) { | ||
code.remove( start, this.argument.start ); | ||
} | ||
const len = this.operator.length; | ||
const start = this.start + len; | ||
const insertWhitespace = len > 1 && this.argument.getLeftHandSide().type !== 'ParenthesizedExpression'; | ||
if ( insertWhitespace ) code.appendLeft( start, ' ' ); | ||
code.remove( start, this.argument.start ); | ||
super.minify( code ); | ||
@@ -50,0 +51,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
2118839
14994
29