islands-build 0.1.3

Layout-agnostic build pipeline for islands.rs apps: WASM bundling, the V8 module-namespace patch, per-page CSS, and content-hash manifests. Composed by a thin xtask in any workspace.
Documentation
//! # islands-build — the islands.rs build pipeline, as a library
//!
//! Everything needed to **build** an islands.rs app, decoupled from any one
//! repository's layout. A thin `xtask` (this repo's, or a downstream consumer's)
//! constructs a [`BuildPlan`] — from an [`IslandsConfig`] (`islands.toml`) or its
//! own discovery — and calls [`build`].
//!
//! The pipeline:
//! 1. **WASM** ([`wasm::build_wasm`]): resolve + install the matching
//!    `wasm-bindgen-cli`, compile the runtime ([`wasm::build_runtime`]) and page
//!    crates to `wasm32-unknown-unknown`, run `wasm-bindgen --target web`, verify
//!    the artifacts, and apply the load-bearing [V8 namespace patch](patch).
//! 2. **CSS** ([`css::build_css`]): build the shared `base.css` and a per-page
//!    Tailwind bundle for each page (optionally materializing `basecoat.css`).
//! 3. **Manifest** ([`hashing::post_build_hashing_pass`], gated by
//!    [`BuildPlan::manifest`]): content-hash every asset, rewrite cross-asset
//!    references, and write `manifest.json`. Off ⇒ logical filenames, resolved by
//!    `page_shell`'s logical-path fallback.
//!
//! The [V8 namespace patch](patch) is exported as a first-class, tested API:
//! skipping it produces a bundle the browser refuses to instantiate, so no
//! consumer should ever have to rediscover it.

pub mod config;
pub mod css;
pub mod discovery;
pub mod hashing;
pub mod manifest;
pub mod patch;
pub mod wasm;

pub use config::{BuildPlan, CssConfig, PageBuild, RuntimeBuild};
pub use css::{build_base_css, build_css, build_page_css};
pub use discovery::IslandsConfig;
pub use hashing::post_build_hashing_pass;
pub use manifest::{BuildManifest, ManifestBundleEntry};
pub use patch::{patch_page_js, patch_runtime_snippets, PATCH_TOKEN};
pub use wasm::{build_page_wasm, build_runtime, build_wasm, wasm_bindgen_bundle};

#[cfg(feature = "basecoat")]
pub use css::materialize_basecoat_css;

use anyhow::Result;

/// Run the full build: WASM (runtime + pages) → CSS → (optional) content-hash +
/// manifest.
///
/// Does **not** clean `out_dir` first — cleaning policy (which directories to
/// wipe, which checked-in inputs to preserve) belongs to the caller.
pub fn build(plan: &BuildPlan) -> Result<()> {
    wasm::build_wasm(plan)?;
    css::build_css(plan)?;
    if plan.manifest {
        hashing::post_build_hashing_pass(plan)?;
    }
    Ok(())
}