esbuild-plugin-i18next-loader

raw JSON →
1.1.5 verified Fri May 01 auth: no javascript

esbuild plugin to bundle i18next translation files (JSON/YAML) into a virtual module for client-side use. Current stable version is 1.1.5, released under the i18next-utilities monorepo with regular patch updates. It rewrites alienfast/vite-plugin-i18next-loader for esbuild, supporting namespace resolution via basename or relative path, and multiple locale paths. Differentiators: ESM-only builds, TypeScript types included, virtual module generation for tree-shaking.

error Cannot find module 'esbuild-plugin-i18next-loader'
cause Package not installed or incorrect import path.
fix
Run npm install --save-dev esbuild-plugin-i18next-loader and ensure import path is correct.
error require() of ES Module esbuild-plugin-i18next-loader not supported
cause Package is ESM-only, require() not allowed.
fix
Use dynamic import: const { i18nextPlugin } = await import('esbuild-plugin-i18next-loader');
error TypeError: i18nextPlugin is not a function
cause Using default import after v1.1.0 when named export is required.
fix
Use import { i18nextPlugin } from 'esbuild-plugin-i18next-loader';
breaking ESM-only since v1.1.3
fix Use import syntax instead of require(). If using CommonJS, consider dynamic import.
gotcha namespaceResolution strategy must be set explicitly; if omitted, namespace defaults to basename but may cause collisions.
fix Set namespaceResolution to 'basename' or 'relativePath' as needed.
deprecated Plugin name changed from default export to named export in v1.1.0
fix Use named import { i18nextPlugin } instead of default import.
npm install esbuild-plugin-i18next-loader
yarn add esbuild-plugin-i18next-loader
pnpm add esbuild-plugin-i18next-loader

Shows how to use the plugin with esbuild to bundle i18next locale files from ./src/locales.

import { i18nextPlugin } from 'esbuild-plugin-i18next-loader';
import esbuild from 'esbuild';

await esbuild.build({
  entryPoints: ['./src/index.ts'],
  write: true,
  bundle: true,
  plugins: [
    i18nextPlugin({
      namespaceResolution: 'basename',
      paths: ['./src/locales'],
    }),
  ],
});