-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! I did a more thorough review. Really appreciate the nice readme in examples/
:)
examples/readme.md
Outdated
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 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 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Co-Authored-By: Justin Starry <[email protected]>
fixes: #1162
Updated examples to work with
wasm-bindgen
->build.sh
script to run themAdded
minimal_wp
example which works withwasm-pack
Added
readme.md
with minimum info how to run these examples.Added
ci/run_examples.sh
to 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 )