@aphrody/bun-plugin-yaml
Bun的官方YAML插件. 添加对 .yml编号 :.yaml 进口.
安装
bun add @aphrody/bun-plugin-yaml -d
Bundler 用户
此插件可用于支持 .yaml 装入Bun的捆绑箱的装填器通过传入 plugins 数组 :
import yamlPlugin from "@aphrody/bun-plugin-yaml";
await Bun.build({
entrypoints: ["./index.tsx"],
// other config
plugins: [yamlPlugin()],
});
您现在可以导入 .yaml 来自源代码的文件 :
import data from "./data.yaml";
export function Component() {
return <div>{data.name}</div>;
}
报告的内容 .yaml 文件将包含在您的捆绑中.
运行时间使用情况
要用作运行时插件, 请创建一个注册插件的文件 :
// yaml.ts
import yamlPlugin from "@aphrody/bun-plugin-yaml";
Bun.plugin(yamlPlugin());
准备装入你的 bunfig.toml数字 :
preload = ["./yaml.ts"]
类型脚本
默认 VSCode/ TypeScript 无法识别 .yaml 进口。 为避免导入出错,请在您的 tsconfig.json数字 :
{
"compilerOptions": {
"types": [
// other packages, e.g. "@aphrody/bun-types",
+ "@aphrody/bun-plugin-yaml"
]
}
}
捐款
$ bun install # project setup
$ bun test # run tests