Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

companion.js GulpUglifyError: unable to minify JavaScript

ANSWERED

Hello,

 

currently, I am trying to create an npm module and I already have published it here. Actually, the function works. But when I try to import it, I do always get the same error:

 

[error][build] companion.js GulpUglifyError: unable to minify JavaScript

I have imported the file in that way:

 

import requestGraphQL from "graphql-fitbit";

Now when I call the function I will get the error above:

 

requestGraphQL(graphql_url, query).then(data => console.log(data));

I know that maybe my code is stupid for just that case, but I want to understand how to use NPM modules in Fitbit projects. 

 

Thank you for your help in advance.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

I think you can't use ES6 syntax in modules, but I think David worked around that by importing the fitbit-sdk into his project. See https://www.npmjs.com/package/fitbit-asap

View best answer in original post

Best Answer
3 REPLIES 3

I think you can't use ES6 syntax in modules, but I think David worked around that by importing the fitbit-sdk into his project. See https://www.npmjs.com/package/fitbit-asap

Best Answer

Thanks Jon,

I found out what the problem actually was. The GulpUglify minimizer does not support async functions with an awaiting return. So I switched to traditional callbacks and it worked. Probably all the ES6 syntax does not work, unfortunately.

Best Answer
0 Votes

You'll want to use something like TypeScript or Babel to transpile your module before publishing.

 

You can find a Babel example here: https://github.com/gregoiresage/fitfont/blob/develop/package.json#L4-L15

The example Jon mentioned uses TypeScript here: https://github.com/dillpixel/fitbit-asap/blob/master/package.json#L22

Best Answer
0 Votes