Registry / devops / rollup-plugin-json-combine

rollup-plugin-json-combine

JSON →
library1.0.7jsnpmunverified

Rollup plugin that combines multiple JSON files from a directory into a single output file. Current stable version is 1.0.7, with no release cadence documented. It differs from other JSON bundling plugins by providing a custom merge callback, allowing users to define how individual file contents are merged. Requires Node ^14.18.0 or >=16. Ships TypeScript types for better developer experience.

npm install rollup-plugin-json-combine
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-JSON
R
rollup-plugin-json-combine
devopsjavascriptv1.0.7
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import jsonCombine from 'rollup-plugin-json-combine'
const jsonCombine = require('rollup-plugin-json-combine')
Package is ESM-only due to Rollup plugin conventions. Default export is the plugin function.
RollupPluginJsonCombineOptions
import type { RollupPluginJsonCombineOptions } from 'rollup-plugin-json-combine'
TypeScript type for plugin options, available only when using TypeScript.
MergeCallback
import type { MergeCallback } from 'rollup-plugin-json-combine'
TypeScript type for the merge callback function signature.

Combines all JSON files in locales/ into a single dist/locales.json with keys derived from file names.

import jsonCombine from 'rollup-plugin-json-combine'; export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'esm' }, plugins: [ jsonCombine({ input: ['locales/*.json'], fileName: 'dist/locales.json', merge: (items) => { const output = {}; items.forEach((item) => { output[item.name.replace('.json', '')] = item.res; }); return output; }, }), ], };
Debug
Known issues
gotchaThe merge callback receives items as an array of { name, res } where 'res' is a string (raw content), not a parsed JSON object.
fix
If you need the parsed value, call JSON.parse(item.res) inside the merge callback.
affects: >=1.0.0
breakingInput option must be an array of glob patterns. Providing a single string (e.g., 'path/*.json') is not supported and may cause no files to be matched.
fix
Always pass an array: ['path/*.json']
affects: >=1.0.0
gotchaThe fileName option is required and must be relative to your Rollup output directory, not the project root.
fix
Ensure the path in fileName is correct relative to your output directory. For example, if output.file is 'dist/bundle.js', use 'dist/locales.json'.
affects: >=1.0.0
deprecatedNo known deprecations in current version.
Errors
Common errors & fixes
Error: No files matched for input pattern: path/*.json
Input pattern does not match any files or the path is incorrect relative to the project root.
fix
Verify the pattern is correct and files exist. Use absolute paths or correct relative paths from process.cwd().
TypeError: items.forEach is not a function
The merge callback is called with undefined or non-array data, possibly because input pattern matched no files.
fix
Ensure at least one JSON file matches the input pattern. Add error handling in the merge callback.
Error: [plugin: json-combine] Cannot read properties of undefined (reading 'forEach')
Same as above; merge callback receives undefined when no files are matched.
fix
Check the input pattern and file existence.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
rollup-plugin-json-combine — npm install rollup-plugin-json-combine · libregistry