README: Dev loop section

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
CRTkafa 2026-09-30 22:32:38 +07:00
parent 098b985bce
commit 832396801c

View file

@ -510,6 +510,29 @@ wayBetter for X adds this repository as a git submodule at `waybetter/` and cons
type stripping refuses `.ts` files under `node_modules`, while sources outside it work with Bun's type stripping refuses `.ts` files under `node_modules`, while sources outside it work with Bun's
isolated linker on Windows. isolated linker on Windows.
## Dev loop
`waybetter dev [--stable] --watch "<build watcher>"...` starts the app's watchers, waits for their
first build and runs `tauri dev` (`--stable` adds `--no-watch`: a Rust file saved by someone else
does not restart the app; restart it yourself after Rust changes). Debug builds only:
- The app names its page scripts with `waybetter_host::page_script!(include_str!("../x.js"), "x.js")`
in `SiteHooks::init_scripts`. A debug build reads the file from disk (path relative to the app
crate, falling back to the embedded copy) each time a tab's init scripts are built and watches it
(`devloop`, using `devmode`'s debounced signature watcher). When it changes, every tab webview is
rebuilt on its current URL through `tabs_sync`, because a webview's document-start scripts are
fixed at creation. Route is kept, scroll is not. About 1 s from save to visible.
- `buildRuntime({ watch: watchRequested(), ... })` (`waybetter/build`) keeps esbuild rebuilding the
file; a failed build leaves the last good one.
- The shell reloads through the frontend dev server (`beforeDevCommand`), instantly.
- Restart needed: Rust, `tauri.conf.json`, capabilities, bundled plugin sources (`include_str!` in the
plugin table; installed plugin files reload with developer mode as before).
- Release builds contain none of it: `devloop` is `cfg(debug_assertions)`, the macro's release arm is
`$embedded.to_owned()` and the path literal is never expanded. `release_guard` (lib.rs) checks that
every mention is gated; `cargo test --release` also runs `release_page_script_is_the_embedded_copy`.
- `.taurignore` the watched output files (`observer.js`, `x-runtime.js`), or plain `tauri dev` restarts
on every rebuild. `create-waybetter` apps get `npm run dev` and `npm run dev:stable`.
## Scripts (no CI) ## Scripts (no CI)
```sh ```sh