diff options
author | 2023-09-19 16:31:38 -0700 | |
---|---|---|
committer | 2023-09-19 16:31:38 -0700 | |
commit | 4fce34854be8e1f29bf89f02f7a2541ef5e1d3a8 (patch) | |
tree | 48873680c39417eb97a62a341a6cf217318efd40 /docs/runtime | |
parent | 615beee1ae0fd9b299fc38ac0989d4be5899c19b (diff) | |
download | bun-4fce34854be8e1f29bf89f02f7a2541ef5e1d3a8.tar.gz bun-4fce34854be8e1f29bf89f02f7a2541ef5e1d3a8.tar.zst bun-4fce34854be8e1f29bf89f02f7a2541ef5e1d3a8.zip |
Doc updates (#5759)
* WIP
* WIP
Diffstat (limited to 'docs/runtime')
-rw-r--r-- | docs/runtime/plugins.md | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/docs/runtime/plugins.md b/docs/runtime/plugins.md index 8f5bf21e2..a422fdc40 100644 --- a/docs/runtime/plugins.md +++ b/docs/runtime/plugins.md @@ -61,7 +61,7 @@ Plugins are primarily used to extend Bun with loaders for additional file types. ```ts#yamlPlugin.ts import { plugin } from "bun"; -plugin({ +await plugin({ name: "YAML", async setup(build) { const { load } = await import("js-yaml"); @@ -84,15 +84,20 @@ plugin({ }); ``` -With this plugin, data can be directly imported from `.yaml` files. +Register this file in `preload`: + +```toml#bunfig.toml +preload = ["./yamlPlugin.ts"] +``` + +Once the plugin is registed, `.yaml` and `.yml` files can be directly imported. {% codetabs %} ```ts#index.ts -import "./yamlPlugin.ts" -import {name, releaseYear} from "./data.yml" +import data from "./data.yml" -console.log(name, releaseYear); +console.log(data); ``` ```yaml#data.yml |