Skip to content

packages(ui): build step using rollup + tsc #1344

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 24 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1193890
refactor: packages(ui) - use `rollup` to build and transpile + tsc fo…
SutuSebastian Apr 2, 2024
58bbf58
chore: packages(ui) - remove `rollup-plugin-delete` replace with loca…
SutuSebastian Apr 2, 2024
e3ddcc6
fix: packages(ui) - build step generateDts overriding the rest
SutuSebastian Apr 3, 2024
f810b9e
fix: packages(ui) - rework tsconfig files
SutuSebastian Apr 3, 2024
20e6768
feat: packages(ui) - create tailwind plugin for easier management of …
SutuSebastian Apr 3, 2024
e653c20
feat: packages(ui) - remove tailwind plugin and replace it with `tail…
SutuSebastian Apr 4, 2024
9ee66ae
chore: remove comments
SutuSebastian Apr 4, 2024
e291e80
chore: remove unused package
SutuSebastian Apr 4, 2024
5a09c56
chore: remove rollup external leftover path
SutuSebastian Apr 4, 2024
58ae945
chore: add `trustedDependencies` for `postinstall` script to work in …
SutuSebastian Apr 4, 2024
db6618d
chore: get rid of `postinstall` lifecycle script and configure turbor…
SutuSebastian Apr 4, 2024
e29e489
fix: turborepo `packages/ui` script dependencies
SutuSebastian Apr 4, 2024
aa184ae
chore: rollup config - remove redundant array structure
SutuSebastian Apr 4, 2024
afc5490
chore: simplify turbo configs + fix `packages/ui` outputs path
SutuSebastian Apr 4, 2024
e4cf84f
chore: update docs introduction and installation guides to new config
SutuSebastian Apr 4, 2024
c9824ba
fix: docs redwood guide tailwind config path
SutuSebastian Apr 4, 2024
c610613
chore: remove comment
SutuSebastian Apr 4, 2024
9c6a7b3
fix: docs redwood guide tailwind config path typo
SutuSebastian Apr 4, 2024
f8f6e78
chore: add changeset
SutuSebastian Apr 4, 2024
70f804d
Update .changeset/hungry-toys-care.md
SutuSebastian Apr 4, 2024
ab9e16b
Update .changeset/hungry-toys-care.md
SutuSebastian Apr 4, 2024
41b0f1b
Update .changeset/hungry-toys-care.md
SutuSebastian Apr 4, 2024
82ec7ed
Update .changeset/hungry-toys-care.md
SutuSebastian Apr 4, 2024
50c7cdd
chore: bump version minor
SutuSebastian Apr 4, 2024
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
63 changes: 63 additions & 0 deletions .changeset/hungry-toys-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
"flowbite-react": minor
---

## Rework build process using `rollup` and `tsc`

### Summary

In order to bring more performance to the build process of `flowbite-react` package, we have to consider transpiling the files using other tools rather than `tsc`, which is very slow.

After evaluating various tools including `tsup`, `tshy`, and `bun build`, we chose `rollup` with the `esbuild` plugin for transpiling due to its performance and flexibility. We continue to use `tsc` solely for generating `*.d.ts` declaration files.

### Changes

- added `rollup` + `esbuild` for transpiling files
- all files in the `cjs` directory now have `.cjs` extension
- all files in the `esm` directory now have `.mjs` extension
- declaration file types (`*.d.ts`) have been moved from `dist/esm` to `dist/types`
- changed the build output dir from `lib` to `dist`
- created a facade layer for easier management of the `content` path as well as the `plugin`
- fixed turbo repo dependency tree configs in order for `apps/web` to properly pipe and require the build output of `packages/ui` in certain script steps such as `build` and `dev`

### Breaking changes

`tailwind.config.js` `content` path:

old: `"node_modules/flowbite-react/lib/esm/**/*.js"`

new: `"node_modules/flowbite-react/dist/esm/**/*.mjs"` - (`flowbite.content()` returns it)

Before

```js {5,9}
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
],
plugins: [
// ...
require("flowbite/plugin"),
],
};
```

After

```js {1,7,11}
const flowbite = require("flowbite-react/tailwind");

