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.
Common errors
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 ...
Warnings
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.
Install
npm install esbuild-plugin-dsv yarn add esbuild-plugin-dsv pnpm add esbuild-plugin-dsv Imports
- dsvPlugin wrong
import dsvPlugin from 'esbuild-plugin-dsv'correctimport { dsvPlugin } from 'esbuild-plugin-dsv' - DSVPluginOptions
import type { DSVPluginOptions } from 'esbuild-plugin-dsv' - DSVRowArray wrong
import { DSVRowArray } from 'esbuild-plugin-dsv'correctimport type { DSVRowArray } from 'esbuild-plugin-dsv'
Quickstart
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();