Registry / web-framework / vite-plugin-toml

vite-plugin-toml

JSON →
library0.8.7jsnpmunverified

A Vite and Rollup plugin for importing TOML files. Current stable version is 0.8.7, with updates aligned to Vite's release cadence. Uses toml-eslint-parser for TOML 1.0.0 support. Supports both Vite and Rollup despite the name. Key differentiator: integrates directly as a Vite/Rollup plugin with options for named exports and big integers, unlike alternatives that require separate TOML parsing libraries.

npm install vite-plugin-toml
INSTALL
IMPORT
SIG · VITE-PLUGIN-TOML
V
vite-plugin-toml
web-frameworkjavascriptv0.8.7
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.

ViteToml
import { ViteToml } from 'vite-plugin-toml'
import ViteToml from 'vite-plugin-toml'
Named export only; no default export.
default import for .toml files
import data from './config.toml'
import { data } from './config.toml'
Default import returns parsed object unless namedExports option is enabled.
TypeScript module declaration
declare module '*.toml' { const value: unknown; export default value; }
declare module '*.toml' { const value: Record<string, unknown>; export default value; }
Generic unknown type recommended; better to use a more specific type or typescript-plugin-toml.

Shows how to add the plugin in Vite or Rollup config, including named exports option.

// vite.config.ts import { ViteToml } from 'vite-plugin-toml' // basic usage export default { plugins: [ViteToml()] } // with named exports export default { plugins: [ViteToml({ namedExports: true })] } // Rollup usage (rollup.config.js) import { ViteToml } from 'vite-plugin-toml' export default { plugins: [ViteToml()] }
Debug
Known issues
breakingv0.3.0 dropped support for TOML 0.5.0 and only supports TOML 1.0.0.
fix
Ensure your TOML files conform to TOML 1.0.0 spec.
affects: >=0.3.0
deprecatedThe package name 'vite-plugin-toml' is historical; the plugin also works with Rollup but the name may mislead.
fix
No change needed; just note it works with Rollup too.
affects: >=0.0.0
gotchaDefault import returns the parsed object; named imports (like import { key } from './file.toml') only work when namedExports option is true.
fix
Enable namedExports option or use default import.
affects: >=0.3.0
gotchaUsing require() syntax (CommonJS) may not work in Vite/ESM environments; prefer ESM imports.
fix
Use import statements instead of require().
affects: >=0.1.0
Errors
Common errors & fixes
ViteToml is not defined
Incorrect import style (default import instead of named import).
fix
Change to import { ViteToml } from 'vite-plugin-toml'
Unrecognized TOML syntax: <line>
TOML file contains TOML 0.5.0 syntax not supported in TOML 1.0.0.
fix
Update TOML file to comply with TOML 1.0.0 spec.
TypeScript cannot find module './file.toml'
Missing type declaration for .toml files.
fix
Add declare module '*.toml' { const value: unknown; export default value; } to a .d.ts file.
Upgrade
Version history
0.8.7latest on npm
Audit
Dependencies
rolluprequiredPeer dependency required for Rollup integration
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
vite-plugin-toml — npm install vite-plugin-toml · libregistry