Compare commits

...

2 Commits

Author SHA1 Message Date
autofix-ci[bot]
c27e0e14b6 [autofix.ci] apply automated fixes 2025-08-04 12:14:59 +00:00
Claude Bot
50983179ee docs(bundler): add documentation for undocumented bundler features
Add compact documentation for previously undocumented bundler features:

**CLI Flags:**
- `--emit-dce-annotations` - Re-emit DCE annotations in output
- `--ignore-dce-annotations` - Ignore tree-shaking annotations
- `--css-chunking` - Chunk shared CSS across entry points
- `--server-components` - Enable React Server Components (experimental)

**JavaScript API:**
- `reactFastRefresh` - Enable React Fast Refresh for development
- `hotModuleReloading` - Enable HMR support

Features were verified against source code in src/cli/ and src/options.zig.
Documentation added to appropriate existing pages rather than creating new files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-04 12:11:32 +00:00
4 changed files with 43 additions and 2 deletions

View File

@@ -5,6 +5,16 @@ Bun's bundler has built-in support for CSS with the following features:
- CSS Modules
- Tailwind (via a native bundler plugin)
## CSS Chunking
When multiple entry points import the same CSS files, use `--css-chunking` to reduce duplication by grouping shared CSS into separate chunks:
```bash
bun build ./home.ts ./about.ts --css-chunking --outdir ./dist
```
This creates separate CSS files for shared imports, reducing total CSS size in multi-page applications.
## Transpiling
Bun's CSS bundler lets you use modern/future CSS features without having to worry about browser compatibility — all thanks to its transpiling and vendor prefixing features which are enabled by default.

View File

@@ -174,6 +174,18 @@ export function App() {
{% /codetabs %}
### Server Components (Experimental)
Enable React Server Components with `--server-components` (requires server-side target):
```bash
bun build ./app/page.tsx --server-components --target bun --outdir ./dist
```
{% callout %}
Server Components support is experimental and the API may change.
{% /callout %}
### Development mode
When building locally, enable development mode by setting `development: true` in `Bun.serve()`.

View File

@@ -4,6 +4,18 @@ state and improves the development experience.
HMR is enabled by default when using Bun's full-stack development server.
## React Fast Refresh
For React applications, enable React Fast Refresh for component-level hot reloading:
```typescript
await Bun.build({
entrypoints: ["./src/App.tsx"],
reactFastRefresh: true,
hotModuleReloading: true,
});
```
## `import.meta.hot` API Reference
Bun implements a client-side HMR API modeled after [Vite's `import.meta.hot` API](https://vitejs.dev/guide/api-hmr.html). It can be checked for with `if (import.meta.hot)`, tree-shaking it in production

View File

@@ -773,9 +773,16 @@ $ bun build ./index.tsx --outdir ./out --minify-whitespace --minify-identifiers
{% /codetabs %}
<!-- ### `treeshaking`
#### DCE annotations
boolean; -->
Control dead code elimination annotations like `@__PURE__`:
- `--emit-dce-annotations` - Re-emit DCE annotations in output (default: enabled unless `--minify-whitespace`)
- `--ignore-dce-annotations` - Ignore tree-shaking annotations
```bash
$ bun build ./index.tsx --ignore-dce-annotations --minify
```
### `external`