/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
// ...
flowbite.content(),
],
plugins: [
// ...
flowbite.plugin(),
],
};
```
39 changes: 8 additions & 31 deletions apps/web/content/docs/getting-started/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,7 @@ Learn how to get started with Flowbite React and start leveraging the interactiv

### Setup Tailwind CSS

Install Tailwind CSS:

```bash
npm i autoprefixer postcss tailwindcss
npx tailwindcss init -p
```

Point Tailwind CSS to files you have `className=".."` in:

```javascript
module.exports = {
content: ["./src/**/*.{js,jsx,ts,tsx}" /* src folder, for example */],
theme: {
extend: {},
},
plugins: [],
};
```

Add Tailwind CSS to a CSS file:

```css
@tailwind base;
@tailwind components;
@tailwind utilities;
```
Install Tailwind CSS by following the [official installation guide](https://tailwindcss.com/docs/installation).

### Install Flowbite React

Expand All @@ -48,18 +23,20 @@ Add Tailwind CSS to a CSS file:
npm i flowbite-react
```

2. Add the Flowbite plugin to `tailwind.config.js`, and include content from `flowbite-react`:
2. Add the Flowbite React `content` path and `plugin` to `tailwind.config.js`:

```js {1,7,11}
const flowbite = require("flowbite-react/tailwind");

```js {5,9}
/** @type {import('tailwindcss').Config} */
export default {
module.exports = {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content(),
],
plugins: [
// ...
require("flowbite/plugin"),
flowbite.plugin(),
],
};
```
Expand Down
10 changes: 6 additions & 4 deletions apps/web/content/docs/guides/astro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,20 @@ npx astro add tailwind
npm i flowbite-react
```

2. Add the Flowbite plugin to `tailwind.config.mjs` and include content from `flowbite-react`:
2. Add the Flowbite React `content` path and `plugin` to `tailwind.config.mjs`:

```js {1,7,11}
import flowbite from "flowbite-react/tailwind";

```js {5,9}
/** @type {import('tailwindcss').Config} */
export default {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content(),
],
plugins: [
// ...
require("flowbite/plugin"),
flowbite.plugin(),
],
};
```
Expand Down
12 changes: 7 additions & 5 deletions apps/web/content/docs/guides/create-react-app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,20 @@ module.exports = {
npm i flowbite-react
```

2. Add the Flowbite plugin to `tailwind.config.js` and include content from `flowbite-react`:
2. Add the Flowbite React `content` path and `plugin` to `tailwind.config.js`:

```js {1,7,11}
const flowbite = require("flowbite-react/tailwind");

```js {5,9}
/** @type {import('tailwindcss').Config} */
export default {
module.exports = {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content(),
],
plugins: [
// ...
require("flowbite/plugin"),
flowbite.plugin(),
],
};
```
Expand Down
10 changes: 6 additions & 4 deletions apps/web/content/docs/guides/gatsby.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,20 @@ npm init gatsby
npm i flowbite-react
```

2. Add the Flowbite plugin to `tailwind.config.js` and include content from `flowbite-react`:
2. Add the Flowbite React `content` path and `plugin` to `tailwind.config.js`:

```js {1,7,11}
import flowbite from "flowbite-react/tailwind";

```js {5,9}
/** @type {import('tailwindcss').Config} */
export default {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content(),
],
plugins: [
// ...
require("flowbite/plugin"),
flowbite.plugin(),
],
};
```
Expand Down
10 changes: 6 additions & 4 deletions apps/web/content/docs/guides/laravel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,20 @@ laravel new flowbite-react-laravel --breeze --stack=react
npm i flowbite-react
```

2. Add the Flowbite plugin to `tailwind.config.js` and include content from `flowbite-react`:
2. Add the Flowbite React `content` path and `plugin` to `tailwind.config.js`:

