T44d Web · What a browser cannot do says why; fonts resolve; the bundle builds
Demos that open a second window, take files, move the window, read the clipboard or set native menus show a note on the web in the blocked style. IBM Plex Sans Regular joins the assets, unmodified, where gpui's svg renderer loads it: gpui_web answers .SystemUIFont with it. The gallery's web entry registers a Hebrew cut of Noto Sans Hebrew. scripts/web.sh builds the bundle with wasm-bindgen and wasm-opt -Oz, 20.0 MB, and fails past 25 MiB.
This commit is contained in:
26 files changed
+381
-76
No files matched your search
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Builds the browser gallery into <out>; ELY_GALLERY_ASSETS is the address of <out>/assets/.
|
||||
set -eu
|
||||
out=$(mkdir -p "${1:?usage: scripts/web.sh <out dir>}" && cd "$1" && pwd)
|
||||
: "${ELY_GALLERY_ASSETS:?set ELY_GALLERY_ASSETS to the address of <out>/assets/, ending in /}"
|
||||
cd "$(dirname "$0")/.."
|
||||
version=$(sed -n '/^name = "wasm-bindgen"$/{n;s/^version = "\(.*\)"$/\1/p;}' Cargo.lock)
|
||||
wasm-bindgen --version | grep -qx "wasm-bindgen $version" || {
|
||||
echo "wasm-bindgen $version needed: cargo install wasm-bindgen-cli --version $version --locked" >&2
|
||||
exit 1
|
||||
}
|
||||
command -v wasm-opt >/dev/null || { echo "wasm-opt needed: brew install binaryen, or npm i -g binaryen" >&2; exit 1; }
|
||||
# gpui_web's wasm_thread asks for an unstable feature even single-threaded, as Zed's own web build does.
|
||||
RUSTC_BOOTSTRAP=1 cargo build --example gallery --target wasm32-unknown-unknown --profile web
|
||||
wasm="${CARGO_TARGET_DIR:-target}/wasm32-unknown-unknown/web/examples/gallery.wasm"
|
||||
wasm-bindgen "$wasm" --out-dir "$out" --out-name gallery --target web --no-typescript \
|
||||
--remove-name-section --remove-producers-section
|
||||
# Cloudflare serves no file over 25 MiB; -Oz takes a seventh off, though not off the gzip.
|
||||
wasm-opt -Oz --enable-bulk-memory --enable-nontrapping-float-to-int --enable-sign-ext \
|
||||
--enable-mutable-globals --enable-reference-types --enable-multivalue \
|
||||
"$out/gallery_bg.wasm" -o "$out/gallery_bg.wasm"
|
||||
cp examples/gallery/index.html "$out/"
|
||||
rm -rf "$out/assets"
|
||||
cp -R examples/gallery/assets "$out/assets"
|
||||
size=$(wc -c < "$out/gallery_bg.wasm" | tr -d ' ')
|
||||
[ "$size" -le 26214400 ] || { echo "gallery_bg.wasm is $size bytes, over Cloudflare's 25 MiB" >&2; exit 1; }
|
||||
echo "gallery_bg.wasm: $size bytes"
|
||||
Reference in new issue
Block a user