diff --git a/build-emscripten.sh b/build-emscripten.sh
index f53d93b6828..dbc9c9a599d 100755
--- a/build-emscripten.sh
+++ b/build-emscripten.sh
@@ -122,6 +122,8 @@ if [ "$DEBUG" = "1" ]; then
fi
emcc -Wl,--whole-archive "$LIBHEIFA" -Wl,--no-whole-archive \
+ -sMODULARIZE=1 \
+ -sEXPORT_NAME="libheif" \
-sWASM_ASYNC_COMPILATION=0 \
-sALLOW_MEMORY_GROWTH \
--memory-init-file 0 \
diff --git a/examples/demo.html b/examples/demo.html
index beb200346b9..1c6f8275a7b 100644
--- a/examples/demo.html
+++ b/examples/demo.html
@@ -191,6 +191,8 @@
libheif decoder demo
}.bind(this));
this.drawer = new CanvasDrawer(canvas);
this.decoder = new libheif.HeifDecoder();
+
+ console.log("Using libheif", libheif.heif_get_version());
saveSupported = this.canvas.toBlob &&
((URL && URL.createObjectURL) || navigator.msSaveOrOpenBlob);
if (saveSupported) {
@@ -313,8 +315,7 @@ libheif decoder demo
return;
}
- console.log("Using libheif", libheif.heif_get_version());
- var demo = new HeifDemo(libheif);
+ var demo = new HeifDemo(libheif());
show("form");
diff --git a/scripts/test-javascript.js b/scripts/test-javascript.js
index d556a639ba5..0f70d87d975 100644
--- a/scripts/test-javascript.js
+++ b/scripts/test-javascript.js
@@ -22,7 +22,7 @@
console.log("Running libheif JavaScript tests ...");
- var libheif = require('../libheif.js');
+ var libheif = require('../libheif.js')();
console.log("Loaded libheif.js", libheif.heif_get_version());
// Decode the example file and make sure at least one image is returned.