esbuild-plugin-dsv

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

An esbuild plugin that enables importing .tsv and .csv files as ES6 modules. Current stable version is 0.0.4. It uses d3-dsv under the hood to parse tabular data and returns a DSVRowArray (array of objects). The plugin supports a transform option to mutate parsed data before bundling. Compared to other CSV loaders for esbuild, this plugin is minimal and focused, but it has very low maintenance activity and may not be suitable for production use due to its early stage.

error Error: Cannot find module 'esbuild-plugin-dsv'
cause Package is not installed.
fix
Run npm install --save-dev esbuild-plugin-dsv
error TypeError: dsvPlugin is not a function
cause Importing default instead of named export.
fix
Use import { dsvPlugin } from 'esbuild-plugin-dsv' instead of import dsvPlugin from ...
gotcha Plugin does not validate CSV/TSV file extensions; any file imported with .csv or .tsv extension will be parsed, potentially causing errors on malformed data.
fix Ensure imported CSV/TSV files are valid tabular data with headers.
gotcha The plugin does not support custom delimiter or quoting; it uses d3-dsv defaults which assume comma separated values and double quotes.
fix Transform the data manually using d3-dsv's csvParse with custom options.
gotcha Version 0.0.4 is very early; breaking changes may occur without major version bump.
fix Pin exact version in package.json and test upgrades thoroughly.
npm install esbuild-plugin-dsv
yarn add esbuild-plugin-dsv
pnpm add esbuild-plugin-dsv

Registers the DSV plugin with esbuild, allowing import of .csv and .tsv files in bundled code.

const esbuild = require('esbuild');
const { dsvPlugin } = require('esbuild-plugin-dsv');

async function build() {
  await esbuild.build({
    entryPoints: ['src/index.js'],
    bundle: true,
    outfile: 'dist/bundle.js',
    plugins: [dsvPlugin()],
  });
}

build();