Skip to main content

@docxio/bun

Bun build plugin for docxio. Handles WASM file resolution and JSX configuration during bun build.

Installation​

bun add @docxio/bun

Size: ~2 KB

Usage​

Register the plugin in your Bun build script:

import { docxioPlugin } from "@docxio/bun";

await Bun.build({
entrypoints: ["./src/index.tsx"],
outdir: "./dist",
plugins: [docxioPlugin()],
});

The plugin:

  1. Resolves the docxio WASM binary so Bun can bundle it correctly
  2. Configures the JSX transform to use docxio as the import source
  3. Ensures .wasm files are included in the output

With Bun.serve​

When using Bun.serve directly (no build step), docxio works out of the box:

/** @jsxImportSource docxio */
import { render } from "docxio";

Bun.serve({
async fetch(req) {
const doc = (
<document>
<section>
<paragraph><run>Hello from Bun!</run></paragraph>
</section>
</document>
);

const bytes = await render(doc);
return new Response(bytes, {
headers: {
"Content-Type":
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
},
});
},
});

No build plugin is needed for development -- only for production builds.