tweetnacl-js
tweetnacl-js copied to clipboard
ES6 modules
What's the minimal amount of changes needed to support ES6 module-style export?
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
@dchest any progress on this issue?
@evbogue not yet, sorry. I hope to work on it some time soon though.
@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.
@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 thank you! I’ll try to get some time to work on it this weekend.
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.
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
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).