Repository navigation
Description
Problem
Developing a Stackpress application today means running separate native and WASM builds by hand, often for both hydrate and CSR, and reloading the browser manually. Every edit pays for full rebuilds of outputs the edit did not affect. Framework-library settings cannot fix this alone: Cargo reads [profile.*] only from the consuming workspace root, so each application's own manifest decides its build defaults (Cargo profiles).
Requested behavior
Add a stackpress dev command to the application tooling that gives a fast edit loop for a selected app:
- watch the app's sources and rebuild only the affected native and/or WASM outputs;
- build only the render mode being developed (for example hydrate), not both hydrate and CSR on every edit;
- reload the browser after a successful rebuild, and update CSS without a Rust compile;
- start the dev server only through the normal managed path (no hidden listeners), and show build errors in the terminal and the page.
Ship matching defaults in the application templates, so new apps get fast development builds:
- workspace
[profile.dev]settings (for example reduced debug info and incremental builds); - an optional, documented compiler cache;
- a test command that prefers
cargo nextestwhere installed.
Prior art
cargo-leptos already provides server/client watch builds, browser reload and CSS hot reload. Its documented support centres on SSR plus hydration. Stackpress would need integration work for:
- CSR-only applications;
- custom hosting (the Stackpress server and gateway, mounted base paths);
- generated admin and asset manifests.
Decide whether to wrap cargo-leptos, reuse parts of it, or implement a smaller watcher.
Scope and boundaries
- Development only; production builds stay explicit and reproducible.
- No change to plugin selection rules: plugins remain chosen at compile time.
- Keep SSR, hydrate and CSR builds separate. Never unify mutually exclusive render features.
- No dependency or toolchain upgrades as part of this issue.
Acceptance criteria
- Design records the watcher choice (cargo-leptos integration vs custom), supported app shapes (SSR+hydrate, CSR, custom host) and limits.
- Editing a Rust file in a sample app rebuilds only affected outputs; a CSS-only edit applies without a Rust compile.
- Browser reloads after a successful rebuild; failures are shown without killing the session.
- Application templates include the development profile defaults and document optional
sccacheandcargo nextestuse. - Measured before/after edit-loop times for a sample app are recorded.
Related: #14 (plugin entry points), #17 (stackpress-leptos).
Activity
cblanquera commentedon Oct 29, 2026
Implementation recommendation
Grounded in the current tree. Each example ships its own Python build script (for example
examples/ui-preferences/build.py). Every run does a native build plus both hydrate and CSR WASM builds andwasm-bindgen.stackpress-cliis an application-owned event CLI (emit ...) and should stay that way. The recommendation below keeps the dev loop out of every runtime graph.1. A separate, development-only tool
Add
tools/dev(packagestackpress-dev, binarystackpress-dev, also runnable ascargo stackpress-dev). It is never a dependency of an app, library or browser build, the same rule as codegen and generator tools.2. Declare the app once, in its own manifest
Read the app shape from the app workspace's own
Cargo.toml, so nothing is guessed from paths:3. Rebuild only the affected outputs
Use
cargo metadataonce at start-up (and again when aCargo.tomlchanges). It maps every changed file to a workspace package, then to the outputs that depend on that package:Notes:
--features hydrateorcsr). CI and release keep building every mode separately.wasm-optin dev.cargo build --message-format=json-render-diagnosticsand read thecompiler-artifactmessage for the client's.wasmfile before runningwasm-bindgen.CORE_STYLES) still needs a compile; only app-owned stylesheet files hot-swap. Document that limit.4. Watch, debounce, and cancel stale builds
Use
notifywith a short debounce. When a new change arrives mid-build, kill the running build's process group and start over, so the loop never finishes a build that is already stale:5. Reload through a small dev proxy, so apps need no dev code
Run the app server as a child on an internal port.
stackpress-devlistens on the user-facing port, started through the project's normal managed-listener rules. It forwards requests and, in dev only, injects one script tag into HTML responses. It also serves a Server-Sent Events channel. Release builds, app code and CSP stay untouched: the proxy adds the injected script's hash or nonce to the dev response's CSP header.After a native rebuild, restart the server child. The proxy holds incoming requests until the new child accepts connections, so the browser never sees a refused connection. Build errors go to the terminal and the overlay, and the previous good server stays up.
6. Template defaults (Cargo reads profiles only from the app's workspace root)
Document
cargo nextest runfor tests andcargo test --docfor doctests.stackpress-dev --testcan runcargo nextest run -p <affected packages>after each successful rebuild.7. cargo-leptos: borrow ideas, don't wrap (for now)
cargo-leptos proves the loop: paired server and client watch builds, live reload and CSS hot reload. It is built around one SSR+hydrate lib/bin layout and its own server integrations. Stackpress needs:
A small purpose-built tool fits better. Keep the manifest format close enough that a later
engine = "cargo-leptos"option stays possible for plain SSR+hydrate apps.8. Suggested milestones
tools/devwith the manifest, affected-output mapping, a single-mode client build, a native rebuild with server restart, and terminal errors. Prove it onexamples/ui-preferences.[profile.dev], opt-in sccache,nextest.toml),--test, and measured before/after edit-loop times on two examples, plus docs.