From f2426e6097c058ad151889fe1c9a24beb5598337 Mon Sep 17 00:00:00 2001 From: Mason <86958+masonicboom@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:11:12 -0700 Subject: [PATCH 1/5] ESM build --- Makefile | 19 +- wrapper/build-wrappers.js | 15 +- wrapper/wrap-esm-template.js | 64 +++++ wrapper/wrap-template.js | 536 +---------------------------------- wrapper/wrap-utils.js | 535 ++++++++++++++++++++++++++++++++++ 5 files changed, 627 insertions(+), 542 deletions(-) create mode 100644 wrapper/wrap-esm-template.js create mode 100644 wrapper/wrap-utils.js diff --git a/Makefile b/Makefile index 857c68e0..e07dbfb0 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,8 @@ all: pack @echo ================= @ls -l $(MODULES_SUMO_DIR)/ +esm: $(MODULES_DIR)/libsodium.esm.js $(MODULES_DIR)/libsodium-esm-wrappers.js + @echo + Building standard ESM distribution standard: $(MODULES_DIR)/libsodium.js $(MODULES_DIR)/libsodium-wrappers.js @echo + Building standard distribution @@ -47,12 +49,22 @@ pack: targets $(MODULES_DIR)/libsodium-wrappers.js: wrapper/build-wrappers.js wrapper/build-doc.js wrapper/wrap-template.js @echo +++ Building standard/libsodium-wrappers.js mkdir -p $(MODULES_DIR) - $(NODE) wrapper/build-wrappers.js libsodium API.md $(MODULES_DIR)/libsodium-wrappers.js + $(NODE) wrapper/build-wrappers.js libsodium API.md $(MODULES_DIR)/libsodium-wrappers.js wrap-template.js + +$(MODULES_DIR)/libsodium-esm-wrappers.js: wrapper/build-wrappers.js wrapper/build-doc.js wrapper/wrap-esm-template.js + @echo +++ Building standard/libsodium-wrappers.js + mkdir -p $(MODULES_DIR) + $(NODE) wrapper/build-wrappers.js libsodium API.md $(MODULES_DIR)/libsodium-esm-wrappers.js wrap-esm-template.js $(MODULES_SUMO_DIR)/libsodium-wrappers.js: wrapper/build-wrappers.js wrapper/build-doc.js wrapper/wrap-template.js @echo +++ Building sumo/libsodium-wrappers.js mkdir -p $(MODULES_SUMO_DIR) - $(NODE) wrapper/build-wrappers.js libsodium-sumo API_sumo.md $(MODULES_SUMO_DIR)/libsodium-wrappers.js + $(NODE) wrapper/build-wrappers.js libsodium-sumo API_sumo.md $(MODULES_SUMO_DIR)/libsodium-wrappers.js wrap-template.js + +$(MODULES_DIR)/libsodium.esm.js: wrapper/libsodium-pre.js wrapper/libsodium-post.js $(MODULES_DIR)/libsodium-wrappers.js $(LIBSODIUM_JS_DIR)/lib/libsodium.js + @echo +++ Building standard/libsodium ESM + mkdir -p $(MODULES_DIR) + cp $(LIBSODIUM_JS_DIR)/lib/libsodium.esm.js $(MODULES_DIR)/libsodium.esm.js $(MODULES_DIR)/libsodium.js: wrapper/libsodium-pre.js wrapper/libsodium-post.js $(MODULES_DIR)/libsodium-wrappers.js $(LIBSODIUM_JS_DIR)/lib/libsodium.js @echo +++ Building standard/libsodium @@ -78,6 +90,9 @@ $(LIBSODIUM_DIR)/test/default/browser/sodium_core.html: $(LIBSODIUM_DIR)/configu $(LIBSODIUM_JS_DIR)/lib/libsodium.js: $(LIBSODIUM_DIR)/configure cd $(LIBSODIUM_DIR) && env CPPFLAGS="-DFAVOR_PERFORMANCE" ./dist-build/emscripten.sh --standard +$(LIBSODIUM_JS_DIR)/lib/libsodium.esm.js: $(LIBSODIUM_DIR)/configure + cd $(LIBSODIUM_DIR) && env CPPFLAGS="-DFAVOR_PERFORMANCE" ./dist-build/emscripten.sh --standard + $(LIBSODIUM_JS_SUMO_DIR)/lib/libsodium.js: $(LIBSODIUM_DIR)/configure cd $(LIBSODIUM_DIR) && env CPPFLAGS="-DFAVOR_PERFORMANCE" ./dist-build/emscripten.sh --sumo diff --git a/wrapper/build-wrappers.js b/wrapper/build-wrappers.js index 3c5bf67b..d5928339 100644 --- a/wrapper/build-wrappers.js +++ b/wrapper/build-wrappers.js @@ -4,15 +4,16 @@ var docBuilder = require("./build-doc"); //Parse arguments const argv = process.argv; -if (argv.length != 5) { +if (argv.length !== 6) { console.error( - "Usage: build-wrappers.js " + "Usage: build-wrappers.js