Registry / data / rollup-plugin-json-map-keys

rollup-plugin-json-map-keys

JSON →
library1.2.0jsnpmunverified

Rollup plugin that recursively transforms JSON values into their dot-separated key paths, useful for i18n key generation or object value replacement. Latest version 1.2.0 (2025-11-22) requires rollup >= 2. The package has seen recent maintenance including dependency updates and path restructuring. It is part of a monorepo with webpack loader and Jest transformer equivalents. Key differentiators: designed specifically for Rollup, outputs JSON with key paths, supports custom prefix via options.

npm install rollup-plugin-json-map-keys
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-JSON
R
rollup-plugin-json-map-keys
datajavascriptv1.2.0
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 jsonMapKeys from 'rollup-plugin-json-map-keys'
const jsonMapKeys = require('rollup-plugin-json-map-keys')
ESM-only export. CommonJS require returns module.exports which is an object { default: ... } in this package, so you'd need jsonMapKeys.default if using require.
jsonMapKeys (default)
import jsonMapKeys from 'rollup-plugin-json-map-keys'
import { jsonMapKeys } from 'rollup-plugin-json-map-keys'
Plugin is exported as default export, not named.
Plugin type
import type { Plugin } from 'rollup'; // for TS users then use as return type of function
import { Plugin } from 'rollup-plugin-json-map-keys'
No TypeScript types are bundled; users should import Plugin from Rollup itself.

Configures Rollup to replace JSON values with dot-separated key paths, demonstates typical usage with @rollup/plugin-json.

import jsonMapKeys from 'rollup-plugin-json-map-keys'; import json from '@rollup/plugin-json'; // to import JSON files export default { input: 'src/index.js', output: { dir: 'dist', format: 'es' }, plugins: [ json(), // resolves .json imports jsonMapKeys({ prefix: '[name]:' // optional prefix for key paths }) ] };
Debug
Known issues
breakingAfter version 1.2.0, the package was moved to a new monorepo. Imports from 'rollup-plugin-json-map-keys' still work, but ensure you use the latest version to avoid path resolution issues.
fix
Update to rollup-plugin-json-map-keys@1.2.0 or later; verify lockfile for correct package.
affects: >=1.2.0
gotchaThe plugin works only with JSON files imported via @rollup/plugin-json or a similar JSON loader. It does not handle inline JSON objects.
fix
Add @rollup/plugin-json to your Rollup plugins list.
affects: *
deprecatedThe prefix option uses '[name]' placeholder for the JSON file name. This behavior is not explicitly documented in older versions.
fix
Review prefix syntax in README for version 1.2.0.
affects: <1.2.0
gotchaThe plugin does not support nested key references; it only replaces leaf values with the full key path. If a value is an object, it is not replaced.
fix
Ensure your JSON structure has intended leaf values (strings) to be replaced.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-json-map-keys'
Package not installed or misconfigured in package.json.
fix
Run 'npm install rollup-plugin-json-map-keys --save-dev'
TypeError: jsonMapKeys is not a function
CommonJS require returns module.exports object with default property.
fix
Use ES import: 'import jsonMapKeys from 'rollup-plugin-json-map-keys'' or use 'const jsonMapKeys = require('rollup-plugin-json-map-keys').default'
Error: '@rollup/plugin-json' is required to use rollup-plugin-json-map-keys
Plugin only transforms JSON files imported via Rollup JSON plugin; without it, no .json files are processed.
fix
Install and add @rollup/plugin-json to plugins array.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
rolluprequiredpeer dependency essential for plugin to function
Agent activity
4 hits · last 30 days
node
2
OpenAI (training)
2
Resources
rollup-plugin-json-map-keys — npm install rollup-plugin-json-map-keys · libregistry