Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/many-nights-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"flowbite-react": patch
---

fix(ui/cli/plugins): `setup-plugin-bun` also detect `Bun.build`
7 changes: 1 addition & 6 deletions apps/web/content/docs/guides/bun.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,9 @@ Create a new Bun project with React and Tailwind CSS:

```bash
mkdir my-app && cd my-app
bun init
bun init --react=tailwind
```

When prompted:

- Select "React" for the project template
- Select "TailwindCSS" for the React template

### 2. Install Flowbite React

Install Flowbite React:
Expand Down
28 changes: 28 additions & 0 deletions packages/ui/src/cli/utils/update-build-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,32 @@ describe("updateBuildConfig", () => {
expect(result).toContain('import customPlugin from "@custom/plugin"');
expect(result).toMatch(/plugins:\s*\[\s*customPlugin\s*\]/);
});

it("should handle config with Bun.build", () => {
const input = `
import { plugin } from './plugins';

const result = await Bun.build({
entrypoints,
outdir,
plugins: [plugin],
minify: true,
target: "browser",
sourcemap: "linked",
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
...cliConfig,
});
`;

const result = updateBuildConfig({
content: input,
pluginName: "flowbiteReact",
pluginImportPath: "flowbite-react/plugin/bun",
});

expect(result).toContain('import flowbiteReact from "flowbite-react/plugin/bun"');
expect(result).toMatch(/plugins:\s*\[\s*plugin,\s*flowbiteReact\s*\]/);
});
});
10 changes: 7 additions & 3 deletions packages/ui/src/cli/utils/update-build-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ export function updateBuildConfig({
visitCallExpression(path) {
const { node } = path;

// Check if this is a build() call
// Check if this is a build() or Bun.build() call
if (
node.callee.type === "Identifier" &&
node.callee.name === "build" &&
((node.callee.type === "Identifier" && node.callee.name === "build") ||
(node.callee.type === "MemberExpression" &&
node.callee.object.type === "Identifier" &&
node.callee.object.name === "Bun" &&
node.callee.property.type === "Identifier" &&
node.callee.property.name === "build")) &&
node.arguments.length > 0 &&
node.arguments[0].type === "ObjectExpression"
) {
Expand Down
Loading