Registry / web-framework / vite-plugin-yaml2

vite-plugin-yaml2

JSON →
library1.1.5jsnpmunverified

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.

npm install vite-plugin-yaml2
INSTALL
IMPORT
SIG · VITE-PLUGIN-YAML2
V
vite-plugin-yaml2
web-frameworkjavascriptv1.1.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

pluginYaml
import pluginYaml from 'vite-plugin-yaml2'
import { pluginYaml } from 'vite-plugin-yaml2'
Default export only; named import will fail.
pluginYaml
const pluginYaml = require('vite-plugin-yaml2')
CommonJS require works (the package exports a default).

Shows how to register the plugin in vite.config.ts and import a YAML file.

// vite.config.ts import { defineConfig } from 'vite'; import pluginYaml from 'vite-plugin-yaml2'; export default defineConfig({ plugins: [pluginYaml()], }); // Then in any component: import data from './data.yml'; console.log(data); // data.yml content: // - name: Alice // age: 30 // - name: Bob // age: 25
Debug
Known issues
gotchaTypes for imported YAML files are not provided; you must manually add a module declaration.
fix
Add declare module '*.yaml' { const value: any; export default value; } in a .d.ts file.
affects: >=1.0.0
deprecatedNo known deprecations, but the package has seen few updates; may not follow Vite's latest plugin API changes.
fix
If issues arise with newer Vite versions, consider using vite-plugin-yaml (alternative) or file an issue.
affects: >=0.1.0
gotchaThe plugin uses the yaml package to parse; deeply nested structures may throw if YAML is invalid.
fix
Validate YAML syntax before importing.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-yaml2' or its corresponding type declarations.
Missing type declarations for the plugin or the imported YAML files.
fix
Ensure vite-plugin-yaml2 is installed: npm i vite-plugin-yaml2. For YAML files, add type declarations as shown in the quickstart warnings.
Uncaught SyntaxError: The requested module 'vite-plugin-yaml2' does not provide an export named 'pluginYaml'
Used named import instead of default import.
fix
Use import pluginYaml from 'vite-plugin-yaml2' instead of import { pluginYaml } from ...
Error: Cannot find module 'yaml'
The dependency 'yaml' is not installed.
fix
Install yaml: npm i yaml (or it should be automatically installed as a dependency of vite-plugin-yaml2, but manual install may fix).
TypeScript error: Cannot find module './data.yml' or its corresponding type declarations.
No ambient module declaration for .yml/.yaml files.
fix
Add declare module '*.yaml' { const value: any; export default value; } to src/vite-env.d.ts.
Upgrade
Version history
1.1.5latest on npm
Audit
Dependencies
viterequiredPeer dependency; the plugin runs only within a Vite project.
yamlrequiredRuntime dependency for parsing YAML strings into JS objects.
Agent activity
11 hits · last 30 days
node
8
OpenAI (training)
1
Resources
vite-plugin-yaml2 — npm install vite-plugin-yaml2 · libregistry