Registry / web-framework / vite-yaml-plugin

vite-yaml-plugin

JSON →
library2.0.4jsnpmunverified

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.

npm install vite-yaml-plugin
INSTALL
IMPORT
SIG · VITE-YAML-PLUGIN
V
vite-yaml-plugin
web-frameworkjavascriptv2.0.4
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

yamlPlugin
✓ import { yamlPlugin } from 'vite-yaml-plugin'
✗ import yamlPlugin from 'vite-yaml-plugin'
Named export, not default.
YamlFile type
✓ // no explicit type import needed; use ambient types via tsconfig or declare module
✗ import { YamlFile } from 'vite-yaml-plugin'
Types are provided as ambient declarations, not exported from the package.
yamlPlugin (CommonJS require)
✓ const { yamlPlugin } = require('vite-yaml-plugin')
✗ const yamlPlugin = require('vite-yaml-plugin')
CommonJS require must destructure the named export.

Shows basic setup of the plugin in vite.config.js and usage in a module, plus TypeScript type augmentation.

// vite.config.js import { defineConfig } from 'vite'; import { yamlPlugin } from 'vite-yaml-plugin'; export default defineConfig({ plugins: [ yamlPlugin(), ], }); // Then in any module: import foo from './foo.yaml'; console.log(foo); // For TypeScript, add to tsconfig.json: // { // "compilerOptions": { // "types": ["vite-yaml-plugin/types"] // } // }
Debug
Known issues
gotchaPlugin must be called as a function, not passed directly as object.
fix
Use `yamlPlugin()` instead of `yamlPlugin` in the plugins array.
affects: *
gotchaTypeScript ambient types require adding 'vite-yaml-plugin/types' to compilerOptions.types, not just importing.
fix
Add 'vite-yaml-plugin/types' to the 'types' array in tsconfig.json.
affects: *
deprecatedOlder versions (1.x) may have used a different import path or default export.
fix
Update to v2 and use named import { yamlPlugin } from 'vite-yaml-plugin'.
affects: <2.0
Errors
Common errors & fixes
Cannot find module 'vite-yaml-plugin' or its corresponding type declarations.
Missing TypeScript types setup.
fix
Add 'vite-yaml-plugin/types' to compilerOptions.types in tsconfig.json, or provide a custom declaration file.
The requested module 'vite-yaml-plugin' does not provide an export named 'default'
Using default import instead of named import.
fix
Change import statement to: import { yamlPlugin } from 'vite-yaml-plugin'
TypeError: yamlPlugin is not a function
Passing the function reference instead of calling it in the plugins array.
fix
Use `yamlPlugin()` with parentheses in the plugins array.
Upgrade
Version history
2.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
Bingbot
1
OpenAI (training)
1
Resources
vite-yaml-plugin — npm install vite-yaml-plugin · libregistry