{"id":25431,"library":"esbuild-plugin-yaml","title":"esbuild-plugin-yaml","description":"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.","status":"active","version":"0.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/martonlederer/esbuild-plugin-yaml","tags":["javascript","typescript"],"install":[{"cmd":"npm install esbuild-plugin-yaml","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-yaml","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-yaml","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency — plugin must be used with esbuild","package":"esbuild","optional":false},{"reason":"runtime dependency — used to parse YAML files","package":"js-yaml","optional":false}],"imports":[{"note":"Package is ESM-only; require() will fail. Use dynamic import() in CommonJS contexts.","wrong":"const yamlPlugin = require('esbuild-plugin-yaml')","symbol":"yamlPlugin","correct":"import { yamlPlugin } from 'esbuild-plugin-yaml'"},{"note":"Default export is not available; only named export yamlPlugin exists.","wrong":"import { default as yamlPlugin } from 'esbuild-plugin-yaml'","symbol":"default","correct":"import yamlPlugin from 'esbuild-plugin-yaml'"},{"note":"YAMLOptions is only a type export, not a runtime value.","wrong":"import { YAMLOptions } from 'esbuild-plugin-yaml'","symbol":"type YAMLOptions","correct":"import type { YAMLOptions } from 'esbuild-plugin-yaml'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport { yamlPlugin } from 'esbuild-plugin-yaml';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [yamlPlugin()]\n});\n\n// Then in your code:\n// import config from './config.yaml';\n// console.log(config);","lang":"typescript","description":"Configure esbuild to import YAML files as ES6 modules using the yamlPlugin."},"warnings":[{"fix":"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.","message":"Plugin does not automatically resolve .yaml/.yml extensions; esbuild must be configured to handle those file types as data URLs or custom loaders.","severity":"gotcha","affected_versions":"0.0.1"},{"fix":"Always return an object or undefined from the transform function. Example: transform(data, filePath) { return { ...data, transformed: true }; }","message":"Transform option must return an object or undefined; returning a non-object (e.g., string) will cause a runtime error in esbuild.","severity":"gotcha","affected_versions":"0.0.1"},{"fix":"Use import syntax: import { yamlPlugin } from 'esbuild-plugin-yaml'; For CommonJS projects, use dynamic import: const { yamlPlugin } = await import('esbuild-plugin-yaml');","message":"The plugin uses CommonJS require in its README example, but the package is ESM-only. The require example will not work.","severity":"deprecated","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install esbuild-plugin-yaml` or `yarn add esbuild-plugin-yaml` and ensure your lock file is updated.","cause":"Package not installed or not in node_modules; or project is using a different package manager (yarn vs npm) and cache is stale.","error":"Cannot find module 'esbuild-plugin-yaml'"},{"fix":"Change import to: import { yamlPlugin } from 'esbuild-plugin-yaml';","cause":"yamlPlugin is imported incorrectly (e.g., default import instead of named import) or the package version is very old (though 0.0.1 only).","error":"TypeError: yamlPlugin is not a function"},{"fix":"Ensure the plugin is added to the plugins array: plugins: [yamlPlugin()]. Also check that esbuild version is compatible (>=0.8.0).","cause":"Esbuild's default loaders do not include YAML; the plugin's loader may not have been applied properly (e.g., plugin not included in plugins array).","error":"error: No loader is configured for \".yaml\" files"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}