esbuild-plugin-toml

raw JSON →
0.0.1 verified Fri May 01 auth: no javascript

An esbuild plugin to load TOML files during bundling. Version 0.0.1 is the initial and only release, with no updates since 2021. The package is lightweight and depends on esbuild's plugin API, providing a simple setup. Compared to alternatives like @toml-tools/loader, it is minimal but lacks customization options (e.g., no support for custom parsing or multiple file patterns). It is designed for basic TOML loading use cases.

error Error: No loader is configured for ".toml" files
cause Missing esbuild plugin configuration or plugin not registered.
fix
Ensure tomlPlugin() is added to the plugins array in esbuild.build options.
error TypeError: toml is not a function
cause Incorrect import style; toml is the default export (a function) but was used as an object.
fix
Use const tomlPlugin = require('esbuild-plugin-toml') then call tomlPlugin().
gotcha The plugin only handles .toml files; other extensions are ignored.
fix Ensure your TOML files have the .toml extension, or consider using a different plugin if custom extensions are needed.
deprecated Package has not been updated since 2021; may not support newer esbuild versions.
fix Check compatibility with your esbuild version. If using esbuild >0.14, consider testing or using an alternative plugin.
npm install esbuild-plugin-toml
yarn add esbuild-plugin-toml
pnpm add esbuild-plugin-toml

Shows how to set up esbuild with the TOML plugin and import a TOML file in JavaScript.

// esbuild.config.js
const esbuild = require('esbuild');
const tomlPlugin = require('esbuild-plugin-toml');

esbuild.build({
  bundle: true,
  entryPoints: ['main.js'],
  outfile: 'out.js',
  plugins: [tomlPlugin()],
}).catch(() => process.exit(1));

// main.js
const config = require('./config.toml');
console.log(config);