From ab3195ef05699b92b8a69799e3df8d5452ce5606 Mon Sep 17 00:00:00 2001 From: August Damiani Date: Fri, 24 Mar 2023 19:07:57 -0500 Subject: [PATCH] manually patch package.json fixes rustwasm/wasm-pack#1039 --- build_wasm.sh | 27 +++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 build_wasm.sh diff --git a/build_wasm.sh b/build_wasm.sh new file mode 100755 index 00000000..6e72dbb2 --- /dev/null +++ b/build_wasm.sh @@ -0,0 +1,27 @@ +#! /bin/bash + +if !command -v js &> /dev/null +then + echo "jq command not found" + exit 127 +fi + +if !command -v wasm-pack &> /dev/null +then + echo "wasm-pack command not found" + exit 127 +fi + +if [ ! -d "./rs" ] +then + echo "could not find crate \"rs\"" + exit 2 +fi + +cd rs +wasm-pack build --target web + +tmp=$(mktemp) + +cd pkg +jq '. += { type: "module" }' package.json > "$tmp" && mv "$tmp" package.json diff --git a/package.json b/package.json index 5a749ce3..c438c504 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "vite dev", "build": "vite build", - "build:wasm": "wasm-pack build ./rs --target web", + "build:wasm": "./build_wasm.sh", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",