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 : ionc build ios or android, uglifyjs failed: SyntaxError: Unexpected token: operator (>) #8817

Closed
tianleios opened this issue Oct 20, 2016 · 8 comments
Labels
needs: reply the issue needs a response from the user

Comments

@tianleios
Copy link

when i run ionic build ios. will display fllow errror,uglifyjs cannot support es6 feature arrow function
] ngc finished in 32.81 s
[19:52:49] bundle started ...
[19:53:01] bundle finished in 12.33 s
[19:53:01] uglifyjs started ...
[19:53:01] sass started ...
[19:53:02] uglifyjs failed: SyntaxError: Unexpected token: operator (>)
[19:53:02] ionic-app-script task: "build"
[19:53:02] Error: SyntaxError: Unexpected token: operator (>)

@jgw96
Copy link
Contributor

jgw96 commented Oct 20, 2016

Hello, thanks for opening an issue with us! uglifyJS does support arrow functions. Are you using the correct syntax for arrow functions? setTimeout(() => {});

@jgw96 jgw96 added needs: reply the issue needs a response from the user v2 labels Oct 20, 2016
@haxpor
Copy link

haxpor commented Oct 20, 2016

@jgw96 it happens the same for me with uglifyjs failed: SyntaxError: Unexpected token: operator (>). For my case, it's due to one of node modules I imported has es6 code, specifically arrow function. I tried not to import that module, and it passes, no error but not the other way around.

It seems uglifyJS has es6 support but in another branch harmony, once I tried hooking it up with gulp but failed. I don't know how to do it properly though.

Is it the case? If not, how to make this works with ionic 2.

Updated: I solved the problem now. As @jgw96 said that uglifyJS already supports es6, I just changed node_modules/@ionic/app-scripts/package.json file for uglify-js to git+https://github.com/mishoo/UglifyJS2.git#harmony. Then it automatically solves the problem. I now can build without error. For study, I will take a look at its code later on how the team did this as I failed before. Thanks.

@tianleios
Copy link
Author

@haxpor can you display you resolve function detail

@tianleios
Copy link
Author

@jgw96 i confirm i use correct arrow function

@haxpor
Copy link

haxpor commented Oct 22, 2016

@tianleios On your root project directory, edit node_modules/@ionic/app-scripts/package.json file. Then in that file update uglify-js like this "uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony".

Then after that execute npm install (make sure right now you're at node_modules/@ionic/app-scripts. Ignore error that shown. I have shown error about jasmine's build for path variable that it seems like it need src, but it works at the end.

@zhang-z
Copy link

zhang-z commented Oct 23, 2016

@haxpor , the 'harmony' solution is working, thank you!

@jgw96
Copy link
Contributor

jgw96 commented Oct 25, 2016

This issue was moved to ionic-team/ionic-app-scripts#239

@jgw96 jgw96 closed this as completed Oct 25, 2016
@jgw96
Copy link
Contributor

jgw96 commented Oct 25, 2016

Hello, thanks for using Ionic! Since this is a build issue i have moved this issue to the app-scripts repo.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: reply the issue needs a response from the user
Projects
None yet
Development

No branches or pull requests

4 participants