Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Upgrade to babel@7 #218

Closed
fnando opened this issue Sep 25, 2018 · 10 comments
Closed

Upgrade to babel@7 #218

fnando opened this issue Sep 25, 2018 · 10 comments

Comments

@fnando
Copy link

fnando commented Sep 25, 2018

As of right now, ledgerjs libs don't work with latest babel (v7). I think the project should be upgraded to the latest version, bumping the major version. Here's the error I'm currently having when trying to use exported files:

ERROR in ./node_modules/@ledgerhq/hw-transport/lib/Transport.js
Module not found: Error: Can't resolve 'babel-runtime/core-js/get-iterator' in 'myproject/node_modules/@ledgerhq/hw-transport/lib'
 @ ./node_modules/@ledgerhq/hw-transport/lib/Transport.js 16:20-65
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport/lib/Transport.js
Module not found: Error: Can't resolve 'babel-runtime/core-js/object/assign' in 'myproject/node_modules/@ledgerhq/hw-transport/lib'
 @ ./node_modules/@ledgerhq/hw-transport/lib/Transport.js 12:14-60
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
Module not found: Error: Can't resolve 'babel-runtime/core-js/object/get-prototype-of' in 'myproject/node_modules/@ledgerhq/hw-transport-u2f/lib'
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js 15:22-78
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport/lib/Transport.js
Module not found: Error: Can't resolve 'babel-runtime/core-js/object/keys' in 'myproject/node_modules/@ledgerhq/hw-transport/lib'
 @ ./node_modules/@ledgerhq/hw-transport/lib/Transport.js 40:12-56
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-app-str/lib/utils.js
Module not found: Error: Can't resolve 'babel-runtime/core-js/promise' in 'myproject/node_modules/@ledgerhq/hw-app-str/lib'
 @ ./node_modules/@ledgerhq/hw-app-str/lib/utils.js 7:15-55
 @ ./node_modules/@ledgerhq/hw-app-str/lib/Str.js
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
Module not found: Error: Can't resolve 'babel-runtime/core-js/promise' in 'myproject/node_modules/@ledgerhq/hw-transport-u2f/lib'
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js 7:15-55
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport/lib/Transport.js
Module not found: Error: Can't resolve 'babel-runtime/core-js/promise' in 'myproject/node_modules/@ledgerhq/hw-transport/lib'
 @ ./node_modules/@ledgerhq/hw-transport/lib/Transport.js 8:15-55
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/asyncToGenerator' in 'myproject/node_modules/@ledgerhq/hw-transport-u2f/lib'
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js 23:25-74
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport/lib/Transport.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/asyncToGenerator' in 'myproject/node_modules/@ledgerhq/hw-transport/lib'
 @ ./node_modules/@ledgerhq/hw-transport/lib/Transport.js 28:25-74
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-app-str/lib/Str.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/classCallCheck' in 'myproject/node_modules/@ledgerhq/hw-app-str/lib'
 @ ./node_modules/@ledgerhq/hw-app-str/lib/Str.js 7:23-70
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/classCallCheck' in 'myproject/node_modules/@ledgerhq/hw-transport-u2f/lib'
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js 27:23-70
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport/lib/Transport.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/classCallCheck' in 'myproject/node_modules/@ledgerhq/hw-transport/lib'
 @ ./node_modules/@ledgerhq/hw-transport/lib/Transport.js 32:23-70
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-app-str/lib/Str.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/createClass' in 'myproject/node_modules/@ledgerhq/hw-app-str/lib'
 @ ./node_modules/@ledgerhq/hw-app-str/lib/Str.js 11:20-64
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/createClass' in 'myproject/node_modules/@ledgerhq/hw-transport-u2f/lib'
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js 35:20-64
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport/lib/Transport.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/createClass' in 'myproject/node_modules/@ledgerhq/hw-transport/lib'
 @ ./node_modules/@ledgerhq/hw-transport/lib/Transport.js 36:20-64
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/inherits' in 'myproject/node_modules/@ledgerhq/hw-transport-u2f/lib'
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js 39:17-58
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/possibleConstructorReturn' in 'myproject/node_modules/@ledgerhq/hw-transport-u2f/lib'
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js 31:34-92
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport/lib/Transport.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/toConsumableArray' in 'myproject/node_modules/@ledgerhq/hw-transport/lib'
 @ ./node_modules/@ledgerhq/hw-transport/lib/Transport.js 20:26-76
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
Module not found: Error: Can't resolve 'babel-runtime/helpers/typeof' in 'myproject/node_modules/@ledgerhq/hw-transport-u2f/lib'
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js 11:15-54
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'myproject/node_modules/@ledgerhq/hw-transport-u2f/lib'
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js 19:19-55
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

