Skip to content

Commit 50ae2ee

Browse files
fix(ui/cli/plugins): setup-plugin-bun also detect Bun.build (#1615)
* fix(ui/cli/plugins): `setup-plugin-bun` also detect `Bun.build` * chore(docs/guide): simplify Bun project setup instructions to include React and Tailwind CSS integration
1 parent 0018bc6 commit 50ae2ee

File tree

4 files changed

+41
-9
lines changed

4 files changed

+41
-9
lines changed

.changeset/many-nights-nail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"flowbite-react": patch
3+
---
4+
5+
fix(ui/cli/plugins): `setup-plugin-bun` also detect `Bun.build`

apps/web/content/docs/guides/bun.mdx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,9 @@ Create a new Bun project with React and Tailwind CSS:
5555

5656
```bash
5757
mkdir my-app && cd my-app
58-
bun init
58+
bun init --react=tailwind
5959
```
6060

61-
When prompted:
62-
63-
- Select "React" for the project template
64-
- Select "TailwindCSS" for the React template
65-
6661
### 2. Install Flowbite React
6762

6863
Install Flowbite React:

packages/ui/src/cli/utils/update-build-config.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,32 @@ describe("updateBuildConfig", () => {
9090
expect(result).toContain('import customPlugin from "@custom/plugin"');
9191
expect(result).toMatch(/plugins:\s*\[\s*customPlugin\s*\]/);
9292
});
93+
94+
it("should handle config with Bun.build", () => {
95+
const input = `
96+
import { plugin } from './plugins';
97+
98+
const result = await Bun.build({
99+
entrypoints,
100+
outdir,
101+
plugins: [plugin],
102+
minify: true,
103+
target: "browser",
104+
sourcemap: "linked",
105+
define: {
106+
"process.env.NODE_ENV": JSON.stringify("production"),
107+
},
108+
...cliConfig,
109+
});
110+
`;
111+
112+
const result = updateBuildConfig({
113+
content: input,
114+
pluginName: "flowbiteReact",
115+
pluginImportPath: "flowbite-react/plugin/bun",
116+
});
117+
118+
expect(result).toContain('import flowbiteReact from "flowbite-react/plugin/bun"');
119+
expect(result).toMatch(/plugins:\s*\[\s*plugin,\s*flowbiteReact\s*\]/);
120+
});
93121
});

packages/ui/src/cli/utils/update-build-config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ export function updateBuildConfig({
4040
visitCallExpression(path) {
4141
const { node } = path;
4242

43-
// Check if this is a build() call
43+
// Check if this is a build() or Bun.build() call
4444
if (
45-
node.callee.type === "Identifier" &&
46-
node.callee.name === "build" &&
45+
((node.callee.type === "Identifier" && node.callee.name === "build") ||
46+
(node.callee.type === "MemberExpression" &&
47+
node.callee.object.type === "Identifier" &&
48+
node.callee.object.name === "Bun" &&
49+
node.callee.property.type === "Identifier" &&
50+
node.callee.property.name === "build")) &&
4751
node.arguments.length > 0 &&
4852
node.arguments[0].type === "ObjectExpression"
4953
) {

0 commit comments

Comments
 (0)