package
The official YAML plugin for Bun. Adds support for `.yml`/`.yaml` imports.
npm install bun-plugin-yamlGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Estimated unpacked size across 3 packages.
1.7 MB
Includes dependencies.
Latest published May 3, 2023
bun-plugin-yamlThe official YAML plugin for Bun. Adds support for .yml/.yaml imports.
bun add bun-plugin-yaml -dThis plugin can be used to support .yaml loaders in Bun's bundler by passing it into the plugins array:
import yamlPlugin from "bun-plugin-yaml";
Bun.build({
entrypoints: ["./index.tsx"],
// other config
plugins: [yamlPlugin()],
});You can now import .yaml files from your source code:
import data from "./data.yaml";
export function Component() {
return <div>{data.name}</div>;
}The contents of the .yaml file will be inlined into your bundle.
To use as a runtime plugin, create a file that registers the plugin:
// yaml.ts
import yamlPlugin from "bun-plugin-yaml";
Bun.plugin(yamlPlugin());Then preload it in your bunfig.toml:
preload = ["./yaml.ts"]By default VSCode/TypeScript will not recognize .yaml imports. To avoid import errors, add the following to your tsconfig.json:
{
"compilerOptions": {
"types": [
// other packages, e.g. "bun-types",
+ "bun-plugin-yaml"
]
}
}$ bun install # project setup
$ bun test # run tests