@@ -21,7 +21,6 @@ import typescript from 'rollup-plugin-typescript';
2121import flow from './lib/flow-plugin' ;
2222import camelCase from 'camelcase' ;
2323
24- const interopRequire = m => m . default || m ;
2524const readFile = promisify ( fs . readFile ) ;
2625const stat = promisify ( fs . stat ) ;
2726const isDir = name => stat ( name ) . then ( stats => stats . isDirectory ( ) ) . catch ( ( ) => false ) ;
@@ -259,32 +258,40 @@ function createConfig(options, entry, format, writeMeta) {
259258 // [`export default ${rollupName};`]: '',
260259 // [`var ${rollupName} =`]: 'export default'
261260 // }),
262- options . compress !== false && uglify ( {
263- output : { comments : false } ,
264- mangle : {
261+ options . compress !== false && [
262+ uglify ( {
263+ output : { comments : false } ,
264+ compress : {
265+ keep_infinity : true ,
266+ pure_getters : true
267+ } ,
268+ warnings : true ,
269+ ecma : 5 ,
265270 toplevel : format === 'cjs' || format === 'es' ,
266- properties : mangleOptions ? {
267- regex : mangleOptions . regex ? new RegExp ( mangleOptions . regex ) : null ,
268- reserved : mangleOptions . reserved || [ ]
269- } : false
270- } ,
271- nameCache
272- } , format === 'es' ? interopRequire ( require ( 'uglify-es' ) ) . minify : undefined ) ,
273- mangleOptions && {
274- // before hook
275- options ( ) {
276- try {
277- nameCache = JSON . parse ( fs . readFileSync ( resolve ( options . cwd , 'mangle.json' ) , 'utf8' ) ) ;
278- }
279- catch ( e ) { }
280- } ,
281- // after hook
282- onwrite ( ) {
283- if ( writeMeta && nameCache ) {
284- fs . writeFile ( resolve ( options . cwd , 'mangle.json' ) , JSON . stringify ( nameCache , null , 2 ) , Object ) ;
271+ mangle : {
272+ properties : mangleOptions ? {
273+ regex : mangleOptions . regex ? new RegExp ( mangleOptions . regex ) : null ,
274+ reserved : mangleOptions . reserved || [ ]
275+ } : false
276+ } ,
277+ nameCache
278+ } ) ,
279+ mangleOptions && {
280+ // before hook
281+ options ( ) {
282+ try {
283+ nameCache = JSON . parse ( fs . readFileSync ( resolve ( options . cwd , 'mangle.json' ) , 'utf8' ) ) ;
284+ }
285+ catch ( e ) { }
286+ } ,
287+ // after hook
288+ onwrite ( ) {
289+ if ( writeMeta && nameCache ) {
290+ fs . writeFile ( resolve ( options . cwd , 'mangle.json' ) , JSON . stringify ( nameCache , null , 2 ) , Object ) ;
291+ }
285292 }
286293 }
287- } ,
294+ ] ,
288295 { ongenerate ( { bundle } , { code } ) {
289296 config . _code = bundle . _code = code ;
290297 } } ,
0 commit comments