Skip to content

Instantly share code, notes, and snippets.

@MaxMotovilov
Created August 8, 2017 22:28
Show Gist options
  • Save MaxMotovilov/de9090d3197d2ff75df9b25c9086e6d4 to your computer and use it in GitHub Desktop.
Save MaxMotovilov/de9090d3197d2ff75df9b25c9086e6d4 to your computer and use it in GitHub Desktop.
Running Uglify twice results in correct optimization!
export default function() { console.log( "A" ) }
export { b }
function b() { console.log( "B" ) }
! function() {
"use strict";
function o() {
console.log("B")
}
for (var n = 0, c = 1, t = function() {
console.log("A")
}, f = 0; f < 2; ++f) n && t(), c && o()
}();
! function() {
"use strict";
for (var o = 0; o < 2; ++o) console.log("B")
}();
export const A=0, B=1;
import * as conf from "./configuration";
import a from "./a";
import * as b from "./b" ;
function foo() {
if( conf.A )
a();
if( conf.B )
b.b();
}
for( var i=0; i<2; ++i )
foo();
import uglify from 'rollup-plugin-uglify';
import buble from 'rollup-plugin-buble';
export default {
entry: 'main.js',
format: 'iife',
exports: "none",
interop: false,
plugins: [ buble(), uglify() /* , uglify() -- uncomment for right result */ ],
dest: 'bundle.once.js' /* change to bundle.twice.js when uncommenting 2nd uglify instance */
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment