barbar/vortigern

UglifyJS cannot be used with ES6 output from typescript in current config

bherila opened this issue · 4 comments

Per webpack/webpack#2972

I have had to comment out these lines in the prod.js webpack config.

    // new webpack.optimize.UglifyJsPlugin({
    //   compress: {
    //     warnings: false
    //   }
    // }),

Any advice/ideas/thoughts about this would be appreciated.

Thanks,
Ben

Its worth noting that Uglify appears to be fine with "const", and seems to just not like "let" for some reason.

As a result if you're not truly using all ES6 syntax/format; its not a heavy lift to get this working with Uglify.

Thanks for the reply @securityvoid :)

Do you think the ES6 output from tsc should be converted to ES5 using Babel?

OR13 commented

I get no error when settings:

"target": "es5", in tsconfig.json

and running:

$ npm run build:prod
$ npm run start:prod

I've encountered errors with UglifyJsPlugin and ES6 + babel before... better to have TS do the heavy lifting than playing games with wepback and babel...

I solved this issue adding uglifyjs-webpack-plugin and not using the uglifyJsPlugin chipped with webpack.

// webpack.config.js

const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
	// ...
	plugins: [
		new UglifyJSPlugin({/* options */}),
		// ...
	]	
}

hope this helps! :)