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

Plugin breaks to minify es2015 and newer #112

Closed
code-chris opened this Issue Aug 20, 2017 · 12 comments

Comments

Projects
None yet
4 participants
@code-chris

code-chris commented Aug 20, 2017

Hi,
today I changed my TypeScript "target" setting from "es5" to "es2015". This caused an compile error in one of my typescript files:

ERROR in main.js?bust=oqYFU from UglifyJs
Unexpected token: name (App) [./app/App.ts:19,13][main.js?bust=oqYFU:78963,8]

The line and column refers to the class name. This error happens too with more modern target settings.

My setup:

  • TypeScript 2.4.2
  • Webpack 3.5.4
  • uglifyjs-webpack-plugin 1.0.0-beta.2
  • uglify-js 3.0.10
  • OS Windows 10
  • Node 8.1.2

Maybe this relates to #49, but I'm not sure.

Does anybody know why this happens? If you need more information, please tell me.
Thanks!

@kzc

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

evilebottnawi Aug 21, 2017

Member

@code-chris link above help to solve problem, if not please provide a minimum reproducible test repo, thanks!

Member

evilebottnawi commented Aug 21, 2017

@code-chris link above help to solve problem, if not please provide a minimum reproducible test repo, thanks!

@code-chris

This comment has been minimized.

Show comment
Hide comment
@code-chris

code-chris Aug 21, 2017

Thanks for your quick reply, but the issue still occurs: https://github.com/code-chris/uglifyjs-repro

code-chris commented Aug 21, 2017

Thanks for your quick reply, but the issue still occurs: https://github.com/code-chris/uglifyjs-repro

@kzc

This comment has been minimized.

Show comment
Hide comment
@kzc

kzc Aug 21, 2017

uglifyjs-webpack-plugin@0.4.6 and uglify-js@2.x can only minify ES5:

https://github.com/code-chris/uglifyjs-repro/blob/8bd2d31083fcdd34fcb64acf5e124238225c061f/package.json#L10

    "uglifyjs-webpack-plugin": {
      "version": "0.4.6",
      "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz",
      "integrity": "sha1-uVH0q7a9YX5m9j64kUmOORdj4wk=",
      "dev": true,
      "requires": {
        "source-map": "0.5.7",
        "uglify-js": "2.8.29",
        "webpack-sources": "1.0.1"
      }
    },

If you've configured it successfully you would see uglify-es in package-lock.json.

kzc commented Aug 21, 2017

uglifyjs-webpack-plugin@0.4.6 and uglify-js@2.x can only minify ES5:

https://github.com/code-chris/uglifyjs-repro/blob/8bd2d31083fcdd34fcb64acf5e124238225c061f/package.json#L10

    "uglifyjs-webpack-plugin": {
      "version": "0.4.6",
      "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz",
      "integrity": "sha1-uVH0q7a9YX5m9j64kUmOORdj4wk=",
      "dev": true,
      "requires": {
        "source-map": "0.5.7",
        "uglify-js": "2.8.29",
        "webpack-sources": "1.0.1"
      }
    },

If you've configured it successfully you would see uglify-es in package-lock.json.

@code-chris

This comment has been minimized.

Show comment
Hide comment
@code-chris

code-chris Aug 21, 2017

@kzc sorry, my fault. Yes, this fixed the original issue. Now I hit the same bug as described in #31.

code-chris commented Aug 21, 2017

@kzc sorry, my fault. Yes, this fixed the original issue. Now I hit the same bug as described in #31.

@kzc

This comment has been minimized.

Show comment
Hide comment
@kzc

kzc Aug 21, 2017

The stackoverflow instructions do work. All I can suggest is to delete node_modules and do a fresh npm install and verify the module versions in package-lock.json.

People experiencing issues configuring webpack should wait for the uglifyjs-webpack-plugin @1.0.0 release.

kzc commented Aug 21, 2017

The stackoverflow instructions do work. All I can suggest is to delete node_modules and do a fresh npm install and verify the module versions in package-lock.json.

People experiencing issues configuring webpack should wait for the uglifyjs-webpack-plugin @1.0.0 release.

@code-chris

This comment has been minimized.

Show comment
Hide comment
@code-chris

code-chris Aug 21, 2017

clean install brings the initial error again, but ok. Is there a final release date planned (or a rough range) ?

code-chris commented Aug 21, 2017

clean install brings the initial error again, but ok. Is there a final release date planned (or a rough range) ?

@evilebottnawi

This comment has been minimized.

Show comment
Hide comment
@evilebottnawi

evilebottnawi Aug 22, 2017

Member

@code-chris First we should review and accept (or not accept) #108, some time later we will do final release, thanks!

Member

evilebottnawi commented Aug 22, 2017

@code-chris First we should review and accept (or not accept) #108, some time later we will do final release, thanks!

@michael-ciniawsky

This comment has been minimized.

Show comment
Hide comment
@michael-ciniawsky

michael-ciniawsky Aug 28, 2017

Member

npm i -D uglifyjs-webpack-plugin@beta (uglify-es) => Minify ES2015+

Member

michael-ciniawsky commented Aug 28, 2017

npm i -D uglifyjs-webpack-plugin@beta (uglify-es) => Minify ES2015+

@kzc

This comment has been minimized.

Show comment
Hide comment
@kzc

kzc Sep 13, 2017

@code-chris The reason for your test repo's failure are these two lines:

    "prod": "webpack -p",
    "dev": "webpack -d"

You need to change them to:

    "prod": "webpack --define process.env.NODE_ENV=production",
    "dev": "webpack --define process.env.NODE_ENV=development"

webpack@3.5.5's -p and -d flags make use of uglifyjs-webpack-plugin@0.4.6 which uses the ES5-only uglify-js@2.8.29. This is not obvious at all and should probably be mentioned in the README.

ref: #104 (comment)

kzc commented Sep 13, 2017

@code-chris The reason for your test repo's failure are these two lines:

    "prod": "webpack -p",
    "dev": "webpack -d"

You need to change them to:

    "prod": "webpack --define process.env.NODE_ENV=production",
    "dev": "webpack --define process.env.NODE_ENV=development"

webpack@3.5.5's -p and -d flags make use of uglifyjs-webpack-plugin@0.4.6 which uses the ES5-only uglify-js@2.8.29. This is not obvious at all and should probably be mentioned in the README.

ref: #104 (comment)

@code-chris

This comment has been minimized.

Show comment
Hide comment
@code-chris

code-chris Sep 13, 2017

@kzc yes, this actually fixed the bug in my test repo... thanks!
Unfortunately in my big project (with a much more complex webpack config) the plugin does not minify anything, without an error. Hopefully I can find the issue there...

code-chris commented Sep 13, 2017

@kzc yes, this actually fixed the bug in my test repo... thanks!
Unfortunately in my big project (with a much more complex webpack config) the plugin does not minify anything, without an error. Hopefully I can find the issue there...

@kzc

This comment has been minimized.

Show comment
Hide comment
@kzc

kzc Sep 13, 2017

The problem is that webpack includes an earlier incompatible version of this plugin by name causing all the versioning confusion. Changing the plugin options only add to the confusion. The uglify-es version of this plugin really ought to have a different name since most users run into these same problems. I just noticed that stackoverflow is a fountain of incorrect advice on this subject - the wisdom of crowds. Better to wait for a new webpack release that makes use of the new uglify-es version of this plugin.

kzc commented Sep 13, 2017

The problem is that webpack includes an earlier incompatible version of this plugin by name causing all the versioning confusion. Changing the plugin options only add to the confusion. The uglify-es version of this plugin really ought to have a different name since most users run into these same problems. I just noticed that stackoverflow is a fountain of incorrect advice on this subject - the wisdom of crowds. Better to wait for a new webpack release that makes use of the new uglify-es version of this plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment