Bitcoinjs-lib: Use ES6 classes

Created on 22 May 2018  路  6Comments  路  Source: bitcoinjs/bitcoinjs-lib

Just a thought.

refactor

Most helpful comment

It has more traction on the frontend js than Nodejs. I think most node projects are still using require but on the frontend import/export has lots more traction. Especially in React dev.

All 6 comments

It does seem that the JS ecosystem is moving towards using the class syntax over prototype syntax. React being one example.

As pointed out by @rbndg in https://github.com/bitcoinjs/bitcoinjs-lib/issues/1069#issuecomment-389095993

Prefer the ES6 get/set syntax if possible.

module.exports = class Foo {
  constructor () {}
  get foo () { return 1 }
  set foo () {}
  static boo () { return 2 }
}

We don't need to be ubiquitous in this roll-out... and provided the breaking changes are in 4.0.0, I don't mind if we use either syntax before then.

What about ES6 import/exports? How are people going these days with that?
I use babel on my modules so it is ok... But, it was a horror to set up.

It has more traction on the frontend js than Nodejs. I think most node projects are still using require but on the frontend import/export has lots more traction. Especially in React dev.

I think this feature is out until Node supports it (if ever).
We don't want to rollup.

edit: that was RE import/export, not ES6 classes, my bad - reopened

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

hoshsadiq picture hoshsadiq  路  3Comments

panpan2 picture panpan2  路  3Comments

LeonYanghaha picture LeonYanghaha  路  3Comments

thrastarson picture thrastarson  路  3Comments