cosmicjs / cosmicjs-node

*API v2 JavaScript client for Cosmic. See important message in README
https://www.cosmicjs.com
MIT License
274 stars 38 forks source link

Failed to minify code #19

Closed ghost closed 6 years ago

ghost commented 6 years ago

I'm using cosmicjs in a big React app created with create-react-app and I cannot build the project via npm run build without receiving this error:

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

    ./node_modules/cosmicjs/index.js:6 

Read more here: http://bit.ly/2tRViJ9

Now as the helpful link suggest this means the file is not pre-compiled and that seems to be true, so could you please publish the next version precompiled (if that is indeed the issue here)?

Also, is there anything I can do as a workaround, so that I can import coscmisjs and build the app like I can with any other npm module now? The build happens via CI, so precompiling it manually makes the whole thing more brittle than it should anyway.

I'm open for suggestions. Maybe I'm just doing something wrong myself.

ghost commented 6 years ago

I've just copied the index.js file from the project folder into my projects lib folder and imported it from there. That works, but it's a pretty ugly, hacky solution. I'd appreciate feedback from you, because quite frankly I don't quite understand why importing it from node_modules, as usual, won't work right away.

tonyspiro commented 6 years ago

Hey @odiumediae, I wasn't able to reproduce the issue. Have you tried removing your node_modules folder and running npm install again? What version on node are you running?

ghost commented 6 years ago

Yes, I have. I wouldn't waste anybody's time without at least trying the most obvious possibilities ;)

I've also updated all dependencies (including react-scripts, which seems to report the error, but cannot really be the culprit here, at least I wouldn't know how) and I've tried different older versions of cosmicjs, but the problem persists as long as I don't import the module from within my own project.

It also makes no difference, whether I use import or require.

ghost commented 6 years ago

I'm running Node v9.11.1, but before that I was still running v9.8.0 and it didn't work either.

tonyspiro commented 6 years ago

@odiumediae can you please test with the latest version? I believe this issue is now fixed.

tonyspiro commented 6 years ago

Just tested this and looks to be fixed. Thanks for the heads up @odiumediae!