Skip to main content

Crate wabot_ui_bundler

Crate wabot_ui_bundler 

Source
Expand description

§wabot-ui-bundler

Build-time bundler for Preact (or any JSX) islands, for apps that want real components in the browser while Rust keeps rendering every page. Port of the discovery + entry-generation half of wabot-ts’s UiBundler, delegating the actual bundling to esbuild.

This is a build dependency, not a runtime one — nothing here ends up in your binary.

ⓘ
// build.rs
fn main() {
    wabot_ui_bundler::IslandBundler::new("islands", "static/islands")
        .public_base("/static/islands")
        .run_or_warn();
}
ⓘ
// src/main.rs — ids and module URLs, checked by the compiler
include!(concat!(env!("OUT_DIR"), "/islands.rs"));

island_module(islands::CLICKS_ID, islands::CLICKS_MODULE, &props, html! { … })

§What it does

  1. Finds *.island.tsx / *.island.jsx under the source directory.
  2. Derives a stable id from the filename: NotesForm.island.tsx → notes-form. That id is what the Rust view passes to island() and what the generated entry registers, so the two always agree.
  3. Writes one entry per island that hydrates the default export into its <wabot-island> host and returns a teardown.
  4. Runs esbuild over all entries with code splitting, so Preact itself lands in one shared chunk instead of being copied into every island.
  5. Emits islands.rs with an id + module-URL constant per island, so renaming a .tsx file breaks the Rust build instead of silently producing a dead island.

§Degrading without Node

IslandBundler::run_or_warn turns a missing toolchain into a cargo:warning rather than a failed build, so a checkout without Node still compiles — you just need the previously-built bundles present (committing them is reasonable for an example or a deploy artifact).

Re-exports§

pub use css::CssModule;
pub use css::CssModuleBundler;

Modules§

css
CSS modules: scoped class names, with the same names on both sides of the language boundary.

Structs§

AssetEmbedder
Walks a directory at build time and generates a Rust manifest that include_bytes!s every file, so the binary carries its own assets.
BundleReport
What a successful run produced.
Island
One discovered island source file.
IslandBundler
ViewBundler
Bundles *.view.tsx into one JavaScript file that QuickJS evaluates at startup, exposing __wabot_render(view, propsJson).

Enums§

BundleError

Functions§

island_stem
Counter.island.tsx → Some("Counter"); anything else → None.
kebab_case
NotesForm → notes-form, HTTPStatus → http-status.
screaming_case
NotesForm → NOTES_FORM.
view_stem
Dashboard.view.tsx → Some("Dashboard"). Server-rendered views, as opposed to client islands.