Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bherila opened this issue Jun 22, 2017 · 4 comments
Open

Comments

@bherila
Copy link
Contributor

bherila commented Jun 22, 2017

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

@securityvoid
Copy link

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.

@bherila
Copy link
Contributor Author

bherila commented Jun 28, 2017

Thanks for the reply @securityvoid :)

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

@OR13
Copy link

OR13 commented Jul 3, 2017

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...

@horacioh
Copy link

horacioh commented Aug 17, 2018

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! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants