Chore: use Uglify version with ES6 support

Authored by Niedzielski on Nov 14 2017, 3:12 PM.


Chore: use Uglify version with ES6 support

According to the docs, Webpack uses an older version of
uglifyjs-webpack-plugin when the -p command line option is specified.
This older version of the plugin uses uglify-js which does not support
ES6 targets, which is needed for a server Webpack configuration. Either
the TypeScript compiler target and libraries need to be updated to a
configuration similar to the client or the Webpack config needs to be
modified to use the latest version of Uglify plugin. This patch takes
the latter approach. The build products are approximately the same
except that the source maps are about twice as large.


Webpack =< v3.0.0 currently contains v0.4.6 of this plugin under
webpack.optimize.UglifyJsPlugin as an alias. For usage of the latest
version (v1.0.0), please follow the instructions below. Aliasing
v1.0.0 as webpack.optimize.UglifyJsPlugin is scheduled for webpack

npm i -D uglifyjs-webpack-plugin

Alternative tsconfig.json changes:

  • "target": "ES2015",
  • "module": "commonjs", + "target": "es5", + "module": "esnext", + "lib": ["es2015", "dom"],

Bug: T177235
Change-Id: I672af9b2597d5ef85205ee1b7bd0193314b7c5e1