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.
npm install esbuild-plugin-yamlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configure esbuild to import YAML files as ES6 modules using the yamlPlugin.
Ensure esbuild's loader for .yaml/.yml is set to 'file' or use the plugin's internal loader; plugin currently registers a custom loader internally, but may conflict with explicit loader settings.
Always return an object or undefined from the transform function. Example: transform(data, filePath) { return { ...data, transformed: true }; }Use import syntax: import { yamlPlugin } from 'esbuild-plugin-yaml'; For CommonJS projects, use dynamic import: const { yamlPlugin } = await import('esbuild-plugin-yaml');Run `npm install esbuild-plugin-yaml` or `yarn add esbuild-plugin-yaml` and ensure your lock file is updated.
Change import to: import { yamlPlugin } from 'esbuild-plugin-yaml';Ensure the plugin is added to the plugins array: plugins: [yamlPlugin()]. Also check that esbuild version is compatible (>=0.8.0).