bundle: the page JS and the bundler become a library crate downstream packs can reuse

The in-page bundle, the extension pieces, the registry JSON and the
wasm-pack call were reachable only through `cargo xtask bundle`, which read
`browser-bundle/*.js` from the repo root. A downstream crate that links
impeccable-core + impeccable-wasm with its own rule pack had to copy the
page JS to produce a detector bundle for its module.

They move to `impeccable-bundle` (crates/bundle), which embeds every
`browser-bundle/*.js` with `include_str!` and exposes `in_page_bundle`,
`extension_pieces`, `registry_json`, `check_capture_contract` and
`wasm_pack_build`. Nothing writes files or exits the process; the caller
places the bytes. `registry_json` now reads `all_antipatterns()`, so an
installed pack's rows land in `antipatterns.json` too (no built-in change).

xtask becomes the workspace's caller and writes the same files to the same
places; `cargo xtask bundle` is byte-identical, tracked live asset included.
`IMPECCABLE_BUNDLE_SKIP_WASM_PACK` is the skip switch's new name, the old
`IMPECCABLE_XTASK_SKIP_WASM_PACK` still works.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vau2X53xGTjjTCXWMVBoNY
This commit is contained in:
Paul Bakaus
2026-09-03 10:49:42 -07:00
co-authored by Claude Fable 5.1
parent 410626e5de
commit 453a6e1500
9 changed files with 539 additions and 253 deletions
+12 -4
View File
@@ -10,10 +10,18 @@ Two consumers:
- `crates/browser` embeds `15-snapshot.js` (the snapshot producer the URL
engine injects; no WebAssembly runs in the page).
- `cargo xtask bundle` concatenates these files, in filename order, with the
wasm core into `dist/detect-antipatterns-browser.js`, copies that bundle to
the tracked `crates/live/assets/detect-antipatterns-browser.js` the engine
embeds, and writes the extension's `extension/detector/` pieces.
- `crates/bundle` (the `impeccable-bundle` library) embeds every file here
with `include_str!` and concatenates them, in filename order, with the wasm
core into the in-page bundle plus the extension's `extension/detector/`
pieces. `cargo xtask bundle` is its caller inside this workspace: it writes
`dist/detect-antipatterns-browser.js`, copies that bundle to the tracked
`crates/live/assets/detect-antipatterns-browser.js` the engine embeds, and
writes the extension pieces. A downstream crate with its own rule pack
calls the library directly (`docs/ENGINE.md`).
Because the files are embedded, a new one here has to be added to
`PAGE_JS` in `crates/bundle/src/lib.rs` (and to the order it is concatenated
in); a test fails when the two lists disagree.
`15-snapshot.js` lists the computed-style properties the rules read; the
bundle build checks that list against the core's and fails when they drift.