Files
Jake Teton-LandisandGitHub d50fce7fbe Cloudflare worker support (#133)
* working wrangler demo

* improve worker example code quality

* add helpers for cloudflare support

* document cloudflare, deno, esmodule

* deno smoketest file

* doc cleanup

* expand loader docs

* test minimal example in CI

* rebuild docs

* document minimal size
2023-12-29 18:38:05 +00:00

26 lines
828 B
Bash
Executable File

#!/usr/bin/env bash
#
# quickjs-emscripten exposes an export for the .wasm file, but Cloudflare refuses to accept it.
# Cloudflare's build system only allows importing .wasm files using a relative path.
# Github issue: https://github.com/cloudflare/workers-sdk/issues/1672
#
# Instead the easy way out is to just copy the .wasm files we need into the build directory.
# Once there, we can import them and use them to make a new quickjs variant.
#
set -eo pipefail
VARIANTS=(
DEBUG_SYNC
RELEASE_SYNC
)
for VARIANT in "${VARIANTS[@]}"; do
kebab="$(echo "$VARIANT" | tr '[:upper:]' '[:lower:]' | tr '_' '-')"
WASM_FILE="$(node -p 'require.resolve("@jitl/quickjs-wasmfile-'$kebab'/wasm")')"
cp -v "$WASM_FILE" src/$VARIANT.wasm
if [[ -f "$WASM_FILE.map" ]]; then
cp -v "$WASM_FILE.map" src/$VARIANT.wasm.map.txt
fi
done