libsodium.js icon indicating copy to clipboard operation
libsodium.js copied to clipboard

ESM support

Open masonicboom opened this issue 8 months ago • 9 comments

Here's a proof-of-concept of an ES Modules build.

I haven't tested if this achieves any sort of file-size reduction through tree-shaking. I'm just doing this to facilitate use in the Deno runtime (https://deno.com).

To test, with Deno installed:

  1. Checkout this code
  2. Copy emscripten.sh from https://github.com/jedisct1/libsodium/pull/1382 to libsodium/dist-build/emscripten.sh
  3. make esm
  4. deno
  5. > import sodium from "./dist/modules/libsodium-esm-wrappers.js"
  6. > await sodium.ready
  7. > sodium.crypto_secretbox_keygen()

Any feedback on the approach so far? If not, I'll just plan to add Make targets for the sumo builds and get the automated tests running against this (I think there are some—haven't looked deeply).

masonicboom avatar Jun 12 '24 19:06 masonicboom