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

ERROR in bundle from UglifyJs Unexpected token: punc (,) #205

Closed
mhoofman opened this issue May 22, 2023 · 8 comments · Fixed by #216
Closed

ERROR in bundle from UglifyJs Unexpected token: punc (,) #205

mhoofman opened this issue May 22, 2023 · 8 comments · Fixed by #216

Comments

@mhoofman
Copy link

Our project's webpack build which uses UglifyJS (uglify-js) started erroring after the tslib update from 2.5.0 to 2.5.1.

Here is the error message we are seeing (I replaced the name of our bundle file w/ bundle.js):

ERROR in bundle.js from UglifyJs
Unexpected token: punc (,) [./~/tslib/tslib.es6.js:296,0][bundle.js:218700,13]

Here are the package versions used that create this build error:

  • webpack 2.7.0
  • uglify-js 2.8.29
  • tslib >=2.5.1
  • cheerio 1.0.0-rc.10 (depends on tslib ^2.2.0)
  • file-selector 0.1.19 (depends on tslib ^2.0.1)

We rolled back tslib to version 2.5.0 to fix our builds.

Can this older version of uglify-js be supported or should we work towards updating our package dependencies?

@jakebailey
Copy link
Member

Seems like we wrote an object literal like { foo } but should have written { foo: foo }. @andrewbranch

Though, you must be using something truly ancient to not have that syntax... Webpack v2 I guess shows that just be the case. I'm surprised you don't see breaks somewhere else!

@jakebailey
Copy link
Member

Per #206 (comment), this is exceptionally strange given export default was introduced in the same ECMAScript revision as the object literal shorthand, so a tool not doing both is very, very odd.

@andrewbranch
Copy link
Member

should we work towards updating our package dependencies

Yes 😄

@mhoofman
Copy link
Author

should we work towards updating our package dependencies

Yes 😄

Thanks for looking into this! I guess its time for us to move out of ancient history.

@andrewbranch
Copy link
Member

Note that there should be other workarounds available to you, like

  • pin your version of tslib
  • override Webpack’s resolution of tslib to get tslib.js instead of tslib.es6.js
  • Run babel-loader or something on tslib.es6.js before Uglify sees it

@simeiyu
Copy link

simeiyu commented May 25, 2023

ERROR in static/js/index.js from UglifyJs
Unexpected token: punc (,) [./node_modules/_tslib@2.5.2@tslib/tslib.es6.js:296,0][static/js/index.js:140813,13]

@taurheim
Copy link

I am running into this issue, but not related to UglifyJs, instead when trying to use webpack with typescript with an es5 target.

I have a minimum repro here: https://github.com/taurheim/webpack-typescript-es5-demo

@andrewbranch would appreciate your insights here, this might not be a tslib problem directly but it only broke with the new tslib version. Thanks!

@andrewbranch
Copy link
Member

This all seems like everyone else’s bugs, not ours, but I guess we can just delete the offending syntax 🥴

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