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

Uglify throwing an error with 7.0.0 #5186

Closed
jcbreel opened this issue May 17, 2018 · 13 comments · Fixed by #5189
Closed

Uglify throwing an error with 7.0.0 #5186

jcbreel opened this issue May 17, 2018 · 13 comments · Fixed by #5189

Comments

@jcbreel
Copy link

jcbreel commented May 17, 2018

Description

I'm using Uglify with Webpack and if I use v7.0.0 I get the following error when trying to uglify my code:

ERROR in 0.js from UglifyJs Unexpected token: punc (,) [0.js:45921,41]

Anyone experiencing this?

@jcbreel jcbreel changed the title Uglify trhowing an error with 7.0.0 Uglify throwing an error with 7.0.0 May 17, 2018
@nypinstripes
Copy link

Yes @jcbreel I started experiencing this last night also when getting ready to deploy & needed to downgrade back to 6.10.0. Everything looked ok locally in my dev build, but when i ran it through my prod webpack-html minifying & uglifyjs-webpack-plugin pipeline (with relatively minimal but tested config on webpack 3.11.0), i couldn't get past this issue and one other one which i believe was related to use of object assignments in default values for function args in ES6 like:

const playerFunction = ({ attributes: stuff }) =>

Neglected to save the output before downgrading, can try reproducing later.

I'd suppose this is due to uglifyjs-webpack-plugin not capable of parsing es2015/es6 features, but even after transforming the core playerjs with babel it doesnt seem to be succeeding. I'm a little out-of-my-depth going much further into it, perhaps i'm required to do the webpack 4 upgrade i've been avoiding lol, not sure though. Maybe @gkatsev or @mjneil can help shed light.

@gkatsev
Copy link
Member

gkatsev commented May 17, 2018

We do use ES6 syntax in source code but we use babel to compile it all down to es5 code. We do have a pkg.module file pointing at an es modules code that webpack potentially is using, but webpack should know how to handle es modules. Maybe something unexpected snuck through?

@gkatsev
Copy link
Member

gkatsev commented May 17, 2018

I just tried using webpack 4 and it seems to work for the most part, except for uglify using an unsafe transform by default that can cause issues with typeof expressions.

@nypinstripes
Copy link

nypinstripes commented May 17, 2018

@gkatsev thanks for the quick response, here's the generic error uglify spits out for me, after setting mangle to false & beautify to true.

    ERROR in player.js from UglifyJs
    Invalid assignment [player.js:11289,77]

this is my uglify config:

UglifyJSPlugin({
          cache: false,
          parallel: true,
          sourceMap: true,
          uglifyOptions: {
            compress: {
              join_vars: true,
              passes: 3,
              reduce_vars: true
            },
            mangle: false,
            output: {
              beautify: true,
              indent_level: 2
            },
            warnings: false
          }

the line in the output looks like:
screen shot 2018-05-17 at 4 04 54 pm

@nypinstripes
Copy link

nypinstripes commented May 17, 2018

which seems fine but perhaps the illegal assignment is on the line above,

var __WEBPACK_IMPORTED_MODULE_0_url_toolkit__ = __webpack_require__(7), __WEBPACK_IMPORTED_MODULE_0_url_toolkit___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_url_toolkit__), __WEBPACK_IMPORTED_MODULE_1_global_window__ = __webpack_require__(3), __WEBPACK_IMPORTED_MODULE_1_global_window___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_global_window__);

@nypinstripes
Copy link

@gkatsev strange but it seems like everything up to that line is transpiled to ES5 but everything afterwards is ES6. I've also just upgraded to 7.0.1.

@nypinstripes
Copy link

@gkatsev I take that back, after that line 11289 it's ES6 for a bit, then goes back to ES5 here:
screen shot 2018-05-17 at 4 22 49 pm
hope that's helpful.

@gkatsev
Copy link
Member

gkatsev commented May 17, 2018

Oh, looks like our mpd-parser in VHS isn't using babel for the es build and that's probably what's being used. I'll look into it, nice catch @nypinstripes

@nypinstripes
Copy link

np, @gkatsev after doing the webpack 4.8.3 upgrade, everything's building smoothly in UglifyJS webpack plugin with 7.0.1.

@gkatsev
Copy link
Member

gkatsev commented May 17, 2018

webpack 4 uses uglify-es, so, it can handle minifying es6 code. Going to work on fixing it on our end also.

@gkatsev
Copy link
Member

gkatsev commented May 17, 2018

Looks like mpd-parser (videojs/mpd-parser#25) already had this change just needs a release and I made a PR for VHS (videojs/http-streaming#97).

@gkatsev
Copy link
Member

gkatsev commented May 17, 2018

Both have been released, going to update vjs to latest VHS which should fix this.

gkatsev added a commit that referenced this issue May 17, 2018
Upgrade to 1.0.2 which contains babel build fixes.

Fixes #5186
gkatsev added a commit that referenced this issue May 18, 2018
Upgrade to 1.0.2 which contains babel build fixes.

Fixes #5186
@jcbreel
Copy link
Author

jcbreel commented May 22, 2018

So should I just update to latest? What version exactly? Thanks for looking at this guys.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants