Tips for improvements
MartinKavik opened this issue · 9 comments
RealWorld example is based on this quickstart, so I want to write a list of changes / missing features before I forget:
- Some copy & pasted task descriptions in
Makefile.toml
doesn't make sense in quickstart's context (e.g. "Run Seed's tests. Ex:.."). - Missing tasks for linting and CI like
clippy
,fmt
,verify
,verify_only
, .. - Missing default
rustfmt.toml
,.travis.yml
and maybenetlify.toml
. wasm-bindgen-test
is missing indev-dependencies
.cargo make watch
builds before starting watcher so its annoying if you have more compilation errors and want to start watcher for easier debugging.- Missing auto-reload. Temporary solution probably can be http://livereload.com/. I found only https://gitlab.com/MJDSys/reload-rs in Rust world which should do what we want but its a little bit older and it has probably incompatible license.
- Minification / uglify - its a relatively big problem, RealWorld's first start is quite slow.
- Minification/Uglify for CSS/HTML/JS - I don't know if something in Rust exists.
- Optimize
*.wasm
size (it's possible to strip several hundred of KBs):- The first way is easy - just add compiler flags (see the end of RealWorld's Cargo.toml,
opt-level
should bes
orz
). - The second way is to call external optimizer https://github.com/WebAssembly/binaryen#wasm-opt. It's written in C++ so it cannot be used directly but if I remember correctly there were some plans to integrate it into
wasm-pack
. Or it can be probably installed withcargo-make
. I'm using NodeJS API wrapper - see this script inseed-quickstart-webpack
.
- The first way is easy - just add compiler flags (see the end of RealWorld's Cargo.toml,
Related issue from Seed repo to 6. Auto-reload: seed-rs/seed#172.
I was looking at source code for microserver
(we use it for starting examples in Seed and serve
task here) - and it seems quite simple. And we have nice examples server-integration
and websocket
in Seed repo.
So this is the idea: Write a simple alternative for microserver
. New server will serve wasm files + assets like microserver
but it will have also REST (?) API for invoking page reload. That API would be called by watcher after build (Variant A). Or this new server would have own watcher instead of API and it would monitor served files for changes (Variant B).
This server will send command to reload to served client through websocket. Client receives commands either through injected javascript by server (Variant X) or through Rust connector (Variant Y) - there will be something like this in client code:
#[wasm_bindgen(start)]
#[cfg(debug_assertions)]
connect_to_live_reload_server();
pub fn render() {
seed::App::build(|_, _| Model::default(), update, view)
.finish()
.run();
}
Some of the Makefile issues are cleaned up in the latest commit.
Do you think fmt and clippy makefile tasks are needed in this repo? Ie functionality past what running cargo clippy
and cargo fmt
provide?
- Template - see MartinKavik/seed-quickstart-webpack#2
- Check Rust dependencies - example issue: #16
with cargo make watch
, would there be a solution somewhere in this notion?
while [ ! cargo make build ] ; do
block until change is detected
end while
cargo make watch
@Ben-PH Maybe.. I plan to update this quickstart and then move to Seeder and use Seeder as the primary Seed/Rust app template. Then you'll have space for experiments with this quickstart, I don't want to invest a lot of time into it.
The quickstart rewritten and updated. Some of the features from the list above have been implemented. However some advanced features will be integrated into more advanced quickstart/tool Seeder. I think this QS should be as simple as possible.