sindresorhus / p-map

Map over promises concurrently
MIT License
1.27k stars 58 forks source link

UglifyJsPlugin: Invalid assignment #6

Closed d0ruk closed 7 years ago

d0ruk commented 7 years ago

Hello,

Here is my UglifyJsPlugin config;

new webpack.optimize.UglifyJsPlugin({
          compress: {
            warnings: false,
            screw_ie8: true,
            conditionals: true,
            unused: true,
            comparisons: true,
            sequences: true,
            dead_code: true,
            evaluate: true,
            if_return: true,
            join_vars: true,
            drop_console: true,
          },
          output: { comments: false },
          sourceMap: true
        })

Here's the error I get;

ERROR in js/vendor_b535d98.js from UglifyJs Invalid assignment [./node_modules/p-map/index.js:2,0][js/vendor_b535d98.js:1709,42]

ERROR in js/main_b535d98.js from UglifyJs Unexpected token: operator (>) [./src/util/js/api.js:7,8][js/main_b535d98.js:26,12]

Even If I completely remove the options, (new UglifyJS()) minification still errors out.

The line it yells at;

module.exports = (iterable, mapper, opts) => new Promise((resolve, reject) => {

which seems perfectly OK to me.

Do you have any solution besides switching my uglifyJS method? That is the only idea I'm left with.

SamVerschueren commented 7 years ago

It's because UglifyJS can't handle ES2015 features like fat arrow. We aim for Node.js though, not the browser. You can find a more detailed explanation here https://github.com/sindresorhus/ama/issues/446.

If you use Webpack, check out babel-engine-plugin, which transpiles only the dependencies that needs to be transpiled.