Files
bun.sh/packages/bun-build-mdx-rs
Zack Radisic 113b62be82 Native plugin follow up (#15632)
Co-authored-by: zackradisic <zackradisic@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-12-11 17:51:21 -08: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);