ERROR in ./node_modules/@ledgerhq/hw-transport/lib/Transport.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'myproject/node_modules/@ledgerhq/hw-transport/lib'
 @ ./node_modules/@ledgerhq/hw-transport/lib/Transport.js 24:19-55
 @ ./node_modules/@ledgerhq/hw-transport-u2f/lib/TransportU2F.js
 @ ./app/frontend/scripts/components/pay_with_nano.jsx
 @ ./app/frontend/scripts/components/profile_checkout_payment.jsx
 @ ./app/frontend/scripts/components/profile_send_money.jsx
 @ ./app/frontend/scripts/routes/profile.js
 @ ./app/frontend/scripts/router.js
 @ ./app/frontend/application.jsx

That's because babel packages now use the @babel scope (e.g. @babel/runtime).

@gre
Copy link
Contributor

gre commented Oct 8, 2018

I agree on this but I wonder about backward compatibility.

If an app still uses babel 6 and we migrate to babel 7, would it be a problem too?

@fnando
Copy link
Author

fnando commented Oct 8, 2018

Well, they can keep using an older version until they upgrade to a newer babel version. The thing is that starting a new project and having to use older tooling is far from ideal (I wish I could use Ledger in a app I’m creating right now but can’t).

An alternative would be running parallel configs that spits out code compatible with both versions.

@gre
Copy link
Contributor

gre commented Oct 12, 2018

I would recommend to fork the lib on your side of you need it , we'll be careful on migrating to this. I've discussed with parceljs author recently and he suggested there could be a way to transpile code from Babel 7 back to babel 6 and apparently they used that. Worth taking a look 🧐

@fnando
Copy link
Author

fnando commented Oct 12, 2018

I tried making it work with Babel 7, but I couldn't really grasp how lerna works. I'll take another look.

@MisterTicot
Copy link

MisterTicot commented Oct 19, 2018

Actually it would be interesting to have the option to transpile the code using our own configuration. Not sure how this could be done, though.

Edit: I'm saying this cause now my bundles have duplicate regenerators runtime and promise polyfill and a few others; I'd be happy to cut some of the bloat for my webapps.

@webmaster128
Copy link
Contributor

webmaster128 commented Oct 30, 2018

I am having the same issue. But the log message above is most likely because the dependency "babel-runtime" is not a runtime dependency of each package. But hw-transport-node-hid/lib/TransportNodeHid.js for example contains code like:

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _getIterator2 = require("babel-runtime/core-js/get-iterator");

var _getIterator3 = _interopRequireDefault(_getIterator2);

var _regenerator = require("babel-runtime/regenerator");

var _regenerator2 = _interopRequireDefault(_regenerator);

var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");

var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of");

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require("babel-runtime/helpers/createClass");

[...]

I think this must go into each package.

@MisterTicot
Copy link

@webmaster128 Yes this is another issue

@nscarlson
Copy link

nscarlson commented Nov 2, 2018

I have the same problem in my next.js app. import '@babel/polyfill' is a (hideous) temporary workaround.

@harshjv
Copy link
Contributor

harshjv commented Nov 15, 2018

I've pushed a PR #241 to fix this.

I've also pushed built packages to https://www.npmjs.com/org/liquality. Feel free to use them while PR gets merged.

@gre
Copy link
Contributor

gre commented Dec 17, 2019

Fixed since v5.0.0

@gre gre closed this as completed Dec 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants