Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES modules #1380

Open
lastmjs opened this issue Apr 9, 2019 · 5 comments
Open

ES modules #1380

lastmjs opened this issue Apr 9, 2019 · 5 comments
Labels

Comments

@lastmjs
Copy link

lastmjs commented Apr 9, 2019

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

@junderw
Copy link
Member

junderw commented Apr 9, 2019

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.

@junderw
Copy link
Member

junderw commented Apr 9, 2019

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.

@lastmjs
Copy link
Author

lastmjs commented Apr 9, 2019 via email

@zone117x
Copy link

zone117x commented Apr 9, 2019

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.

@junderw
Copy link
Member

junderw commented Mar 26, 2024

This should be revisited since ES Modules have had time to cook and get more adoption.
It seems like we'd need to migrate a lot of things (like Buffer) to get full browser support though.
Supporting Web Crypto (which iirc is now supported in NodeJS) would also change a lot of the APIs to use async.

Thoughts on whether a full ESM library would be better than some sort of hybrid thing? I publish hybrid packages for tiny-secp256k1 and uint8array-tools... but a lot of bundlers still have trouble with them apparently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants