Registry / devops / ya-i18next-webpack-plugin

ya-i18next-webpack-plugin

JSON →
library0.5.0jsnpmunverified

A webpack plugin that automates i18next key collection and translation file management during webpack builds. Version 0.5.0 (stable, low release cadence) detects missing translation keys, saves them to specified paths, and copies translation resource files. Unlike other i18n webpack plugins, it integrates tightly with webpack's parsing phase and provides a config module for runtime setup. Requires webpack 5 as peer dependency. Ships TypeScript types.

npm install ya-i18next-webpack-plugin
INSTALL
IMPORT
SIG · YA-I18NEXT-WEBPACK
Y
ya-i18next-webpack-plugin
devopsjavascriptv0.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import i18nextPlugin from 'ya-i18next-webpack-plugin';
const i18nextPlugin = require('ya-i18next-webpack-plugin').default;
ESM default export; CJS require must use .default
config
import * as i18nConf from 'ya-i18next-webpack-plugin/config';
import { config } from 'ya-i18next-webpack-plugin';
Config module is a separate entry point, not a named export from main entry
Languages
import { Languages } from 'ya-i18next-webpack-plugin/config';
Config module exports Languages (array) and other constants; named imports work

Demonstrates plugin configuration and client-side usage with i18next and xhr-backend, including config module constants.

// webpack.config.js import i18nextPlugin from 'ya-i18next-webpack-plugin'; export default { plugins: [ new i18nextPlugin({ defaultLanguage: 'en', languages: ['en', 'ko'], functionName: '_t', resourcePath: './locales/{{lng}}/{{ns}}.json', pathToSaveMissing: './locales/{{lng}}/{{ns}}-missing.json' }) ] }; // index.js import * as i18next from 'i18next'; import * as Backend from 'i18next-xhr-backend'; import * as i18nConf from 'ya-i18next-webpack-plugin/config'; if (window._t === undefined) { i18next .use(Backend) .init({ fallbackLng: i18nConf.DEFAULT_NAMESPACE, whitelist: i18nConf.LANGUAGES, backend: { loadPath: `${__webpack_public_path__}${i18nConf.RESOURCE_PATH}` } }); window._t = i18next.t; } console.log(_t('hello_world'));
Debug
Known issues
breakingVersion 0.5.0 requires webpack 5 as a peer dependency. Using with webpack 4 will cause TypeScript or runtime errors.
fix
Ensure webpack@5 is installed (npm install webpack@5 --save-dev).
affects: >=0.5.0
gotchaThe plugin uses .default property when required via CommonJS (require). Forgetting .default results in undefined or constructor error.
fix
Use require('ya-i18next-webpack-plugin').default or use ES import.
affects: >=0.0.0
gotchaConfig module is at 'ya-i18next-webpack-plugin/config', not under main export. Incorrect path leads to module not found.
fix
Import config with 'import * as i18nConf from "ya-i18next-webpack-plugin/config"'.
affects: >=0.0.0
deprecatedPlugin uses __webpack_public_path__ which is webpack-specific and may conflict with modern setups using dynamic publicPath.
fix
Consider using __webpack_public_path__ = ... or publicPath in output config.
affects: >=0.0.0
breakingNo peer dependency on i18next; the plugin expects i18next to be used in client code but does not enforce version compatibility. Mismatch may cause runtime errors.
fix
Ensure i18next version is compatible with your client-side usage (e.g., i18next >= 20).
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: i18nextPlugin is not a constructor
Using require without .default: const i18nextPlugin = require('ya-i18next-webpack-plugin');
fix
Use const i18nextPlugin = require('ya-i18next-webpack-plugin').default;
Module not found: Error: Can't resolve 'ya-i18next-webpack-plugin/config'
Incorrect import path or missing config entry in bundler resolution.
fix
Ensure the import path is exactly 'ya-i18next-webpack-plugin/config'.
Error: Cannot find module 'webpack'
Missing webpack peer dependency.
fix
npm install webpack@5 --save-dev
TypeError: Cannot read property 't' of undefined
window._t not assigned because i18next.init failed or config module not imported.
fix
Ensure i18next is correctly initialized and the config module is imported before use.
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies
webpackrequiredpeer dependency, required version 5
Agent activity
12 hits · last 30 days
node
10
Resources
ya-i18next-webpack-plugin — npm install ya-i18next-webpack-plugin · libregistry