```js {1,7,11}
import flowbite from "flowbite-react/tailwind";

```js {5,9}
/** @type {import('tailwindcss').Config} */
export default {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content(),
],
plugins: [
// ...
require("flowbite/plugin"),
flowbite.plugin(),
],
};
```
Expand Down
22 changes: 13 additions & 9 deletions apps/web/content/docs/guides/next-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,20 @@ npm i flowbite-react

### Configure Tailwind CSS

Open `tailwind.config.js` and update `content` and `plugins` to include Flowbite React:
Open `tailwind.config.ts` and update `content` and `plugins` to include Flowbite React:

```js {1,7,11}
import flowbite from "flowbite-react/tailwind";

```js {5,9}
/** @type {import('tailwindcss').Config} */
export default {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content(),
],
plugins: [
// ...
require("flowbite/plugin"),
flowbite.plugin(),
],
};
```
Expand Down Expand Up @@ -115,18 +117,20 @@ module.exports = {
npm i flowbite-react
```

2. Add the Flowbite plugin to `tailwind.config.js` and include content from `flowbite-react`:
2. Add the Flowbite React `content` path and `plugin` to `tailwind.config.js`:

```js {1,7,11}
const flowbite = require("flowbite-react/tailwind");

```js {5,9}
/** @type {import('tailwindcss').Config} */
export default {
module.exports = {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content(),
],
plugins: [
// ...
require("flowbite/plugin"),
flowbite.plugin(),
],
};
```
Expand Down
12 changes: 7 additions & 5 deletions apps/web/content/docs/guides/parcel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,20 @@ module.exports = {
npm i flowbite-react
```

2. Add the Flowbite plugin to `tailwind.config.js` and include content from `flowbite-react`:
2. Add the Flowbite React `content` path and `plugin` to `tailwind.config.js`:

```js {1,7,11}
const flowbite = require("flowbite-react/tailwind");

```js {5,9}
/** @type {import('tailwindcss').Config} */
export default {
module.exports = {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content(),
],
plugins: [
// ...
require("flowbite/plugin"),
flowbite.plugin(),
],
};
```
Expand Down
10 changes: 6 additions & 4 deletions apps/web/content/docs/guides/redwood-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,20 @@ yarn rw setup ui tailwindcss
yarn workspace web add flowbite-react
```

2. Add the Flowbite plugin to `tailwind.config.js` and include content from `flowbite-react`:
2. Add the Flowbite React `content` path and `plugin` to `web/config/tailwind.config.js`:

```js {1,7,11}
const flowbite = require("flowbite-react/tailwind");

```js {5,9}
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
// ...
"../node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content({ base: "../" }),
],
plugins: [
// ...
require("flowbite/plugin"),
flowbite.plugin(),
],
};
```
Expand Down
8 changes: 4 additions & 4 deletions apps/web/content/docs/guides/remix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@ export const links: LinksFunction = () => [
npm i flowbite-react
```

2. Add the Flowbite plugin to `tailwind.config.ts` and include content from `flowbite-react`:
2. Add the Flowbite React `content` path and `plugin` to `tailwind.config.ts`:

```ts {1,8,12}
import flowbite from "flowbite/plugin";
import flowbite from "flowbite-react/tailwind";

import type { Config } from "tailwindcss";

export default {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content(),
],
plugins: [
// ...
flowbite,
flowbite.plugin(),
],
} satisfies Config;
```
Expand Down
12 changes: 7 additions & 5 deletions apps/web/content/docs/guides/vite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,20 @@ module.exports = {
npm i flowbite-react
```

2. Add the Flowbite plugin to `tailwind.config.js` and include content from `flowbite-react`:
2. Add the Flowbite React `content` path and `plugin` to `tailwind.config.js`:

```js {1,7,11}
const flowbite = require("flowbite-react/tailwind");

```js {5,9}
/** @type {import('tailwindcss').Config} */
export default {
module.exports = {
content: [
// ...
"node_modules/flowbite-react/lib/esm/**/*.js",
flowbite.content(),
],
plugins: [
// ...
require("flowbite/plugin"),
flowbite.plugin(),
],
};
```
Expand Down
Loading
Loading