esbuild-plugin-dsv
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

esbuild-plugin-dsv

Use .tsv and .csv files as ES6 modules.

Install

yarn add -D esbuild-plugin-dsv

or

npm i -D esbuild-plugin-dsv

Usage

Add to your esbuild plugins list:

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

esbuild.build({
  ...
  plugins: [
    dsvPlugin()
  ]
  ...
});

Options

You can customize how esbuild-plugin-dsv parses .tsv and .csv files the following way:

dsvPlugin({
  // options
});

transform

With this function, you can mutate the parsed/resolved .tsv and .csv files:

  transform(data, extension) {
    // transform the file
    // the data holds a "DSVRowArray" type data
    // parsed from the imported file
    // read more about it here:
    // https://github.com/d3/d3-dsv#csvParse
    // https://github.com/d3/d3-dsv#tsvParse
    // the extension can be "TSV" or "CSV"
    return data;
  }

Readme

Keywords

none

Package Sidebar

Install

npm i esbuild-plugin-dsv

Weekly Downloads

216

Version

0.0.4

License

MIT

Unpacked Size

7.57 kB

Total Files

9

Last publish

Collaborators

  • martondev