feat(bundler): expose reactFastRefresh option in Bun.build API (#25731)

Fixes #25716

Adds support for a `reactFastRefresh: boolean` option in the `Bun.build`
JavaScript API, matching the existing `--react-fast-refresh` CLI flag.

```ts
const result = await Bun.build({
    reactFastRefresh: true,
    entrypoints: ["src/App.tsx"],
});
```

When enabled, the bundler adds React Fast Refresh transform code
(`$RefreshReg$`, `$RefreshSig$`) to the output.
This commit is contained in:
Tommy D. Rossi
2025-12-29 07:07:47 +01:00
committed by GitHub
parent d04b86d34f
commit 538be1399c
4 changed files with 65 additions and 0 deletions

View File

@@ -1942,6 +1942,16 @@ declare module "bun" {
development?: boolean;
};
/**
* Enable React Fast Refresh transform.
*
* This adds the necessary code transformations for React Fast Refresh (hot module
* replacement for React components), but does not emit hot-module code itself.
*
* @default false
*/
reactFastRefresh?: boolean;
outdir?: string;
}