{"id":22541,"library":"vite-bundled-i18n","title":"vite-bundled-i18n","description":"Route-aware i18n bundler for Vite that extracts translation keys via AST analysis at build time and emits per-route scope-matched JSON bundles. Current stable version is 0.7.2, released with weekly or bi-weekly cadence. Unlike traditional i18n libraries (react-i18next, vue-i18n) that load all translations globally, vite-bundled-i18n tree-shakes translations per page, reducing payload from thousands of keys to only the ones needed for the current route. Supports React, Vue, and vanilla JS with a shared ~50-line core, optional compiled Map modules for O(1) lookup, SSR with automatic hydration, type-safe placeholder validation, and a testing utility. Requires Node >=20, peer deps: react >=18, react-dom >=18, vue ^3.0.0, eslint >=8.","status":"active","version":"0.7.2","language":"javascript","source_language":"en","source_url":"https://github.com/nicolasvlachos/vite-bundled-i18n","tags":["javascript","i18n","vite","react","translations","localization","typescript"],"install":[{"cmd":"npm install vite-bundled-i18n","lang":"bash","label":"npm"},{"cmd":"yarn add vite-bundled-i18n","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-bundled-i18n","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for React adapter; required if using React.","package":"react","optional":true},{"reason":"Peer dependency for React DOM rendering; required if using React.","package":"react-dom","optional":true},{"reason":"Peer dependency for Vue adapter; required if using Vue.","package":"vue","optional":true},{"reason":"Peer dependency for ESLint integration; required if using scope registration audit or other ESLint features.","package":"eslint","optional":true}],"imports":[{"note":"ESM-only; no CJS support. Must be imported as named export; no default export.","wrong":"const i18nPlugin = require('vite-bundled-i18n')","symbol":"i18nPlugin","correct":"import { i18nPlugin } from 'vite-bundled-i18n'"},{"note":"The t function is exported from framework-specific subpath: '/react', '/vue', or '/vanilla'. Importing from root will not include the function.","wrong":"import { t } from 'vite-bundled-i18n'","symbol":"t","correct":"import { t } from 'vite-bundled-i18n/react'"},{"note":"Testing utilities are exported from '/testing' subpath. From version 0.5.0 onwards.","wrong":"import { createI18nTestPlugin } from 'vite-bundled-i18n'","symbol":"createI18nTestPlugin","correct":"import { createI18nTestPlugin } from 'vite-bundled-i18n/testing'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport react from '@vitejs/plugin-react';\nimport { i18nPlugin } from 'vite-bundled-i18n';\n\nexport default defineConfig({\n  plugins: [\n    react(),\n    i18nPlugin()\n  ]\n});\n\n// src/App.tsx\nimport { useI18n } from 'vite-bundled-i18n/react';\n\nexport default function App() {\n  const { t } = useI18n();\n  return <h1>{t('greeting', { name: 'World' })}</h1>;\n}\n\n// src/locales/en.json\n{\n  \"greeting\": \"Hello, {{name}}!\"\n}","lang":"typescript","description":"Shows minimal setup: configure Vite plugin, use useI18n hook in React component, create a JSON locale file."},"warnings":[{"fix":"Replace 'import { viteBundledI18n } from 'vite-bundled-i18n'' with 'import { i18nPlugin } from 'vite-bundled-i18n''.","message":"Version 0.7.0 changed the plugin export name from 'viteBundledI18n' to 'i18nPlugin'. Old imports will fail with 'undefined is not a function'.","severity":"breaking","affected_versions":">=0.7.0"},{"fix":"Use dynamic import() or switch project to ESM (\"type\": \"module\" in package.json).","message":"Version 0.6.0 migrated from CJS to ESM-only. CommonJS require() throws 'ERR_REQUIRE_ESM'.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Use the plugin's built-in scope map handling; remove calls to createScopeMapClient.","message":"The 'createScopeMapClient' function is deprecated since version 0.7.0 in favor of runtime plugin configuration.","severity":"deprecated","affected_versions":">=0.6.0, <0.7.0"},{"fix":"Ensure translation files are in 'src/locales/' or configure with 'bundling.localesDir'.","message":"Translation files must be named with locale code (e.g., 'en.json', 'de.json') and placed inside a 'locales' directory at project root by default. Files elsewhere won't be picked up.","severity":"gotcha","affected_versions":"*"},{"fix":"Use 'import { t } from 'vite-bundled-i18n/react'' for React projects.","message":"The t() function is not available from the root import; you must import from a framework-specific subpath (e.g., 'vite-bundled-i18n/react').","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":"Switch your project to ESM (\"type\": \"module\" in package.json) or use dynamic import: const { i18nPlugin } = await import('vite-bundled-i18n');","cause":"Trying to require() an ESM-only module from CJS","error":"Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /node_modules/vite-bundled-i18n/index.js"},{"fix":"Import as: import { i18nPlugin } from 'vite-bundled-i18n'","cause":"Using deprecated export name 'viteBundledI18n' (pre-0.7.0) or importing wrong symbol","error":"TypeError: i18nPlugin is not a function"},{"fix":"Check the correct subpath: for React use '/react', for Vue '/vue', for vanilla '/vanilla'","cause":"Typo in import path or using wrong framework (e.g., trying to import t from '/vue' in React project)","error":"Module '\"vite-bundled-i18n/react\"' does not provide an export named 't'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}