ccxt: Library won't bundle together with react-scripts (create-react-app, webpack, uglify)
When trying to generate production bundle for react app generated with create-react-app the library causes error:
react-scripts build
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file:
./node_modules/ccxt/js/base/errors.js:36
Read more here: http://bit.ly/2tRViJ9
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "build-js" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
CRA team refers to this issue: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify
Some third-party packages don’t compile their code to ES5 before publishing to npm. This often causes problems in the ecosystem because neither browsers (except for most modern versions) nor some tools currently support all ES6 features. We recommend to publish code on npm as ES5 at least for a few more years.
- OS: Mac OS X 10.13.2 (High Sierra)
- Programming Language version: Javascript, Node JS 8.9.4,
- React scripts:
1.1.0 - CCXT version:
^1.10.1116 - Exchange: any?
- Method:
/node_modules/ccxt/js/base/errors.js
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 24 (9 by maintainers)
@jmparsons Just giving this a friendly bump. I know I’ve seen at 4 or 5 support tickets regarding this issue, so I’m sure your updates would help a number of different projects 😃. Let me know if there’s anything you need / any way to help!
This message itself is a few years old %))))
Basically all modern JS environments, all browsers and common Node versions are ES6-compliant (mostly), nowadays. So, that recommendation itself is outdated now. And there’s no reason to continue supporting the ES5 and those frameworks that can’t compile both ES5+ES6 – that will motivate them to finally switch to ES6 in the best interest of all mankind. )
A partial solution to it is covered here:
Let us know if it does not answer your question.
@kroitor I had came across an es6 project with a very nice setup, but I haven’t been able to find it again - es6 compatible wrappers for imports.
Most times I see rollup - https://github.com/rollup/rollup/wiki/pkg.module - used to point to es6 based modules.
I’ll keep an eye out for the library written in just es6 and overcame the issues. I’m thinking it’s exactly what you’re looking for, but I can’t find it in my history.
@kroitor I’ve added a PR https://github.com/ccxt/ccxt/pull/3140. I cherry picked from my local build, so hopefully everything works. It just requires a
build:distbefore being published to npm.@colbycornish I’ll have a PR tomorrow. Need to test the dist, so it won’t pollute code base. A proxy is still required from what I’ve experienced.
@colbycornish I got it working and will make a pull request soon, been real busy with work.
@kroitor Hey I’m new to this package and don’t know if it used to be compatible with ES5 and was removed on purpose. I forked it and got it working:
https://github.com/jmparsons/ccxt
And tested it with a scoped package:
https://www.npmjs.com/package/@jmparsons/ccxt
What’s the proposed solution exactly? I don’t personally want to eject my create react app. I can, but then I’d have to modify webpack and if I’m doing that I might as well do parcel or something. Without the ES5, I have to do serious plumbing to get it to work. Should I just fork and build a dist folder?
I’ve looked at all those issues and tried to re-apply them using react-app-rewired and react-app-rewire-babel-loader no dice yet. It isn’t so much as getting it working locally - it works fine, but deploying anywhere in a node environment it fails.
I would not mind rewiring it if there were instructions, but so far everything I’ve seen does not work.
I’m closing it until we have a follow-up, if you don’t mind. Feel free to reopen it if needed, or just ask questions, if you still have them. Thx!