Files
bun.sh/packages/bun-plugin-yaml/index.ts
Colin McDonnell a52715597a Add plugins for yaml & RSC (#2888)
* WIP

* WIP

* Add yaml plugin

* Publish v0.0.1

* Updates

* Start RSC plugin - not finished

* Add readme

* Updates

* Add shell dirs for a few other plugins
2023-05-15 20:37:03 -07:00

22 lines
497 B
TypeScript

import { BunPlugin } from "bun";
import { readFileSync } from "fs";
import { load } from "js-yaml";
function YamlPlugin(): BunPlugin {
return {
name: "bun-plugin-yaml",
setup(builder) {
builder.onLoad({ filter: /\.(yaml|yml)$/ }, args => {
const text = readFileSync(args.path, "utf8");
const exports = load(text) as Record<string, any>;
return {
exports,
loader: "object",
};
});
},
};
}
export default YamlPlugin;