{"id":22936,"library":"vite-plugin-yaml2","title":"vite-plugin-yaml2","description":"Vite plugin to import YAML files as JavaScript default exports. Current stable version is 1.1.5, released with basic YAML loading support. The plugin registers a Vite plugin that transforms .yaml and .yml files into JS objects via default export. It is a lightweight alternative to vite-plugin-yaml (which may have different export behavior) and does not require additional loaders. Release cadence appears low; the package has had only a few bug fix releases since v1.0.0. The plugin is minimal, with no configuration options beyond the plugin call.","status":"active","version":"1.1.5","language":"javascript","source_language":"en","source_url":"https://github.com/mzaini30/vite-plugin-yaml2","tags":["javascript","vite","vite-plugin","yaml"],"install":[{"cmd":"npm install vite-plugin-yaml2","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-yaml2","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-yaml2","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; the plugin runs only within a Vite project.","package":"vite","optional":false},{"reason":"Runtime dependency for parsing YAML strings into JS objects.","package":"yaml","optional":false}],"imports":[{"note":"Default export only; named import will fail.","wrong":"import { pluginYaml } from 'vite-plugin-yaml2'","symbol":"pluginYaml","correct":"import pluginYaml from 'vite-plugin-yaml2'"},{"note":"CommonJS require works (the package exports a default).","wrong":null,"symbol":"pluginYaml","correct":"const pluginYaml = require('vite-plugin-yaml2')"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport pluginYaml from 'vite-plugin-yaml2';\n\nexport default defineConfig({\n  plugins: [pluginYaml()],\n});\n\n// Then in any component:\nimport data from './data.yml';\nconsole.log(data);\n// data.yml content:\n// - name: Alice\n//   age: 30\n// - name: Bob\n//   age: 25","lang":"typescript","description":"Shows how to register the plugin in vite.config.ts and import a YAML file."},"warnings":[{"fix":"Add declare module '*.yaml' { const value: any; export default value; } in a .d.ts file.","message":"Types for imported YAML files are not provided; you must manually add a module declaration.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If issues arise with newer Vite versions, consider using vite-plugin-yaml (alternative) or file an issue.","message":"No known deprecations, but the package has seen few updates; may not follow Vite's latest plugin API changes.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Validate YAML syntax before importing.","message":"The plugin uses the yaml package to parse; deeply nested structures may throw if YAML is invalid.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure vite-plugin-yaml2 is installed: npm i vite-plugin-yaml2. For YAML files, add type declarations as shown in the quickstart warnings.","cause":"Missing type declarations for the plugin or the imported YAML files.","error":"Cannot find module 'vite-plugin-yaml2' or its corresponding type declarations."},{"fix":"Use import pluginYaml from 'vite-plugin-yaml2' instead of import { pluginYaml } from ...","cause":"Used named import instead of default import.","error":"Uncaught SyntaxError: The requested module 'vite-plugin-yaml2' does not provide an export named 'pluginYaml'"},{"fix":"Install yaml: npm i yaml (or it should be automatically installed as a dependency of vite-plugin-yaml2, but manual install may fix).","cause":"The dependency 'yaml' is not installed.","error":"Error: Cannot find module 'yaml'"},{"fix":"Add declare module '*.yaml' { const value: any; export default value; } to src/vite-env.d.ts.","cause":"No ambient module declaration for .yml/.yaml files.","error":"TypeScript error: Cannot find module './data.yml' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}