{"id":22957,"library":"vite-yaml-plugin","title":"vite-yaml-plugin","description":"Vite plugin to import YAML files (.yaml/.yml) as JavaScript modules, using js-yaml internally. Version 2.0.4, actively maintained, minimal dependencies (only js-yaml as a dependency, vite as peer). Key differentiator: lightweight alternative to vite-plugin-yaml, supports TypeScript declaration augmentation, configurable file matching and yaml options. Suitable for Vite projects needing YAML data imports with zero configuration overhead.","status":"active","version":"2.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/silverwind/vite-yaml-plugin","tags":["javascript","typescript"],"install":[{"cmd":"npm install vite-yaml-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add vite-yaml-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-yaml-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Named export, not default.","wrong":"import yamlPlugin from 'vite-yaml-plugin'","symbol":"yamlPlugin","correct":"import { yamlPlugin } from 'vite-yaml-plugin'"},{"note":"Types are provided as ambient declarations, not exported from the package.","wrong":"import { YamlFile } from 'vite-yaml-plugin'","symbol":"YamlFile type","correct":"// no explicit type import needed; use ambient types via tsconfig or declare module"},{"note":"CommonJS require must destructure the named export.","wrong":"const yamlPlugin = require('vite-yaml-plugin')","symbol":"yamlPlugin (CommonJS require)","correct":"const { yamlPlugin } = require('vite-yaml-plugin')"}],"quickstart":{"code":"// vite.config.js\nimport { defineConfig } from 'vite';\nimport { yamlPlugin } from 'vite-yaml-plugin';\n\nexport default defineConfig({\n  plugins: [\n    yamlPlugin(),\n  ],\n});\n\n// Then in any module:\nimport foo from './foo.yaml';\nconsole.log(foo);\n\n// For TypeScript, add to tsconfig.json:\n// {\n//   \"compilerOptions\": {\n//     \"types\": [\"vite-yaml-plugin/types\"]\n//   }\n// }","lang":"typescript","description":"Shows basic setup of the plugin in vite.config.js and usage in a module, plus TypeScript type augmentation."},"warnings":[{"fix":"Use `yamlPlugin()` instead of `yamlPlugin` in the plugins array.","message":"Plugin must be called as a function, not passed directly as object.","severity":"gotcha","affected_versions":"*"},{"fix":"Add 'vite-yaml-plugin/types' to the 'types' array in tsconfig.json.","message":"TypeScript ambient types require adding 'vite-yaml-plugin/types' to compilerOptions.types, not just importing.","severity":"gotcha","affected_versions":"*"},{"fix":"Update to v2 and use named import { yamlPlugin } from 'vite-yaml-plugin'.","message":"Older versions (1.x) may have used a different import path or default export.","severity":"deprecated","affected_versions":"<2.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add 'vite-yaml-plugin/types' to compilerOptions.types in tsconfig.json, or provide a custom declaration file.","cause":"Missing TypeScript types setup.","error":"Cannot find module 'vite-yaml-plugin' or its corresponding type declarations."},{"fix":"Change import statement to: import { yamlPlugin } from 'vite-yaml-plugin'","cause":"Using default import instead of named import.","error":"The requested module 'vite-yaml-plugin' does not provide an export named 'default'"},{"fix":"Use `yamlPlugin()` with parentheses in the plugins array.","cause":"Passing the function reference instead of calling it in the plugins array.","error":"TypeError: yamlPlugin is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}