Bitcoinjs-lib: ES modules

Created on 9 Apr 2019  Â·  4Comments  Â·  Source: bitcoinjs/bitcoinjs-lib

It would be great if the library could support ES modules. It would be nice to use an ES module build directly in the browser without a bundler, or use the TypeScript code directly. The use of requires in the source code precludes this

Most helpful comment

package.json has a de facto standard module field that when specified is used by most common web bundler tools (like webpack, rollup, browserify w/ a plugin, etc).

This allows the npm package to add a new directory next to src that contains the ES module js files, and a corresponding entry in package.json (for example: "module": "./module/index.js").

The existing src output and "main": "./src/index.js" entry can be left as is, and regular Node projects will be unaffected.

All 4 comments

Pull requests are welcome.

If you can get rid of the requires and support ES modules I wouldn't see why that wouldn't be a good thing.

Currently it's not really on any of our radars. Could you maybe explain what the use case is a little bit more?

Thanks.

Asking a friend, he recommended we wait for NodeJS to support ES modules.

Since a lot of our dependencies are NodeJS and don't have typescript support, it is difficult at this time.

Sounds reasonable, thanks!

On Tue, Apr 9, 2019, 3:24 AM Jonathan Underwood notifications@github.com
wrote:

Asking a friend, he recommended we wait for NodeJS to support ES modules.

Since a lot of our dependencies are NodeJS and don't have typescript
support, it is difficult at this time.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/bitcoinjs/bitcoinjs-lib/issues/1380#issuecomment-481174005,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGrSjyxpQM_hggHXXfjddIjZzOZE-zQGks5vfFxBgaJpZM4cjmCG
.

package.json has a de facto standard module field that when specified is used by most common web bundler tools (like webpack, rollup, browserify w/ a plugin, etc).

This allows the npm package to add a new directory next to src that contains the ES module js files, and a corresponding entry in package.json (for example: "module": "./module/index.js").

The existing src output and "main": "./src/index.js" entry can be left as is, and regular Node projects will be unaffected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tuyennvtb picture tuyennvtb  Â·  3Comments

yakitorifoodie picture yakitorifoodie  Â·  3Comments

Mr-Mondragon picture Mr-Mondragon  Â·  3Comments

prahaladbelavadi picture prahaladbelavadi  Â·  3Comments

namnv04 picture namnv04  Â·  3Comments