mirror of
https://github.com/proxysoul/Empryo.git
synced 2026-11-07 06:25:57 -10:00
20 lines
612 B
TypeScript
20 lines
612 B
TypeScript
import { plugin } from "bun";
|
|
|
|
plugin({
|
|
name: "react-compiler",
|
|
setup(build) {
|
|
build.onLoad({ filter: /src\/.*\.tsx?$/ }, async ({ path, loader }) => {
|
|
const { transformSync } = await import("@babel/core");
|
|
const source = await Bun.file(path).text();
|
|
const result = transformSync(source, {
|
|
filename: path,
|
|
plugins: [["babel-plugin-react-compiler", { target: "19" }]],
|
|
parserOpts: {
|
|
plugins: path.endsWith(".tsx") ? ["typescript", "jsx"] : ["typescript"],
|
|
},
|
|
});
|
|
return { contents: result?.code ?? source, loader };
|
|
});
|
|
},
|
|
});
|