* feat: wasm-split base implementation * kinda sorta works with the cli * okay great it actually works * fix: cache busting for chunks * cleaned up version * it works with the router * wip: migrate to a faster linear solution using id remapping * add a good harness * it works completely on the docsite * the super tight build works too * make parallelizable * works on the docsite but not the harness * light cleanups, fix for both harness and docsite * make codegen smaller by extract some shared functions to prevent monos * chunking works, but tbd on tuning heuristics * extract used module * wip: cleaning up module * wip: much better understanding of how imports work * fix the call graph * working again... * wip: thinking about ifuncs * ifunc approach works * yes the ifunc approach works!! * it all works completely even with chunks * small cleanups * comments * actually locate all of the symbols * clean up final implementation * clean up tomls, revert some mono changs * clean up, add some more comments / docs in places * hoist more packages * clean up impl a bit more * clean cli * move harness to playwright * update playwright * extract codgen * add lazy to components * Add docs to split loader * clippy * typos * clippy, don't generate splits if not on wasm * whoops, const * Typos and docs * enable optimizations in ci * add optimizations to ci * add wasm-split router feature * parallel playwright? * fix no case check * disable pre-compress... think that might be the issue * better logging, no default pre-compress, caching of shared symbols * Fix: compressing assets * fix non-interactive logging for serve * cache playwright even on failure, use the cli with optimizations * fix prebuild * fix playwright webserver
83 lines
3.6 KiB
Bash
Executable File
83 lines
3.6 KiB
Bash
Executable File
# This file is a simple shell script that runs the bundle split process manually without the CLI involved
|
|
# it's not necessarily meant to work on your machine (sorry!)
|
|
#
|
|
# To hack on harness you need the `wasm-tools` CLI installed
|
|
# `cargo binstall wasm-tools`
|
|
#
|
|
# This script is also sensitive to where it's run from, so you *need* to be in the harness folder (running as `./run.sh`)
|
|
|
|
TARGET_DIR=../../../target
|
|
|
|
# build the harness
|
|
cargo rustc --package wasm-split-harness --target wasm32-unknown-unknown --profile wasm-split-release -- -Clink-args=--emit-relocs
|
|
|
|
# for a much smaller compile, you can crank up the flags. However, dioxus relies heavily on location detail, so we can't disable that
|
|
#
|
|
# -Zlocation-detail=none - we could compile with location detail off but if breaks our signals...
|
|
#
|
|
# cargo +nightly rustc \
|
|
# -Z build-std=std,panic_abort \
|
|
# -Z build-std-features="optimize_for_size" \
|
|
# -Z build-std-features=panic_immediate_abort \
|
|
# --target wasm32-unknown-unknown \
|
|
# --no-default-features \
|
|
# --profile wasm-split-release \
|
|
# -- -Clink-args=--emit-relocs
|
|
|
|
# Build the wasm-split-cli. We are going to call it directly since it's so noisy to build it multiple times
|
|
cargo build --package wasm-split-cli --bin wasm-split-cli
|
|
CLI=$TARGET_DIR/debug/wasm-split-cli
|
|
|
|
# clear the workdir and assemble the new structure
|
|
rm -rf data/harness
|
|
mkdir -p data/harness/split
|
|
mkdir -p data/harness/split_not
|
|
|
|
# copy the output wasm file to the harness dir
|
|
cp $TARGET_DIR/wasm32-unknown-unknown/wasm-split-release/wasm-split-harness.wasm data/harness/input.wasm
|
|
|
|
# Run wasm-bindgen on this module, without splitting it
|
|
wasm-bindgen data/harness/input.wasm --out-dir data/harness/split_not --target web --out-name main --no-demangle --no-typescript --keep-lld-exports --keep-debug
|
|
|
|
# Run the wasm-split-cli on the with_body.wasm file
|
|
${CLI} split data/harness/input.wasm data/harness/split_not/main_bg.wasm data/harness/chunks
|
|
|
|
# copy over the chunks
|
|
paths=$(ls data/harness/chunks/ | grep "\.wasm")
|
|
for path in $paths
|
|
do
|
|
|
|
path_without_ext=${path%.*}
|
|
wasm-opt -Oz data/harness/chunks/$path -o data/harness/split/$path --enable-reference-types --memory-packing --debuginfo
|
|
|
|
# remove stuff like manganis, etc
|
|
wasm-tools strip data/harness/split/$path -o data/harness/split/$path
|
|
|
|
# if you don't want names (making it harder to debug the outputs) use `--all`
|
|
# wasm-tools strip data/harness/split/$path -o data/harness/split/$path --all
|
|
done
|
|
|
|
|
|
# rename the main chunk
|
|
mv data/harness/split/main.wasm data/harness/split/main_bg.wasm
|
|
cp data/harness/split_not/main.js data/harness/split/main.js
|
|
cp -r data/harness/split_not/snippets data/harness/split/snippets
|
|
cp data/harness/chunks/__wasm_split.js data/harness/split/__wasm_split.js
|
|
|
|
wasm-opt -Oz data/harness/split_not/main_bg.wasm -o data/harness/split_not/main_bg_opt.wasm --enable-reference-types --memory-packing --debuginfo
|
|
|
|
# Run wasm-strip to strip out the debug symbols
|
|
wasm-tools strip data/harness/split_not/main_bg_opt.wasm -o data/harness/split_not/main_bg_opt.wasm
|
|
|
|
# if you don't want names (making it harder to debug the outputs) use `--all`
|
|
# wasm-tools strip data/harness/split/$path -o strip data/harness/split_not/main_bg_opt.wasm --all
|
|
|
|
echo "===========================================================================\n"
|
|
ls -l data/harness/split_not/main_bg_opt.wasm | awk '{ printf("%07d -> ", $5);print $9}'
|
|
echo ""
|
|
ls -l data/harness/split | grep "\.wasm" | awk '{ printf("%07d -> ", $5);print $9}'
|
|
echo "\n==========================================================================="
|
|
|
|
# hope you have python3 installed :)
|
|
python3 -m http.server 9876 --directory data
|