Registry / serialization / esbuild-plugin-yaml

esbuild-plugin-yaml

JSON →
library0.0.1jsnpmunverified

An esbuild plugin that allows importing YAML files as ES6 modules, converting YAML content into JavaScript objects at build time. Currently at version 0.0.1, it relies on js-yaml for parsing and provides options for custom load options and a transformation hook. Minor updates expected; alternative to other JSON/YAML esbuild plugins with a focus on simplicity and TypeScript support.

serializationdevops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Package is ESM-only; require() will fail. Use dynamic import() in CommonJS contexts.

import { yamlPlugin } from 'esbuild-plugin-yaml'

Default export is not available; only named export yamlPlugin exists.

import yamlPlugin from 'esbuild-plugin-yaml'

YAMLOptions is only a type export, not a runtime value.

import type { YAMLOptions } from 'esbuild-plugin-yaml'

Configure esbuild to import YAML files as ES6 modules using the yamlPlugin.

import esbuild from 'esbuild'; import { yamlPlugin } from 'esbuild-plugin-yaml'; await esbuild.build({ entryPoints: ['src/index.ts'], bundle: true, outfile: 'dist/bundle.js', plugins: [yamlPlugin()] }); // Then in your code: // import config from './config.yaml'; // console.log(config);
Debug
Known footguns
gotchaPlugin does not automatically resolve .yaml/.yml extensions; esbuild must be configured to handle those file types as data URLs or custom loaders.
gotchaTransform option must return an object or undefined; returning a non-object (e.g., string) will cause a runtime error in esbuild.
deprecatedThe plugin uses CommonJS require in its README example, but the package is ESM-only. The require example will not work.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
11 hits · last 30 days
claudebot
4
gptbot
3
ahrefsbot
3
bingbot
1
Resources