updated examples, added build script#1165
Conversation
minimal example updated to work with wasm-pack minimal_wb exampel to be used with wasm-bindgen directly
|
Nice bash! What was the issue with |
|
|
|
ah got it, no need for package manager. The readme explains the steps: https://github.com/yewstack/yew/tree/master/examples/multi_thread |
|
I tried running and got this: [ Building: minimal using wasm-bindgen ]
Compiling wasm-bindgen-backend v0.2.60
Compiling wasm-bindgen-macro-support v0.2.60
Compiling wasm-bindgen-macro v0.2.60
Compiling wasm-bindgen v0.2.60
Compiling js-sys v0.3.37
Compiling console_error_panic_hook v0.1.6
Compiling web-sys v0.3.37
Compiling wasm-bindgen-futures v0.4.10
Compiling gloo-events v0.1.1
Compiling gloo-timers v0.2.1
Compiling gloo-console-timer v0.1.0
Compiling gloo-file v0.1.0
Compiling gloo v0.2.1
Compiling yew v0.15.0 (/Users/jstarry/Workspace/yewstack/yew/yew)
Compiling minimal v0.1.0 (/Users/jstarry/Workspace/yewstack/yew/examples/minimal)
Finished release [optimized] target(s) in 30.39s
error: failed to read `../target/wasm32-unknown-unknown/release/minimal.wasm`
Caused by:
0: failed to read `../target/wasm32-unknown-unknown/release/minimal.wasm`
1: No such file or directory (os error 2)
[FAIL] Command: "wasm-bindgen --target web --no-typescript --out-dir $SRCDIR/static/ --out-name wasm $TARGET_DIR/$EXAMPLE.wasm" exited with exit code: 1 |
jstarry
left a comment
There was a problem hiding this comment.
Looking good! I did a more thorough review. Really appreciate the nice readme in examples/ :)
|
|
||
| Use `build.sh` script to build examples. | ||
|
|
||
| Examples are prepared for `wasm-bindgen` except `minimal_wp` which is prepared for `wasm-pack`. |
There was a problem hiding this comment.
Can you explain that wasm-bindgen was chosen because:
- Want to keep setup simple (no bundlers)
- Prefer to keep examples as binaries rather than libraries (wasm-pack limitation)
Also, I think here would be a good place to link to https://yew.rs/docs/getting-started/starter-templates for people who are interested in how to setup their own app after they learn about examples.
There was a problem hiding this comment.
This part is little bit confusing for me.
In https://yew.rs/docs/getting-started/project-setup is written: We don't recommend using wasm-bindgen directly because it requires hand-writing some JavaScript to bootstrap you WebAssembly binary.
But wasm-pack and wasm-bindgen both can use same /examples/static/index.html file. No other steps are needed. Neither of them needs to use bundler when compiled with --target web
There was a problem hiding this comment.
🤔 you're right. The docs need to be updated. I wonder if I wrote those before --target web or something.. or maybe I just wrote incorrectly 😅
jstarry
left a comment
There was a problem hiding this comment.
Works so well! This is a huge improvement 👍
I made a bunch of suggestions for small tweaks, you can use Github UI to accept them
Co-Authored-By: Justin Starry <justin.m.starry@gmail.com>
Co-Authored-By: Justin Starry <justin.m.starry@gmail.com>
fixes: #1162
Updated examples to work with
wasm-bindgen->build.shscript to run themAdded
minimal_wpexample which works withwasm-packAdded
readme.mdwith minimum info how to run these examples.Added
ci/run_examples.shto build all examples ( not used )missing info how to install of wasm-bindgen/wasm-pack
update info about
multi-thread( check steps in multi-thread/readme.md )