systemjs / builder

SystemJS build tool
MIT License
466 stars 122 forks source link

Uglify Upgrade #815

Closed timfish closed 5 years ago

timfish commented 7 years ago

This is an initial stab but needs more work.

Now I'm looking through the code I realise the options merging/transformations should really be happening in processOutputOpts but there is quite a bit of legacy stuff in there without tests so I'll need to be careful not to break anything.

It should support the existing config options:

builder.bundle('myModule.js', 'outfile.js', { minify: true, mangle: false, uglify: uglifyOps  });

Or you can pass the entire uglify-es valid config in yourself through options.uglifyes:

var uglifyOpt = { 
    compress: {
        global_defs: { DEBUG: false },
        dead_code: true,
    },
    mangle: false,
    warnings: false 
}
builder.bundle('myModule.js', 'outfile.js', { minify: true, uglifyes: uglifyOpt });
guybedford commented 6 years ago

@timfish see also the approach in https://github.com/systemjs/builder/pull/818. I wonder how far a 3.x upgrade gets us here?

timfish commented 6 years ago

The v3/master readme says:

- uglify-js@3 has a simplified API and CLI that is not backwards compatible with uglify-js@2.
- uglify-js only supports ECMAScript 5 (ES5).
- Those wishing to minify ES2015+ (ES6+) should use the npm package uglify-es.

I can't see any obvious features that you'd get updating to v3/master. The api changes to v3 are not backwards compatible so I doubted you could just upgrade the package like that. Unless I've missed something obvious! 😄

guybedford commented 6 years ago

Ok thanks for checking this. We should definitely stick with this upgrade path then.

behzad888 commented 6 years ago

I want to using babel-plugin-syntax-dynamic-import in bundler task, but i have an error in this case. have anybody an idea? for more details you can see > https://travis-ci.org/behzad888/builder/builds/253923865

guybedford commented 6 years ago

@behzad888 it looks like you're running an older version of SystemJS builder, try upgrading to the latest.

behzad888 commented 6 years ago

@guybedford i'm using latest version of SystemJS builder but new version of uglify-js need to define transpiler SystemJS.config({ transpiler: 'transpiler-module' }). Although in my local project its ok but travis ci builder has an error as Unable to dynamically transpile ES module.
How to set transpiler on SystemJS builder test cases?

timfish commented 5 years ago

Seems like uglify-es is no longer supported.

guybedford commented 5 years ago

See ‘terser’, it’s replacement fork. On Sun, 30 Sep 2018 at 17:38, Tim Fish notifications@github.com wrote:

Seems like uglify-es is no longer supported.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/systemjs/builder/pull/815#issuecomment-425729594, or mute the thread https://github.com/notifications/unsubscribe-auth/AAkiyjPQYCGX-0ZMNKMP0tjmvQO9rjYdks5ugOV4gaJpZM4OID5O .