# Build JavaScript at the Edge

> Bundle, transform, and minify JavaScript/TypeScript at the edge with instant HMR and automatic tree-shaking for production-ready builds.

Canonical: https://esbuild.do/

## In code

```ts
import { Esbuild } from 'esbuild.do'

// Transform TypeScript at the edge in <10ms
on.Request.to.API(async $ => {
  const result = await Esbuild.transform({
    code: $.body,
    loader: 'tsx',
    minify: true
  })
  return $.Response.json({ code: result.code, buildTime: result.duration })
})

// Auto-rebuild and hot reload on file changes
on.File.changed($ => $.Esbuild.rebuild().then(b => $.DevServer.reload(b)))
```

## Frequently asked questions

### Why is esbuild.do faster than traditional bundlers?

Esbuild uses native Go (100x faster than JavaScript bundlers) with edge execution for zero cold starts. Transform TypeScript/JSX in <10ms vs 10-60 seconds with traditional bundlers like Webpack.

### Does it support all TypeScript and JSX features?

Yes, full TypeScript type stripping, JSX/TSX, decorators, class fields, and all ES2015+ features. Source maps, declaration files, and watch mode work seamlessly.

### How does tree-shaking and code splitting work?

Automatic dead code elimination removes unused exports, reducing bundle sizes by 40-70%. Code splitting generates optimal chunks with shared dependencies extracted automatically.

### Can I use custom esbuild plugins?

Yes, import plugins for CSS modules, SASS, Vue, Svelte, or custom loaders that run at the edge. Common plugins (CSS, images, web workers) are built-in and optimized.

### What about development workflow and hot reload?

Built-in dev server with instant HMR preserving application state and perfect source map support. Watch mode triggers rebuilds in <5ms for incremental changes.

## Part of Platform.do

esbuild.do is one of the primitives of Platform.do, in the Build layer (ship from code, cli or mcp). Every .do shares one grammar, Business-as-Code, and one SDK.

- What is Business-as-Code? https://platform.do/business-as-code
- Platform.do: https://platform.do/
- Docs: https://docs.platform.do
