🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

bun-plugin-yaml

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bun-plugin-yaml

The official YAML plugin for Bun. Adds support for `.yml`/`.yaml` imports.

0.0.1
latest
npm
Version published
Weekly downloads
43K
55.15%
Maintainers
1
Weekly downloads
 
Created
Source

bun-plugin-yaml

The official YAML plugin for Bun. Adds support for .yml/.yaml imports.

Installation

bun add bun-plugin-yaml -d

Bundler usage

This 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.

Runtime usage

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"]

TypeScript

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"
      ]
    }
  }

Contributing

$ bun install # project setup
$ bun test # run tests

FAQs

Package last updated on 03 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts