-
Notifications
You must be signed in to change notification settings - Fork 811
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
UglifyJs: Unexpected token: operator (>) #790
Comments
@tillkruss take a look at the exactly installed version of |
Shouldn't uglify work out of the box, since it's enabled by default in production? |
Same problem. |
@hernandev I used to have it working about a month ago too using the harmony branch. However, they've since moved it to uglify-es and now I can't get it to work, again. What exactly do you have setup at the moment? |
Running into this same problem and not having any luck fixing it. I've tried installing the harmony branch of uglifyjs and adding a .babelrc file with the es2015 preset, but nothing has worked. |
Same problem, adding .babelrc triggers new error. |
Getting the same when using a package that has |
I'm about to tag a new release that bumps the Uglify version, so I think that should fix this. |
@JeffreyWay: Still the same error using 0.12.0. |
@JeffreyWay still the same using 0.12.1
|
@JeffreyWay: Could you re-open this until it's resolved? |
Any updates? |
@balthild, all upgrading to |
@iraklisg Nope. upgraded to 1.0.7, still the same:
|
@ipa1981 When upgrading from 0.* to 1.* I had to do that to make things work. Also, check if your npm is now |
@ruchern I use yarn . no package-lock here. |
@ipa1981 Oh then your result may vary from mine. Well, you can still try to clear out the old packages and do a reinstall. Let me know if that worked. |
@ruchern Just did it. Same problem:
|
Wow. This is really weird. Who's version of |
Ok.. cleaned up everything. Just to leave bare minimum: webpack.mix.js
package.json
app.js
Running watch (OK):
Running production (fails):
|
This seemed related to your problem. It seemed like Yarn is not installing |
Have you tried the latest stable yarn release? |
@ruchern I've added uglify-js manually, but same result.
@JHabdas Yes:
|
BTW. I see that I require a |
@ipa1981 🤦♂️ sorry when I said stable I was thinking of |
Ok. it seems yarn is not relevant here, I try https://github.com/ipa1981/laravel-mix-production-test
However I found that it fails only when vue-strap component is imported from node_modules folder, and compiles well if imported from local copy: app.js
Does it help? :) |
Ah. If it's not yarn I have a present for you: https://www.npmjs.com/package/uglify-es |
|
Damn. Looks like I should learn to read good. #790 (comment). stepping out. don't actually use this module 😉 |
:) it happens. Would be glad if @JeffreyWay could look on this. |
@ipa1981 I have fixed your issue. In your Use this instead of anything else. import {utils} from "vue-strap"; |
@ruchern thanks a lot, seems this works! Not exactly as you proposed, but in original
to this
I don't know what's the difference however, but this goes to compile. |
I'm still getting errors for shorthand closures. @JeffreyWay perhaps swap from JSUglify to https://github.com/babel/babili ? Babili supports ES6 |
@ruchern Seems the solution is not good :/. Using
Is not the same as
First does not include styles and template of the component, so final code is getting broken. |
Lets try this. import {aside} from 'vue-strap'
Vue.component('sidebar', aside) Let me know if it works this way. |
@ruchern, thanks for ideas! I just tried many different things. And it seems CommonJS syntax:
finally works with latest So at the moment it looks like everything is fine - both |
@ipa1981 If you import your Vue-Strap components that way, do you not get style conflicts with regular Bootstrap checkboxes/radios, as per this issue? yuche/vue-strap#390 Maybe you don't use regular checkboxes or radio buttons, though. My issue is that I switched the import to the vue-strap/src/* path to avoid the radio button problem, but now I have this UglifyJs issue that seems to require the opposite. Very annoying. By the way, probably a dumb question, but how do you update the version of vue-loader that laravel-mix is using? I don't know if that would help in any way, but since you mention updating to 13.0.0, I thought I'd give it a shot. I see the latest laravel-mix uses 12.1.1... But just installing 13.0.0 in my own project is not going to make laravel-mix use it, is it? |
@ipa1981 Alright. Good to hear everything is working now. |
@StygianTraveler Haven't noticed this problem. Maybe I simply don't use some conflicting styles. I don't remember why I used direct require rather than generic one. Probably there was a reason, but I cannot recall why. To update a version on vue-loader simply |
note: using normalize-url with nextjs triggers this error as well |
For So for me modifying my |
My babel ES2015 preset was excluding /node_modules/ and this would end up not converting some newer modules before uglify saw the code and it choked on the arrow function like the OP title, adding node_modules back solved the issue here (Webpack)
|
Looks really similar to this issue: webpack/webpack#2972 (comment) I've fixed with that comment |
"I have the same problem when my code has the syntax class. And then I found it's my fault because I forget to write .babelrc." from webpack/webpack#2972 (comment) |
Switching to use https://webpack.js.org/plugins/terser-webpack-plugin/ instead of UglifyJS worked for me. |
When running
npm run production
I get the following error:/js/listing.js from UglifyJs Unexpected token: operator (>) [./~/bootstrap/js/src/dropdown.js:11,0][/js/listing.js:3302,23]
I've tried deleting
node_modules
without any luck, same goes for installing:Arrow function seem to be the issue, line 11 of
dropdown.js
is:I don't have a
.babelrc
file.The text was updated successfully, but these errors were encountered: