diff options
Diffstat (limited to '')
-rw-r--r-- | docs/bundler/index.md (renamed from docs/cli/build.md) | 0 | ||||
-rw-r--r-- | docs/bundler/loaders.md | 2 | ||||
-rw-r--r-- | docs/bundler/plugins.md | 14 | ||||
-rw-r--r-- | docs/bundler/vs-esbuild.md (renamed from docs/bundler/migration.md) | 6 |
4 files changed, 16 insertions, 6 deletions
diff --git a/docs/cli/build.md b/docs/bundler/index.md index e0cd36651..e0cd36651 100644 --- a/docs/cli/build.md +++ b/docs/bundler/index.md diff --git a/docs/bundler/loaders.md b/docs/bundler/loaders.md index b06f07175..2dc5103df 100644 --- a/docs/bundler/loaders.md +++ b/docs/bundler/loaders.md @@ -221,7 +221,7 @@ If a value is specified for `publicPath`, the import will use value as a prefix {% /table %} {% callout %} -The location and file name of the copied file is determined by the value of [`naming.asset`](/docs/cli/build#naming). +The location and file name of the copied file is determined by the value of [`naming.asset`](/docs/bundler#naming). {% /callout %} This loader is copied into the `outdir` as-is. The name of the copied file is determined using the value of `naming.asset`. diff --git a/docs/bundler/plugins.md b/docs/bundler/plugins.md index 37f8ce66e..4e0fafee5 100644 --- a/docs/bundler/plugins.md +++ b/docs/bundler/plugins.md @@ -31,6 +31,16 @@ Bun.build({ }); ``` +<!-- It can also be "registered" with the Bun runtime using the `Bun.plugin()` function. Once registered, the currently executing `bun` process will incorporate the plugin into its module resolution algorithm. + +```ts +import {plugin} from "bun"; + +plugin(myPlugin); +``` --> + +## `--preload` + To consume this plugin, add this file to the `preload` option in your [`bunfig.toml`](/docs/runtime/configuration). Bun automatically loads the files/modules specified in `preload` before running a file. ```toml @@ -74,7 +84,7 @@ plugin( // application code ``` -Bun's plugin API is based on [esbuild](https://esbuild.github.io/plugins). Only [a subset](/docs/bundler/migration#plugin-api) of the esbuild API is implemented, but some esbuild plugins "just work" in Bun, like the official [MDX loader](https://mdxjs.com/packages/esbuild/): +Bun's plugin API is based on [esbuild](https://esbuild.github.io/plugins). Only [a subset](/docs/bundler/vs-esbuild#plugin-api) of the esbuild API is implemented, but some esbuild plugins "just work" in Bun, like the official [MDX loader](https://mdxjs.com/packages/esbuild/): ```jsx import { plugin } from "bun"; @@ -268,7 +278,7 @@ console.log(mySvelteComponent.render()); ## Reading `Bun.build`'s config -Plugins can read and write to the [build config](/docs/cli/build#api) with `build.config`. +Plugins can read and write to the [build config](/docs/bundler#api) with `build.config`. ```ts Bun.build({ diff --git a/docs/bundler/migration.md b/docs/bundler/vs-esbuild.md index 1bf9d52dc..5ccde1a1f 100644 --- a/docs/bundler/migration.md +++ b/docs/bundler/vs-esbuild.md @@ -1,5 +1,5 @@ {% callout %} -**Note** — Available in the Bun v0.6.0 nightly. Run `bun upgrade --canary` to try it out. +**Note** — Available in Bun v0.6.0 and later. {% /callout %} Bun's bundler API is inspired heavily by [esbuild](https://esbuild.github.io/). Migrating to Bun's bundler from esbuild should be relatively painless. This guide will briefly explain why you might consider migrating to Bun's bundler and provide a side-by-side API comparison reference for those who are already familiar with esbuild's API. @@ -11,9 +11,9 @@ There are a few behavioral differences to note. ## Performance -This is the simplest reason to migrate to Bun's bundler. With an performance-minded API inspired by esbuild coupled with the extensively optimized Zig-based JS/TS parser, Bun's bundler is roughly 50% faster than esbuild on most benchmarks. +With an performance-minded API coupled with the extensively optimized Zig-based JS/TS parser, Bun's bundler is 1.75x faster than esbuild on esbuild's [three.js benchmark](https://github.com/oven-sh/bun/tree/main/bench/bundle). -IMAGE HERE +{% image src="/images/bundler-speed.png" caption="Bundling 10 copies of three.js from scratch, with sourcemaps and minification" /%} ## CLI API |