Repository: ergoplatform/sigma-rust (language: rust)

Issue:
Look into enabling TC39 weak references support in wasm-bindgen
https://rustwasm.github.io/wasm-bindgen/reference/weak-references.html

To avoid manual `.free()` calls to free memory.


Discussion / hints:

Fix patch:
diff --git a/bindings/ergo-lib-wasm/package.json b/bindings/ergo-lib-wasm/package.json
index 2aa8daccd..a3053bfea 100644
--- a/bindings/ergo-lib-wasm/package.json
+++ b/bindings/ergo-lib-wasm/package.json
@@ -4,14 +4,14 @@
     "browser": "./index.browser.js",
     "scripts": {
         "build": "webpack",
-        "serve": "wasm-pack build --target browser && webpack-dev-server",
-        "test": "wasm-pack build --target nodejs && mocha --require @babel/register --require @babel/polyfill 'tests/test*.js'",
+        "serve": "cross-env WASM_BINDGEN_WEAKREF=1 wasm-pack build --target browser && webpack-dev-server",
+        "test": "cross-env WASM_BINDGEN_WEAKREF=1 wasm-pack build --target nodejs && mocha --require @babel/register --require @babel/polyfill 'tests/test*.js'",
         "test-browser": "rm -rf ./pkg && npm run build-browser && mv ./pkg-browser ./pkg && ./node_modules/.bin/karma start",
         "doc": "jsdoc -c jsdoc.json pkg/ergo_wallet_wasm.js README.md -d docs",
-        "build-nodejs": "rm -rf ./pkg-nodejs && wasm-pack build --target nodejs --out-dir pkg-nodejs && cd pkg-nodejs && node ../scripts/publish_helper -nodejs",
-        "build-nodejs-alpha": "rm -rf ./pkg-nodejs && wasm-pack build --target nodejs --out-dir pkg-nodejs && cd pkg-nodejs && node ../scripts/publish_helper -nodejs && npm version minor && node ../scripts/set_alpha_version -nodejs $(git rev-parse --short HEAD)",
-        "build-browser": "rm -rf ./pkg-browser && wasm-pack build --target browser --out-dir pkg-browser --features rest && cd pkg-browser && node ../scripts/publish_helper -browser && node ../scripts/set_exports",
-        "build-browser-alpha": "rm -rf ./pkg-browser && wasm-pack build --target browser --out-dir pkg-browser --features rest && cd pkg-browser && node ../scripts/publish_helper -browser && node ../scripts/set_exports && npm version minor && node ../scripts/set_alpha_version -browser $(git rev-parse --short HEAD)",
+        "build-nodejs": "rm -rf ./pkg-nodejs && cross-env WASM_BINDGEN_WEAKREF=1 wasm-pack build --target nodejs --out-dir pkg-nodejs && cd pkg-nodejs && node ../scripts/publish_helper -nodejs",
+        "build-nodejs-alpha": "rm -rf ./pkg-nodejs && cross-env WASM_BINDGEN_WEAKREF=1 wasm-pack build --target nodejs --out-dir pkg-nodejs && cd pkg-nodejs && node ../scripts/publish_helper -nodejs && npm version minor && node ../scripts/set_alpha_version -nodejs $(git rev-parse --short HEAD)",
+        "build-browser": "rm -rf ./pkg-browser && cross-env WASM_BINDGEN_WEAKREF=1 wasm-pack build --target browser --out-dir pkg-browser --features rest && cd pkg-browser && node ../scripts/publish_helper -browser && node ../scripts/set_exports",
+        "build-browser-alpha": "rm -rf ./pkg-browser && cross-env WASM_BINDGEN_WEAKREF=1 wasm-pack build --target browser --out-dir pkg-browser --features rest && cd pkg-browser && node ../scripts/publish_helper -browser && node ../scripts/set_exports && npm version minor && node ../scripts/set_alpha_version -browser $(git rev-parse --short HEAD)",
         "publish-nodejs": "npm run build-nodejs &&  cd pkg-nodejs && npm publish",
         "publish-browser": "npm run build-browser && cd pkg-browser && npm publish"
     },
@@ -24,6 +24,7 @@
         "babel-cli": "^6.26.0",
         "babel-loader": "^8.2.3",
         "chai": "^4.2.0",
+        "cross-env": "^7.0.3",
         "jsdoc": "~3.6.3",
         "karma": "^6.3.13",
         "karma-chai": "^0.1.0",


Test patch: