Files
bun.sh/packages/bun-build-mdx-rs
2025-05-12 17:12:17 -07:00
..
2024-12-11 17:51:21 -08:00

bun-build-mdx-rs

This is a proof of concept for using a third-party native addon in Bun.build().

This uses mdxjs-rs to convert MDX to JSX.

TODO: This needs to be built & published to npm.

Building locally:

cargo build --release
import { build } from "bun";
import mdx from "./index.js";

// TODO: This needs to be prebuilt for the current platform
// Probably use a napi-rs template for this
import addon from "./target/release/libmdx_bun.dylib" with { type: "file" };

const results = await build({
  entrypoints: ["./hello.jsx"],
  plugins: [mdx({ addon })],
  minify: true,
  outdir: "./dist",
  define: {
    "process.env.NODE_ENV": JSON.stringify("production"),
  },
});

console.log(results);