pub fn inject_js_into_component(
input: &Utf8Path,
output: &Utf8Path,
js_sources: &[&str],
) -> Result<()>Expand description
Injects JavaScript source code into a compiled WASM component that was built with
EmbeddingMode::BinarySlot.
This structurally rewrites the WASM component using wasmparser + wasm-encoder:
- Finds data segments containing 40-byte markers and records their module indices.
- Grows the core module’s memory to fit all new JS data segments.
- Adds new active data segments at the end of memory containing the JS for each module.
- Updates the DataCount section to account for the extra segments.
There is no capacity limit — each JS source can be any size.
The js_sources slice maps by position to marker MODULE_INDEX: the first entry
is injected into the marker with MODULE_INDEX=0, the second into MODULE_INDEX=1, etc.