tweetnacl-js icon indicating copy to clipboard operation
tweetnacl-js copied to clipboard

ES6 modules

Open dchest opened this issue 5 years ago • 9 comments

What's the minimal amount of changes needed to support ES6 module-style export?

dchest avatar Aug 10 '19 07:08 dchest

I have published a NPM package that is a modification of this to only handle es6 https://www.npmjs.com/package/tweetnacl-es6 https://github.com/hakanols/tweetnacl-es6

hakanols avatar Apr 15 '20 17:04 hakanols

@dchest any progress on this issue?

evbogue avatar May 15 '20 14:05 evbogue

@evbogue not yet, sorry. I hope to work on it some time soon though.

dchest avatar May 15 '20 14:05 dchest

@dchest cool. I got @hakanols 's fork working in Deno just a moment ago.

But, I'd want to use this library in the future, if possible.

evbogue avatar May 15 '20 14:05 evbogue

@dchest would love to see this one pushed through. Am willing to help, so if there is anything I can do please let me know

roopakv avatar Jun 03 '20 20:06 roopakv

@roopakv thank you! I’ll try to get some time to work on it this weekend.

dchest avatar Jun 03 '20 21:06 dchest

If you end up tackling this, it would be great to also get https://github.com/dchest/nacl-stream-js with native esm exports. Happy to help out there once you set an example of how you want this tackled.

If you are sticking with using npm for publishing native semantically versioned esm, unpkg in ?module mode can provide browser and deno compatibility.

bcomnes avatar Apr 01 '21 15:04 bcomnes

FYI, we've published an interim module similar to @hakanols except supporting dual imports (using the exports field in packag.json):

https://www.npmjs.com/package/@dashkite/tweetnacl
https://github.com/dashkite/tweetnacl-js

dyoder avatar Aug 05 '21 01:08 dyoder

Check out my fork https://github.com/bmdelacruz/tweetnacl-js/commit/5c4460f83dece9ff03071b252f15c35f11c2636b!

It's completely tested and (somewhat) backwards compatible. The only breaking change is that consumers now need to call one of the new functions called setPRNG, setGlobalCryptoPRNG, and setNodeCryptoPRNG when using functions that depends on the PRNG, e.g. nacl.sign.keyPair and nacl.box.keyPair. The resulting nacl-fast.min.js is now slightly larger though (31.4 KB -> 36.4 KB). nacl.min.js too: (18 KB -> 18.6 KB).

bmdelacruz avatar Jun 22 '22 19:06 bmdelacruz