Skip to main content

Module normalize

Module normalize 

Source
Expand description

Plugin entry normalization (D1 — bench/normalizer-spike/STRESS-RESULTS.md §Phase 3 dispositions; executable spec: bench/normalizer-spike/D1-PLAN.md).

One self-contained ESM output per plugin entry, loadable with zero runtime-specific patches on bun/node/deno (spike K1–K7), cached by content hash, emitted either beside the entry (bundle still has runtime-resolved bare specifiers → needs node_modules ancestry — the K4 case) or under ocserve’s own normalized/ tree (fully self-contained → zero writes into user repos; D1-PLAN scanner rule).

Every failure degrades to the raw entry (loud in the log, metric error), never worse than today’s behavior. OCSERVE_PLUGIN_NORMALIZE=0 skips before rolldown is ever constructed (the panic=abort residual, A3). Callers: Sidecar::load_raw (boot AND respawn replay).

Enums§

Outcome
Result of one normalize attempt. The returned PathBuf (tuple) is what the caller must load; the raw entry stays the replay/canonical source.

Functions§

needs_ancestry
true = the bundle still resolves something at runtime against its own location → must be emitted beside the entry (node_modules ancestry).
normalize_or_raw_sync
Normalize entry for loading. Returns (path-to-load, outcome). On any failure the raw entry is returned with Fallback — the load proceeds exactly as it does today (never worse than raw; D1-PLAN).