https://github.com/martonlederer/esbuild-plugin-dsv
Use .tsv and .csv files as ES6 modules
https://github.com/martonlederer/esbuild-plugin-dsv
Last synced: about 1 month ago
JSON representation
Use .tsv and .csv files as ES6 modules
- Host: GitHub
- URL: https://github.com/martonlederer/esbuild-plugin-dsv
- Owner: martonlederer
- License: mit
- Created: 2021-02-21T09:21:06.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-20T19:47:43.000Z (about 1 year ago)
- Last Synced: 2025-03-24T06:45:26.734Z (about 2 months ago)
- Language: TypeScript
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# esbuild-plugin-dsv
Use .tsv and .csv files as ES6 modules.
## Install
```sh
yarn add -D esbuild-plugin-dsv
```or
```sh
npm i -D esbuild-plugin-dsv
```## Usage
Add to your esbuild plugins list:
```js
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:
```js
dsvPlugin({
// options
});
```### `transform`
With this function, you can mutate the parsed/resolved `.tsv` and `.csv` files:
```js
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;
}
```