{"id":29882703,"url":"https://github.com/itsdevdom/json-bundler","last_synced_at":"2025-10-18T11:38:33.598Z","repository":{"id":28419150,"uuid":"118050994","full_name":"itsdevdom/json-bundler","owner":"itsdevdom","description":"Bundles your JSON \u0026 JSON5 files intelligently.","archived":false,"fork":false,"pushed_at":"2025-06-02T07:51:08.000Z","size":619,"stargazers_count":2,"open_issues_count":15,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-07-09T00:42:54.887Z","etag":null,"topics":["bundle","combine","i18n","json","json5","merge"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/json-bundler","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itsdevdom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-18T23:31:43.000Z","updated_at":"2023-03-09T03:19:31.000Z","dependencies_parsed_at":"2024-10-27T11:05:31.766Z","dependency_job_id":"4cbfa0c8-d90f-4c27-bee8-1674a0591b23","html_url":"https://github.com/itsdevdom/json-bundler","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/itsdevdom/json-bundler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdevdom%2Fjson-bundler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdevdom%2Fjson-bundler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdevdom%2Fjson-bundler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdevdom%2Fjson-bundler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itsdevdom","download_url":"https://codeload.github.com/itsdevdom/json-bundler/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdevdom%2Fjson-bundler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268036193,"owners_count":24185169,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bundle","combine","i18n","json","json5","merge"],"created_at":"2025-07-31T12:09:37.964Z","updated_at":"2025-10-18T11:38:33.241Z","avatar_url":"https://github.com/itsdevdom.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n\n# json-bundler\n\n**Bundles your JSON files intelligently.**\n\n\u003c/div\u003e\n\n\u003cbr\u003e\u003cbr\u003e\n\n## What it does\n\nWhen developing web applications, we often use JSON files in order to define content (e.g. for internationalization) or extracting some form\nof configuration. Especially in the former case, we usually end up with one huge JSON file, probably a couple or hundred or thousand lines\nlong.\n\nMeet the **json-bundler**, a NodeJS-based command line tool, enabling you to place multiple JSON files in multiple places - and bundle them\ntogether intelligently.\n\n\u003e For example, the **json-bundler** allows you to place your i18n files directly next to your component implementations (e.g. next to\n\u003e Angular components), or to reference JSON files published within a npm library.\n\n![JSON Bundler Preview](/docs/preview.png?raw=true)\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n## How to install\n\nYou can get the **json-bundler** via **npm** by either adding it as a new *devDependency* to your `package.json` file and running\n`npm install`, or running the following command:\n\n``` bash\nnpm install json-bundler\n```\n\n### Requirements\n\n- **json-bundler** requires **NodeJS 10** (or higher) to be installed\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n## How it works\n\nUsing **json-bundler** means:\n\n- **Entry Point**\u003cbr\u003e\n  There must be exactly one JSON file acting as the singular entry point (e.g. `index.json` or `en.json`).\n- **References**\u003cbr\u003e\n  JSON files are referenced (and thus included) using the `$ref` key, and the path to the JSON file as the value. Reference\n  paths are always relative to the JSON file they're being defined within. Paths starting with `~` are pointing to the project's\n  `node_modules` folder (for easy npm library access).\n- **Bundling**\u003cbr\u003e\n  When bundling, referenced JSON files get merged in (instead of just placed in), at the exact position in the JSNO files at\n  which they're being referenced. Existing values will not be overwritten by referenced files (the \"referencee\" has always higher priority).\n\nAlso: Both `json` and `json5` files are supported, even in a mixed manner. That means you can do linebreaks, use comments, and much more.\nSee **[JSON5](https://github.com/json5/json5)** for further details.\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n## How to use\n\nIt's recommended to use the json-bundler within one of your `package.json` scripts. For instance:\n\n``` json\n{\n  \"scripts\": {\n    \"json:bundle\": \"json-bundler --entryFile \u003cPATH\u003e --outFile \u003cPATH\u003e\"\n  }\n}\n```\n\nThe following parameters are available:\n\n- `--entryFile \u003cPATH\u003e` (required) defines the path to the root JSON / JSON5 file\n- `--outFile \u003cPATH\u003e` (required) defines the path to the output file\n- `--minified` enables, if used, the minification of the output file (production build, in other words)\n- `--watch` enables the watch mode - which comes in very handy during development\n\n\u003e You can always run `json-bundler --help` to get a full list of available command line parameters.\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n## Example\n\nThe following is a very simple example, demonstrating the basics of **json-bundler**. For further examples, feel free to take a look at the\n**[unit tests](https://github.com/dominique-mueller/json-bundler/tree/develop/test)** of the library.\n\n\u003cbr\u003e\n\n### Source\n\nFirst file at `src/app/en.json` (entry file):\n\n``` json\n{\n  \"title\": \"My application title\",\n  \"login\": {\n    \"$ref\": \"./pages/login.json5\"\n  },\n  \"home\": {\n    \"title\": \"Welcome back, it's Christmas time!\",\n    \"$ref\": \"./pages/home.json\"\n  },\n  \"footer\": {\n    \"$ref\": \"~my-library/i18n/footer.json\"\n  }\n}\n```\n\nSecond file at `src/app/pages/login.json5` (referenced file):\n\n``` json5\n// Login Page\n{\n  \"title\": \"Login\", // TODO: Rename to register?\n  \"form\": {\n    \"user\": \"Please enter your username.\",\n    \"password\": \"Please enter your password.\"\n  }\n}\n```\n\nThird file at `src/app/pages/home.json` (referenced file):\n\n``` json\n{\n  \"title\": \"Welcome back!\",\n  \"description\": \"Lorem ipsum dolor sit amet.\"\n}\n```\n\nFourth file at `node_modules/my-library/i18n/footer.json` (referenced file):\n\n``` json\n{\n  \"copyright\": \"My company\",\n  \"legal\": \"My super-duper important legal information. Plus imprint, of course.\"\n}\n```\n\n**Notice that:**\n\n- One JSON file can reference multiple other JSON files\n- The place of the reference within the JSON structure will define where the referenced file gets merged in\n- The paths are relative to the file they are defined within\n- The `~` symbol can be used to access libraries (as a shortcut)\n- The paths include the file ending (either `.json` or `.json5`)\n\n\u003cbr\u003e\n\n### Bundling\n\nWe use the following command to create the bundle:\n\n``` bash\njson-bundler --entryFile src/app/en.json --outFile dist/en.json\n```\n\n**Notice that:**\n\n- We use the entry file from above\n- We only define the required parameters here (`entryFile` and `outFile`)\n\n\u003cbr\u003e\n\n### Output\n\nThe result is a JSON file at `dist/en.json`, and it contains the following:\n\n``` json\n{\n  \"title\": \"My application title\",\n  \"login\": {\n    \"title\": \"Login\",\n    \"form\": {\n      \"user\": \"Please enter your username.\",\n      \"password\": \"Please enter your password.\"\n    }\n  },\n  \"home\": {\n    \"title\": \"Welcome back, it's Christmas time!\",\n    \"description\": \"Lorem ipsum dolor sit amet.\"\n  },\n  \"footer\": {\n    \"copyright\": \"My company\",\n    \"legal\": \"My super-duper important legal information. Plus imprint, of course.\"\n  }\n}\n```\n\n**Notice that:**\n\n- Referenced files get merged in at the place they got referenced\n- Files are included, no matter if they are `json` or `json5`, no matter if they exist within the project or come from a library\n- The `home/title` has the value of the `src/app/en.json` file, and not the value defined in `src/app/pages/home.json` - the\n  \"parent\" (aka the referencee) always has higher priority than the referenced file during merge\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsdevdom%2Fjson-bundler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitsdevdom%2Fjson-bundler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsdevdom%2Fjson-bundler/lists"}