diff options
author | 2023-08-03 16:31:05 -0700 | |
---|---|---|
committer | 2023-08-03 16:31:05 -0700 | |
commit | 112030481f3d89bb45cf9cecb2b21530bb53398c (patch) | |
tree | e2d57f7bd56179a2c6d84c4a7a18ef59b59f660a /docs | |
parent | 9574db355f1435f60214726b21f1ca5bb9d13f6c (diff) | |
download | bun-112030481f3d89bb45cf9cecb2b21530bb53398c.tar.gz bun-112030481f3d89bb45cf9cecb2b21530bb53398c.tar.zst bun-112030481f3d89bb45cf9cecb2b21530bb53398c.zip |
More guides and fixing links (#3960)bun-v0.7.2
* More guides
* WIP
* Updates
* Fix
Diffstat (limited to 'docs')
-rw-r--r-- | docs/api/file-io.md | 4 | ||||
-rw-r--r-- | docs/api/globals.md | 6 | ||||
-rw-r--r-- | docs/ecosystem/express.md | 2 | ||||
-rw-r--r-- | docs/guides/ecosystem/express.md | 2 | ||||
-rw-r--r-- | docs/guides/ecosystem/nextjs.md | 31 | ||||
-rw-r--r-- | docs/guides/install/yarnlock.md | 42 | ||||
-rw-r--r-- | docs/guides/process/spawn-stderr.md | 2 | ||||
-rw-r--r-- | docs/guides/process/spawn-stdout.md | 2 | ||||
-rw-r--r-- | docs/guides/process/spawn.md | 2 | ||||
-rw-r--r-- | docs/guides/read-file/stream.md | 4 | ||||
-rw-r--r-- | docs/guides/util/base64.md | 2 | ||||
-rw-r--r-- | docs/runtime/web-apis.md | 2 |
12 files changed, 87 insertions, 14 deletions
diff --git a/docs/api/file-io.md b/docs/api/file-io.md index be9cf0991..e141c8b17 100644 --- a/docs/api/file-io.md +++ b/docs/api/file-io.md @@ -1,8 +1,8 @@ {% callout %} -<!-- **Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. Existing Node.js projects may use Bun's [nearly complete](/docs/runtime/nodejs-apis#node_fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module. --> +<!-- **Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. Existing Node.js projects may use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module. --> -**Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with `Bun.file`, such as `mkdir`, you can use Bun's [nearly complete](/docs/runtime/nodejs-apis#node_fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module. +**Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with `Bun.file`, such as `mkdir`, you can use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module. {% /callout %} diff --git a/docs/api/globals.md b/docs/api/globals.md index 370dd3800..fe7cd60c6 100644 --- a/docs/api/globals.md +++ b/docs/api/globals.md @@ -34,7 +34,7 @@ Bun implements the following globals. - [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) - Node.js -- See [Node.js > `Buffer`](/docs/runtime/nodejs-apis#node_buffer) +- See [Node.js > `Buffer`](/docs/runtime/nodejs-apis#node-buffer) --- @@ -172,7 +172,7 @@ Bun implements the following globals. - [`global`](https://nodejs.org/api/globals.html#global) - Node.js -- See [Node.js > `global`](/docs/runtime/nodejs-apis#node_global). +- See [Node.js > `global`](/docs/runtime/nodejs-apis#global). --- @@ -220,7 +220,7 @@ Bun implements the following globals. - [`process`](https://nodejs.org/api/process.html) - Node.js -- See [Node.js > `process`](/docs/runtime/nodejs-apis#node_process) +- See [Node.js > `process`](/docs/runtime/nodejs-apis#node-process) --- diff --git a/docs/ecosystem/express.md b/docs/ecosystem/express.md index bbca048ab..8f1fccae1 100644 --- a/docs/ecosystem/express.md +++ b/docs/ecosystem/express.md @@ -22,7 +22,7 @@ app.listen(port, () => { Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on. These modules can also be used directly, though [`Bun.serve`](/docs/api/http) is recommended for most use cases. {% callout %} -**Note** — Refer to the [Runtime > Node.js APIs](/docs/runtime/nodejs-apis#node_http) page for more detailed compatibility information. +**Note** — Refer to the [Runtime > Node.js APIs](/docs/runtime/nodejs-apis#node-http) page for more detailed compatibility information. {% /callout %} ```ts diff --git a/docs/guides/ecosystem/express.md b/docs/guides/ecosystem/express.md index 211e117c4..6042b17e4 100644 --- a/docs/guides/ecosystem/express.md +++ b/docs/guides/ecosystem/express.md @@ -5,7 +5,7 @@ name: Build an HTTP server using Express and Bun Express and other major Node.js HTTP libraries should work out of the box. Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on. {% callout %} -Refer to the [Runtime > Node.js APIs](/docs/runtime/nodejs-apis#node_http) page for more detailed compatibility information. +Refer to the [Runtime > Node.js APIs](/docs/runtime/nodejs-apis#node-http) page for more detailed compatibility information. {% /callout %} ```sh diff --git a/docs/guides/ecosystem/nextjs.md b/docs/guides/ecosystem/nextjs.md new file mode 100644 index 000000000..b8b45ca59 --- /dev/null +++ b/docs/guides/ecosystem/nextjs.md @@ -0,0 +1,31 @@ +--- +name: Build an app with Next.js and Bun +--- + +{% callout %} +Next.js currently relies on Node.js APIs that Bun does not yet implement. The guide below uses Bun to initialize a project and install dependencies, but it uses Node.js to run the dev server. +{% /callout %} + +--- + +Initialize a Next.js app with `create-next-app`. This automatically installs dependencies using `npm`. + +```sh +$ bunx create-next-app +✔ What is your project named? … my-app +✔ Would you like to use TypeScript with this project? … No / Yes +✔ Would you like to use ESLint with this project? … No / Yes +✔ Would you like to use `src/` directory with this project? … No / Yes +✔ Would you like to use experimental `app/` directory with this project? … No / Yes +✔ What import alias would you like configured? … @/* +Creating a new Next.js app in /path/to/my-app. +``` + +--- + +To start the dev server, run `bun run dev` from the project root. + +```sh +$ cd my-app +$ bun run dev +``` diff --git a/docs/guides/install/yarnlock.md b/docs/guides/install/yarnlock.md new file mode 100644 index 000000000..898df634d --- /dev/null +++ b/docs/guides/install/yarnlock.md @@ -0,0 +1,42 @@ +--- +name: Generate a human-readable lockfile +--- + +By default Bun generates a binary `bun.lockb` file when you run `bun install`. In some cases, it's preferable to generate a human-readable lockfile instead. + +--- + +Use the `--yarn` flag to generate a Yarn-compatible `yarn.lock` file (in addition to `bun.lockb`). + +```sh +$ bun install --yarn +``` + +--- + +To set this as the default behavior, add the following to your `bunfig.toml` file. + +```toml#bunfig.toml +[install] +print = "yarn" +``` + +--- + +To print a Yarn lockfile to your console without writing it to disk, just "run" your `bun.lockb` with `bun`. + +```sh +$ bun bun.lockb +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 +# bun ./bun.lockb --hash: 9BFBF11D86084AAB-9418b03ff880c569-390CE6459EACEC9A... + +abab@^2.0.6: + version "2.0.6" + resolved "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz" + integrity sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvH... +``` + +--- + +See [Docs > Package manager](/docs/cli/install) for complete documentation of Bun's package manager. diff --git a/docs/guides/process/spawn-stderr.md b/docs/guides/process/spawn-stderr.md index 3ea56b24e..9e9e8da99 100644 --- a/docs/guides/process/spawn-stderr.md +++ b/docs/guides/process/spawn-stderr.md @@ -28,4 +28,4 @@ if (errors) { --- -See [Docs > API > Child processes](/docs/api/spawn) for complete documentation.. +See [Docs > API > Child processes](/docs/api/spawn) for complete documentation. diff --git a/docs/guides/process/spawn-stdout.md b/docs/guides/process/spawn-stdout.md index 490e8b143..e73fe59a0 100644 --- a/docs/guides/process/spawn-stdout.md +++ b/docs/guides/process/spawn-stdout.md @@ -23,4 +23,4 @@ const proc = Bun.spawn(["echo", "hello"], { --- -See [Docs > API > Child processes](/docs/api/spawn) for complete documentation.. +See [Docs > API > Child processes](/docs/api/spawn) for complete documentation. diff --git a/docs/guides/process/spawn.md b/docs/guides/process/spawn.md index 2a6589458..f0fca8e8a 100644 --- a/docs/guides/process/spawn.md +++ b/docs/guides/process/spawn.md @@ -38,4 +38,4 @@ output; // => "hello" --- -See [Docs > API > Child processes](/docs/api/spawn) for complete documentation.. +See [Docs > API > Child processes](/docs/api/spawn) for complete documentation. diff --git a/docs/guides/read-file/stream.md b/docs/guides/read-file/stream.md index 6b88c3672..ac4bd9e2f 100644 --- a/docs/guides/read-file/stream.md +++ b/docs/guides/read-file/stream.md @@ -13,10 +13,10 @@ const stream = await file.stream(); --- -The chunks of the stream can be consumed with `for await`. +The chunks of the stream can be consumed as an [async iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols) using `for await`. ```ts -for await (const chunk of stream.values()) { +for await (const chunk of stream) { chunk; // => Uint8Array } ``` diff --git a/docs/guides/util/base64.md b/docs/guides/util/base64.md index 06003f062..bbc8f0906 100644 --- a/docs/guides/util/base64.md +++ b/docs/guides/util/base64.md @@ -12,4 +12,4 @@ const decoded = atob(encoded); // => "hello world" --- -See [Docs > API > Hashing](/docs/api/hashing#bun-password) for complete documentation. +See [Docs > Web APIs](/docs/runtime/web-apis) for a complete breakdown of the Web APIs implemented in Bun. diff --git a/docs/runtime/web-apis.md b/docs/runtime/web-apis.md index 366fa7819..f2731a733 100644 --- a/docs/runtime/web-apis.md +++ b/docs/runtime/web-apis.md @@ -17,7 +17,7 @@ The following Web APIs are partially or completely supported. --- - Web Workers -- [`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker) [`self.postMessage`](https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/postMessage) [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone). Missing `MessagePort`, `MessageChannel`, `BroadcastChannel`. +- [`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker) [`self.postMessage`](https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/postMessage) [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone) [`MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort) [`MessageChannel`](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel). Missing `BroadcastChannel`. --- |