{"id":25849,"library":"l10n-tools-compiler-json","title":"l10n-tools-compiler-json","description":"A JSON compiler for the l10n-tools i18n pipeline, targeting formats like vue-i18n, node-i18n, and i18next. Current stable version is 7.0.10, updated as part of a monorepo with active releases. It depends on l10n-tools-core ^8.0.0 as a peer dependency and requires Node.js >=22.19.0. Compared to other l10n compilers, it is specifically designed to integrate with the l10n-tools ecosystem, providing a unified workflow for extracting, compiling, and syncing translations.","status":"active","version":"7.0.10","language":"javascript","source_language":"en","source_url":"https://github.com/tpcint/l10n-tools","tags":["javascript","typescript"],"install":[{"cmd":"npm install l10n-tools-compiler-json","lang":"bash","label":"npm"},{"cmd":"yarn add l10n-tools-compiler-json","lang":"bash","label":"yarn"},{"cmd":"pnpm add l10n-tools-compiler-json","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency providing core compilation and pipeline logic","package":"l10n-tools-core","optional":false}],"imports":[{"note":"Package is ESM-only; CJS require will fail with MODULE_NOT_FOUND.","wrong":"const compileJson = require('l10n-tools-compiler-json')","symbol":"default","correct":"import compileJson from 'l10n-tools-compiler-json'"},{"note":"Named export is available for tree-shaking; avoid deep imports as they may break in future versions.","wrong":"import compileJson from 'l10n-tools-compiler-json/compile'","symbol":"compileJson","correct":"import { compileJson } from 'l10n-tools-compiler-json'"},{"note":"TypeScript types are shipped; use `import type` to avoid runtime overhead.","wrong":null,"symbol":"CompilerOptions","correct":"import type { CompilerOptions } from 'l10n-tools-compiler-json'"}],"quickstart":{"code":"import { compileJson } from 'l10n-tools-compiler-json';\n\nconst source = {\n  en: { greeting: 'Hello' },\n  fr: { greeting: 'Bonjour' }\n};\n\nconst options = {\n  format: 'vue-i18n',\n  namespace: 'common'\n};\n\ncompileJson(source, options)\n  .then(result => console.log(JSON.stringify(result, null, 2)))\n  .catch(err => console.error(err));","lang":"typescript","description":"Compiles a JSON locale object into vue-i18n formatted output using the compileJson function."},"warnings":[{"fix":"Upgrade Node.js to v22.19.0 or later.","message":"Package requires Node.js >=22.19.0. Older versions will fail to install or run.","severity":"breaking","affected_versions":"<7.0.0"},{"fix":"Use dynamic import() if needed: const { compileJson } = await import('l10n-tools-compiler-json').","message":"l10n-tools-compiler-json is ESM-only. It cannot be imported via require() in CommonJS modules.","severity":"gotcha","affected_versions":">=7.0.0"},{"fix":"Replace 'i18next' with 'i18next-v4' in the options.","message":"The `format: 'i18next'` option will be removed in v8. Use `format: 'i18next-v4'` instead.","severity":"deprecated","affected_versions":">=7.0.0 <8.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install l10n-tools-compiler-json` and ensure Node.js >=22.19.0.","cause":"Package is not installed or Node.js version is below 22.19.0.","error":"Error: Cannot find module 'l10n-tools-compiler-json'"},{"fix":"Use `import compileJson from 'l10n-tools-compiler-json'` for default export or `import { compileJson }` for named export.","cause":"Trying to use the default export as a named import, or vice versa.","error":"TypeError: compileJson is not a function"},{"fix":"Switch to ESM (use import) or use dynamic import: const { compileJson } = await import('l10n-tools-compiler-json').","cause":"Using CommonJS require() to import an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}