{"id":22099,"library":"rollup-plugin-json-map-keys","title":"rollup-plugin-json-map-keys","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/tiagoporto/object-value-to-object-path","tags":["javascript","rollup","transformer","json","key","i18n"],"install":[{"cmd":"npm install rollup-plugin-json-map-keys","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-json-map-keys","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-json-map-keys","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency essential for plugin to function","package":"rollup","optional":false}],"imports":[{"note":"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.","wrong":"const jsonMapKeys = require('rollup-plugin-json-map-keys')","symbol":"default","correct":"import jsonMapKeys from 'rollup-plugin-json-map-keys'"},{"note":"Plugin is exported as default export, not named.","wrong":"import { jsonMapKeys } from 'rollup-plugin-json-map-keys'","symbol":"jsonMapKeys (default)","correct":"import jsonMapKeys from 'rollup-plugin-json-map-keys'"},{"note":"No TypeScript types are bundled; users should import Plugin from Rollup itself.","wrong":"import { Plugin } from 'rollup-plugin-json-map-keys'","symbol":"Plugin type","correct":"import type { Plugin } from 'rollup'; // for TS users then use as return type of function"}],"quickstart":{"code":"import jsonMapKeys from 'rollup-plugin-json-map-keys';\nimport json from '@rollup/plugin-json'; // to import JSON files\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'es'\n  },\n  plugins: [\n    json(), // resolves .json imports\n    jsonMapKeys({\n      prefix: '[name]:' // optional prefix for key paths\n    })\n  ]\n};","lang":"javascript","description":"Configures Rollup to replace JSON values with dot-separated key paths, demonstates typical usage with @rollup/plugin-json."},"warnings":[{"fix":"Update to rollup-plugin-json-map-keys@1.2.0 or later; verify lockfile for correct package.","message":"After 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.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Add @rollup/plugin-json to your Rollup plugins list.","message":"The plugin works only with JSON files imported via @rollup/plugin-json or a similar JSON loader. It does not handle inline JSON objects.","severity":"gotcha","affected_versions":"*"},{"fix":"Review prefix syntax in README for version 1.2.0.","message":"The prefix option uses '[name]' placeholder for the JSON file name. This behavior is not explicitly documented in older versions.","severity":"deprecated","affected_versions":"<1.2.0"},{"fix":"Ensure your JSON structure has intended leaf values (strings) to be replaced.","message":"The 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.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'npm install rollup-plugin-json-map-keys --save-dev'","cause":"Package not installed or misconfigured in package.json.","error":"Error: Cannot find module 'rollup-plugin-json-map-keys'"},{"fix":"Use ES import: 'import jsonMapKeys from 'rollup-plugin-json-map-keys'' or use 'const jsonMapKeys = require('rollup-plugin-json-map-keys').default'","cause":"CommonJS require returns module.exports object with default property.","error":"TypeError: jsonMapKeys is not a function"},{"fix":"Install and add @rollup/plugin-json to plugins array.","cause":"Plugin only transforms JSON files imported via Rollup JSON plugin; without it, no .json files are processed.","error":"Error: '@rollup/plugin-json' is required to use rollup-plugin-json-map-keys"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}