aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/runtime
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-07-31 12:20:23 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-31 12:20:23 -0700
commit404b90badc5856a74c06d04062c850003e28fed5 (patch)
tree7954623cf4a792db612d0bb229a227c2ff1e9fd8 /docs/guides/runtime
parent67599f97adc77141331a5f4fc39e4d058dc70b2a (diff)
downloadbun-404b90badc5856a74c06d04062c850003e28fed5.tar.gz
bun-404b90badc5856a74c06d04062c850003e28fed5.tar.zst
bun-404b90badc5856a74c06d04062c850003e28fed5.zip
Add ecosystem guides (#3847)
* Add ecosystem guides * Update titles * Rename stric * Add unlink and fetch guides * Add formdata guide * Tweak title * Moar
Diffstat (limited to 'docs/guides/runtime')
-rw-r--r--docs/guides/runtime/cicd.md43
-rw-r--r--docs/guides/runtime/import-json.md32
-rw-r--r--docs/guides/runtime/import-toml.md30
-rw-r--r--docs/guides/runtime/index.json4
-rw-r--r--docs/guides/runtime/tsconfig-paths.md29
5 files changed, 138 insertions, 0 deletions
diff --git a/docs/guides/runtime/cicd.md b/docs/guides/runtime/cicd.md
new file mode 100644
index 000000000..6dfef2ddd
--- /dev/null
+++ b/docs/guides/runtime/cicd.md
@@ -0,0 +1,43 @@
+---
+name: Install and run Bun in GitHub Actions
+---
+
+Use the official [`setup-bun`](https://github.com/oven-sh/setup-bun) GitHub Action to install `bun` in your GitHub Actions runner.
+
+```yaml-diff#workflow.yml
+name: my-workflow
+jobs:
+ my-job:
+ name: my-job
+ runs-on: ubuntu-latest
+ steps:
+ # ...
+ - uses: actions/checkout@v3
++ - uses: oven-sh/setup-bun@v1
+
+ # run any `bun` or `bunx` command
++ - run: bun install
++ - run: bun index.ts
++ - run: bun run build
+```
+
+---
+
+To specify a version of Bun to install:
+
+```yaml-diff#workflow.yml
+name: my-workflow
+jobs:
+ my-job:
+ name: my-job
+ runs-on: ubuntu-latest
+ steps:
+ # ...
+ - uses: oven-sh/setup-bun@v1
++ with:
++ version: 0.7.0 # or "canary"
+```
+
+---
+
+Refer to the [README.md](https://github.com/oven-sh/setup-bun) for complete documentation of the `setup-bun` GitHub Action.
diff --git a/docs/guides/runtime/import-json.md b/docs/guides/runtime/import-json.md
new file mode 100644
index 000000000..3db2daaea
--- /dev/null
+++ b/docs/guides/runtime/import-json.md
@@ -0,0 +1,32 @@
+---
+name: Import a JSON file
+---
+
+Bun natively supports `.json` imports.
+
+```json#package.json
+{
+ "name": "bun",
+ "version": "1.0.0",
+ "author": {
+ "name": "John Dough",
+ "email": "john@dough.com"
+ }
+}
+```
+
+---
+
+Import the file like any other source file.
+
+```ts
+import data from "./package.json";
+
+data.name; // => "bun"
+data.version; // => "1.0.0"
+data.author.name; // => "John Dough"
+```
+
+---
+
+See [Docs > Runtime > TypeScript](/docs/runtime/typescript) for more information on using TypeScript with Bun.
diff --git a/docs/guides/runtime/import-toml.md b/docs/guides/runtime/import-toml.md
new file mode 100644
index 000000000..2a2e47aa4
--- /dev/null
+++ b/docs/guides/runtime/import-toml.md
@@ -0,0 +1,30 @@
+---
+name: Import a TOML file
+---
+
+Bun natively supports importing `.toml` files.
+
+```toml#data.toml
+name = "bun"
+version = "1.0.0"
+
+[author]
+name = "John Dough"
+email = "john@dough.com"
+```
+
+---
+
+Import the file like any other source file.
+
+```ts
+import data from "./data.toml";
+
+data.name; // => "bun"
+data.version; // => "1.0.0"
+data.author.name; // => "John Dough"
+```
+
+---
+
+See [Docs > Runtime > TypeScript](/docs/runtime/typescript) for more information on using TypeScript with Bun.
diff --git a/docs/guides/runtime/index.json b/docs/guides/runtime/index.json
new file mode 100644
index 000000000..fad27c69d
--- /dev/null
+++ b/docs/guides/runtime/index.json
@@ -0,0 +1,4 @@
+{
+ "name": "Runtime",
+ "description": "A collection of guides for executing code with the Bun runtime"
+}
diff --git a/docs/guides/runtime/tsconfig-paths.md b/docs/guides/runtime/tsconfig-paths.md
new file mode 100644
index 000000000..5c3f591f5
--- /dev/null
+++ b/docs/guides/runtime/tsconfig-paths.md
@@ -0,0 +1,29 @@
+---
+name: Re-map import paths
+---
+
+Bun reads the `paths` field in your `tsconfig.json` to re-write import paths. This is useful for aliasing package names or avoiding long relative paths.
+
+```json
+{
+ "compilerOptions": {
+ "paths": {
+ "my-custom-name": "zod",
+ "@components/*": "./src/components/*"
+ }
+ }
+}
+```
+
+---
+
+With the above `tsconfig.json`, the following imports will be re-written:
+
+```ts
+import { z } from "my-custom-name"; // imports from "zod"
+import { Button } from "@components/Button"; // imports from "./src/components/Button"
+```
+
+---
+
+See [Docs > Runtime > TypeScript](/docs/runtime/typescript) for more information on using TypeScript with Bun.