Registry / web-framework / vite-bundled-i18n

vite-bundled-i18n

JSON →
library0.7.2jsnpmunverified

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.

npm install vite-bundled-i18n
INSTALL
IMPORT
SIG · VITE-BUNDLED-I18N
V
vite-bundled-i18n
web-frameworkjavascriptv0.7.2
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.

i18nPlugin
import { i18nPlugin } from 'vite-bundled-i18n'
const i18nPlugin = require('vite-bundled-i18n')
ESM-only; no CJS support. Must be imported as named export; no default export.
t
import { t } from 'vite-bundled-i18n/react'
import { t } from 'vite-bundled-i18n'
The t function is exported from framework-specific subpath: '/react', '/vue', or '/vanilla'. Importing from root will not include the function.
createI18nTestPlugin
import { createI18nTestPlugin } from 'vite-bundled-i18n/testing'
import { createI18nTestPlugin } from 'vite-bundled-i18n'
Testing utilities are exported from '/testing' subpath. From version 0.5.0 onwards.

Shows minimal setup: configure Vite plugin, use useI18n hook in React component, create a JSON locale file.

// vite.config.ts import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { i18nPlugin } from 'vite-bundled-i18n'; export default defineConfig({ plugins: [ react(), i18nPlugin() ] }); // src/App.tsx import { useI18n } from 'vite-bundled-i18n/react'; export default function App() { const { t } = useI18n(); return <h1>{t('greeting', { name: 'World' })}</h1>; } // src/locales/en.json { "greeting": "Hello, {{name}}!" }
Debug
Known issues
breakingVersion 0.7.0 changed the plugin export name from 'viteBundledI18n' to 'i18nPlugin'. Old imports will fail with 'undefined is not a function'.
fix
Replace 'import { viteBundledI18n } from 'vite-bundled-i18n'' with 'import { i18nPlugin } from 'vite-bundled-i18n''.
affects: >=0.7.0
breakingVersion 0.6.0 migrated from CJS to ESM-only. CommonJS require() throws 'ERR_REQUIRE_ESM'.
fix
Use dynamic import() or switch project to ESM ("type": "module" in package.json).
affects: >=0.6.0
deprecatedThe 'createScopeMapClient' function is deprecated since version 0.7.0 in favor of runtime plugin configuration.
fix
Use the plugin's built-in scope map handling; remove calls to createScopeMapClient.
affects: >=0.6.0, <0.7.0
gotchaTranslation 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.
fix
Ensure translation files are in 'src/locales/' or configure with 'bundling.localesDir'.
affects: *
gotchaThe t() function is not available from the root import; you must import from a framework-specific subpath (e.g., 'vite-bundled-i18n/react').
fix
Use 'import { t } from 'vite-bundled-i18n/react'' for React projects.
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /node_modules/vite-bundled-i18n/index.js
Trying to require() an ESM-only module from CJS
fix
Switch your project to ESM ("type": "module" in package.json) or use dynamic import: const { i18nPlugin } = await import('vite-bundled-i18n');
TypeError: i18nPlugin is not a function
Using deprecated export name 'viteBundledI18n' (pre-0.7.0) or importing wrong symbol
fix
Import as: import { i18nPlugin } from 'vite-bundled-i18n'
Module '"vite-bundled-i18n/react"' does not provide an export named 't'
Typo in import path or using wrong framework (e.g., trying to import t from '/vue' in React project)
fix
Check the correct subpath: for React use '/react', for Vue '/vue', for vanilla '/vanilla'
Upgrade
Version history
0.7.2latest on npm
Audit
Dependencies
reactoptionalPeer dependency for React adapter; required if using React.
react-domoptionalPeer dependency for React DOM rendering; required if using React.
vueoptionalPeer dependency for Vue adapter; required if using Vue.
eslintoptionalPeer dependency for ESLint integration; required if using scope registration audit or other ESLint features.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
vite-bundled-i18n — npm install vite-bundled-i18n · libregistry