ci: script to patch imports in the tlsn-wasm build result (#727)

This commit is contained in:
Hendrik Eeckhaut
2025-03-20 21:47:47 +01:00
committed by GitHub
parent 190b7b0bf6
commit eeccbef909

View File

@@ -11,3 +11,20 @@ rm -rf pkg
# Build tlsn_wasm package
wasm-pack build --target web .
# Patch tlsn_wasm.js import in spawn.js snippet and copy it to the main folder
file=$(find ./pkg/snippets -name "spawn.js" -print -quit)
if [ -z "$file" ]; then
echo "Error: spawn.js snippet not found"
find pkg
exit 1
fi
temp=$(mktemp)
sed 's|../../..|../../../tlsn_wasm.js|' "$file" >"$temp" && mv "$temp" "$file"
cp ${file} ./pkg
# Add all files and snippets directory to package.json
file="pkg/package.json"
temp=$(mktemp)
jq '.files += ["tlsn_wasm_bg.wasm.d.ts"]' "$file" >"$temp" && mv "$temp" "$file"
jq '.files += ["spawn.js"]' "$file" >"$temp" && mv "$temp" "$file"
jq '.files += ["snippets/"]' "$file" >"$temp" && mv "$temp" "$file"