Files
oh-my-pi/packages/coding-agent/src/utils/mupdf-wasm-embed.ts
T
can1357 88aa88f605 fix(coding-agent): bundle mupdf into the compiled binary so PDF reads work
The vendored markit engine kept `mupdf` external, but a single-file
`bun --compile` binary has no node_modules to resolve it from, so the
standalone binary aborted at startup with `Cannot find package 'mupdf'`
— the otherwise-lazy import is resolved eagerly at boot. Bundle mupdf and
embed its WASM blob (scripts/embed-mupdf-wasm.ts, reset after the build);
npm and source installs still load mupdf from node_modules.

Import mupdf lazily inside the PDF converter so the bundled markit chunk's
init stays synchronous: mupdf's top-level await otherwise made the chunk
init async and bun's compiled bundler failed to await it through the
barrel, exposing the converters before their module-level const tables
initialized (undefined EXTENSIONS). Also keeps the ~10MB wasm off non-PDF
document conversions.
2026-06-18 20:44:58 +02:00

13 lines
699 B
TypeScript

// AUTOGENERATED -- managed by scripts/embed-mupdf-wasm.ts. Do not edit by hand.
//
// Compiled single-file binaries cannot let mupdf resolve its `mupdf-wasm.wasm`
// sibling from the read-only bunfs, so the binary build (scripts/build-binary.ts
// and scripts/ci-release-build-binaries.ts) regenerates this module to embed the
// wasm bytes via `with { type: "file" }` and copies the wasm next to it. Source
// checkouts, `bun test`, and the npm `dist/cli.js` bundle keep mupdf external and
// load the wasm from node_modules, so this placeholder returns undefined and the
// build resets back to it afterward.
export function loadEmbeddedMupdfWasm(): Uint8Array | undefined {
return undefined;
}