csv.macro

Compile CSV content to JSON at build-time with babel-plugin-macros.

Usage no npm install needed!

<script type="module">
  import csvMacro from 'https://cdn.skypack.dev/csv.macro';
</script>

README

csv.macro

Compile CSV content to JSON at build-time with babel-plugin-macros.

Babel Macro Codecov Status npm package npm downloads prettier

inspired by graphql.macro

Installation

$ npm install csv.macro

Note: You'll need to install and configure babel-plugin-macros if you haven't already.

Note: It works by default is using create-react-app.

Usage

loader

import { loader } from 'csv.macro';
const jsonData = loader('./fixtures/data.csv');

      ↓ ↓ ↓ ↓ ↓ ↓

const jsonData = [
  {
    id: "1",
    username: "andrew",
    email: "andrew@example.com"
  },
  {
    id: "1",
    username: "luca",
    email: "luca@example.com"
  },
]

Development

Requirements

  • node >= 11.10.0
  • yarn >= 1.13.0
$ npm install --pure-lockfile

Test

$ npm run format
$ npm run eslint
$ npm run flow
$ npm run test:watch
$ npm run build

Publish

$ npm version patch
$ npm run changelog
git commit & push

CONTRIBUTING

  • ⇄ Pull requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull requests must be accompanied by passing automated tests.