Fix: boids and password_strength deployment (#2695)

* fix: boids and password_strength deployment

also adds a compile failure when examples have unresolved symbols

* add caution notice to website
This commit is contained in:
WorldSEnder 2022-05-21 05:38:18 +02:00 committed by GitHub
parent 0fa83e7dd1
commit a6df894f21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 4 deletions

View File

@ -2,8 +2,9 @@
# yew $ ./ci/build-examples.sh # yew $ ./ci/build-examples.sh
output="$(pwd)/dist" output="$(pwd)/dist"
mkdir "$output" mkdir -p "$output"
failure=false
for path in examples/*; do for path in examples/*; do
if [[ ! -d $path ]]; then if [[ ! -d $path ]]; then
continue continue
@ -16,13 +17,32 @@ for path in examples/*; do
continue continue
fi fi
echo "building: $example" echo "::group::Building $example"
( if ! (
set -e
# we are sure that $path exists # we are sure that $path exists
# shellcheck disable=SC2164 # shellcheck disable=SC2164
cd "$path" cd "$path"
dist_dir="$output/$example" dist_dir="$output/$example"
if [[ "$example" == "boids" || "$example" == "password_strength" ]]; then
# works around issue rust-lang/rust#96486
# where the compiler forgets to link some symbols connected to const_eval
# only an issue on nightly and with build-std enabled which we do for code size
# this deoptimizes only the examples that otherwise fail to build
export RUSTFLAGS="-Zshare-generics=n -Clto=thin"
fi
trunk build --release --dist "$dist_dir" --public-url "$PUBLIC_URL_PREFIX$example" trunk build --release --dist "$dist_dir" --public-url "$PUBLIC_URL_PREFIX$example"
)
# check that there are no undefined symbols. Those generate an import .. from 'env',
# which isn't available in the browser.
{ cat "$dist_dir"/*.js | grep -q -e "from 'env'" ; } && exit 1 || true
) ; then
echo "::error ::$example failed to build"
failure=true
fi
echo "::endgroup::"
done done
if [ "$failure" = true ] ; then
exit 1
fi

View File

@ -139,6 +139,11 @@ build-std-features = ["panic_immediate_abort"]
[`build-std`]: https://doc.rust-lang.org/cargo/reference/unstable.html#build-std [`build-std`]: https://doc.rust-lang.org/cargo/reference/unstable.html#build-std
[`build-std-features`]: https://doc.rust-lang.org/cargo/reference/unstable.html#build-std-features [`build-std-features`]: https://doc.rust-lang.org/cargo/reference/unstable.html#build-std-features
:::caution
The nightly rust compiler can contain bugs, such as [this one](https://github.com/yewstack/yew/issues/2696),
that require occasional attention and tweaking. Use these experimental options with care.
:::
### wasm-opt ### wasm-opt
Further more it is possible to optimize size of `wasm` code. Further more it is possible to optimize size of `wasm` code.