seed-rs / seed-quickstart

Bare essentials to start a Seed app.
https://seed-rs.org/
101 stars 28 forks source link

Tips for improvements #11

Closed MartinKavik closed 4 years ago

MartinKavik commented 5 years ago

RealWorld example is based on this quickstart, so I want to write a list of changes / missing features before I forget:

  1. Some copy & pasted task descriptions in Makefile.toml doesn't make sense in quickstart's context (e.g. "Run Seed's tests. Ex:..").
  2. Missing tasks for linting and CI like clippy, fmt, verify, verify_only, ..
  3. Missing default rustfmt.toml, .travis.yml and maybe netlify.toml.
  4. wasm-bindgen-test is missing in dev-dependencies.
  5. cargo make watch builds before starting watcher so its annoying if you have more compilation errors and want to start watcher for easier debugging.
  6. 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.
  7. Minification / uglify - its a relatively big problem, RealWorld's first start is quite slow.
    1. Minification/Uglify for CSS/HTML/JS - I don't know if something in Rust exists.
    2. Optimize *.wasm size (it's possible to strip several hundred of KBs):
      1. The first way is easy - just add compiler flags (see the end of RealWorld's Cargo.toml, opt-level should be s or z ).
      2. 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 with cargo-make. I'm using NodeJS API wrapper - see this script in seed-quickstart-webpack.
MartinKavik commented 5 years ago

Related issue from Seed repo to 6. Auto-reload: https://github.com/David-OConnor/seed/issues/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();
}
David-OConnor commented 5 years ago

Some of the Makefile issues are cleaned up in the latest commit.

David-OConnor commented 5 years ago

Do you think fmt and clippy makefile tasks are needed in this repo? Ie functionality past what running cargo clippy and cargo fmt provide?

MartinKavik commented 5 years ago

Imho it's nice to have default strict settings and if somebody don't like it, it's always faster to delete it than write new one. Also for new rust users it's better to use cargo make * because it automatically installs required dependencies.

On Mon, 29 Jul 2019 at 09:42, David-OConnor notifications@github.com wrote:

Do you think fmt and clippy makefile tasks are needed in this repo? Ie functionality past what running cargo clippy and cargo fmt provide?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/David-OConnor/seed-quickstart/issues/11?email_source=notifications&email_token=AENI3GSDSDXF3WKDUWHLBTDQB2NNXA5CNFSM4IHHSE2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD273Z4Q#issuecomment-515882226, or mute the thread https://github.com/notifications/unsubscribe-auth/AENI3GSRAN4W3X6Y2OCAOQTQB2NNXANCNFSM4IHHSE2A .

MartinKavik commented 5 years ago
  1. Template - see https://github.com/MartinKavik/seed-quickstart-webpack/issues/2
MartinKavik commented 4 years ago
  1. Check Rust dependencies - example issue: https://github.com/seed-rs/seed-quickstart/issues/16
Ben-PH commented 4 years ago

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
MartinKavik commented 4 years ago

@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.

MartinKavik commented 4 years ago

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.