{"id":13774600,"url":"https://github.com/petlack/rollup-plugin-jsonlines","last_synced_at":"2025-05-11T06:33:26.387Z","repository":{"id":61929865,"uuid":"556234976","full_name":"petlack/rollup-plugin-jsonlines","owner":"petlack","description":"🍣 A Rollup plugin which imports .jsonl (JSON Lines) files as JSON arrays.","archived":false,"fork":false,"pushed_at":"2022-10-24T07:43:53.000Z","size":262,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-03T10:41:26.900Z","etag":null,"topics":["javascript","jsonl","rollup","rollup-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/petlack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-23T11:37:41.000Z","updated_at":"2023-08-31T05:05:39.000Z","dependencies_parsed_at":"2022-10-23T18:00:52.408Z","dependency_job_id":null,"html_url":"https://github.com/petlack/rollup-plugin-jsonlines","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petlack%2Frollup-plugin-jsonlines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petlack%2Frollup-plugin-jsonlines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petlack%2Frollup-plugin-jsonlines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petlack%2Frollup-plugin-jsonlines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petlack","download_url":"https://codeload.github.com/petlack/rollup-plugin-jsonlines/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225022211,"owners_count":17408582,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","jsonl","rollup","rollup-plugin"],"created_at":"2024-08-03T17:01:28.485Z","updated_at":"2024-11-17T09:31:04.402Z","avatar_url":"https://github.com/petlack.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Other File Imports"],"readme":"# rollup-plugin-jsonlines\n\n🍣 A Rollup plugin which imports `.jsonl` ([JSON Lines](https://jsonlines.org/)) files as JSON arrays.\n\n## Requirements\n\nThis plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+.\n\n## Install\n\nUsing npm:\n\n```console\nnpm install rollup-plugin-jsonlines --save-dev\n```\n\n## Usage\n\nCreate a rollup.config.js [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:\n\n```js\nimport jsonl from 'rollup-plugin-jsonlines';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'output',\n    format: 'cjs'\n  },\n  plugins: [jsonl()]\n};\n```\n\nThen call rollup either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).\n\n## Usage with vite\n\n_`vite.config.js`_\n\n```js\nimport { defineConfig } from 'vite';\nimport { svelte } from '@sveltejs/vite-plugin-svelte';\nimport jsonl from 'rollup-plugin-jsonlines';\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [svelte(), jsonl()]\n});\n```\n\n## Example\n\n_`fruits.jsonl`_\n\n```json\n{ \"type\": \"apples\", \"count\": 7 }\n{ \"type\": \"pears\", \"count\": 4 }\n{ \"type\": \"bananas\", \"count\": 5 }\n```\n\n_`index.js`_\n\n```js\nimport fruit from './fruits.jsonl';\n\nconsole.log(fruit);\n```\n\n_`log`_\n\n```json\n[\n  { \"type\": \"apples\", \"count\": 7 },\n  { \"type\": \"pears\", \"count\": 4 },\n  { \"type\": \"bananas\", \"count\": 5 }\n]\n```\n\n## Options\n\n### ignoreErrors\n\nType: `Boolean`\u003cbr\u003e\nDefault: `false`\n\nIf set to false (default), an exception will be thrown in case of invalid JSON on a line.\n\nIf set to true, invalid lines will be omitted.\n\n### processRow\n\nType: `Function`\u003cbr\u003e\nDefault: `null`\n\nSpecifies a function which processes each row in the parsed array. The function can either manipulate the passed row, or return an entirely new row object.\n\nThis option could be used for converting numeric string values into Number values. – for example turning numeric values into numbers, e.g.\n\n```js\njsonl({\n  processRow: (row, id) =\u003e {\n    Object.keys(row).forEach((key) =\u003e {\n      var value = row[key];\n      row[key] = isNaN(+value) ? value : +value;\n    });\n  }\n});\n```\n\n## Meta\n\n[CONTRIBUTING](/.github/CONTRIBUTING.md)\n\n[LICENSE (MIT)](/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetlack%2Frollup-plugin-jsonlines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetlack%2Frollup-plugin-jsonlines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetlack%2Frollup-plugin-jsonlines/lists"}