mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
* 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
22 lines
497 B
TypeScript
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;
|