Registry / devops / i18next-scanner-webpack

i18next-scanner-webpack

JSON →
library1.0.0jsnpmunverified

A webpack plugin that automatically extracts i18n translation keys from your source code using i18next-parser. Integrates with webpack 5.x and requires Node.js >= 14.16.0. Version 1.0.0 includes breaking changes from v0.9.0: replaced the underlying scanner with i18next-parser. The plugin scans specified file extensions for translation function calls like t() and generates locale JSON files. Supports both ESM and CommonJS configs, async mode for faster dev builds, and customizable lexers for different file types. Differentiators: simple setup, tight webpack integration, and active maintenance.

npm install i18next-scanner-webpack
INSTALL
IMPORT
SIG · I18NEXT-SCANNER-WE
I
i18next-scanner-webpack
devopsjavascriptv1.0.0
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

I18nextWebpackPlugin
import I18nextWebpackPlugin from 'i18next-scanner-webpack'
const I18nextWebpackPlugin = require('i18next-scanner-webpack').default
Default export. In CommonJS, use const I18nextWebpackPlugin = require('i18next-scanner-webpack') — NOT with .default.
Constructor
new I18nextWebpackPlugin({ options: { locales: ['en', 'de'] } })
new I18nextWebpackPlugin({ locales: ['en', 'de'] })
Plugin options must be wrapped in an `options` object; locale configuration is part of the i18next-parser options.
CommonJS require
const I18nextWebpackPlugin = require('i18next-scanner-webpack')
const I18nextWebpackPlugin = require('i18next-scanner-webpack').default
CJS module.exports is the plugin class directly, not a default export object.

Sets up i18next-scanner-webpack in webpack 5 with ESM config, scanning .js and .jsx files for translation keys, outputting English and German locale files.

import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { dirname } from 'node:path'; import I18nextWebpackPlugin from 'i18next-scanner-webpack'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); export default { mode: 'development', entry: path.resolve(__dirname, './src/index.js'), output: { path: path.resolve(__dirname, 'dist'), filename: '[name].js' }, plugins: [ new I18nextWebpackPlugin({ src: './src', dest: './locales', extensions: ['.js', '.jsx'], options: { lexers: { js: [{ lexer: 'JavascriptLexer', functions: ['t', '$t', 'i18next.t', 'i18n.t'] }] }, locales: ['en', 'de'], output: '$LOCALE/$NAMESPACE.json' } }) ] };
Debug
Known issues
breakingv0.9.0 switched underlying scanner from i18next-scanner to i18next-parser. Config structure changed — options must now match i18next-parser format.
fix
Migrate config to use i18next-parser options (see v0.9.0 changelog). Example: replace `func` with `lexers`, `lngs` with `locales`, etc.
affects: >=0.9.0
breakingv1.0.0 requires Webpack 5.x. Earlier versions (0.x) may support Webpack 4.
fix
Upgrade to Webpack 5 if using v1.0.0+. For Webpack 4, use v0.8.3 or earlier.
affects: >=1.0.0
gotchaIf `async` option is set to `true`, webpack may finish before translation files are written — be cautious in production builds.
fix
Only use `async: true` in development mode. For production, set `async: false` (default).
affects: >=0.9.0
gotchaCommonJS require without .default: `const Plugin = require('i18next-scanner-webpack')` works. Using `.default` will result in `undefined`.
fix
Remove `.default` when requiring via CommonJS.
affects: *
deprecatedVersions <=0.8.3 use deprecated i18next-scanner package. Configs from those versions are incompatible with v0.9.0+.
fix
Update to v0.9.0+ and migrate config to i18next-parser format.
affects: <=0.8.3
Errors
Common errors & fixes
Cannot find module 'i18next-parser'
Missing peer dependency i18next-parser when using v0.9.0+.
fix
Run `npm install i18next-parser --save-dev` or check that it is in your dependencies.
TypeError: I18nextWebpackPlugin is not a constructor
Using `.default` on CommonJS require: `const Plugin = require('...').default` returns undefined.
fix
Use `const I18nextWebpackPlugin = require('i18next-scanner-webpack');` without `.default`.
Error: Configuration error. Cannot find 'options.locales'
Options not nested under `options` key in plugin config, e.g. `{ locales: ['en'] }` instead of `{ options: { locales: ['en'] } }`.
fix
Wrap i18next-parser options in an `options` property: `new I18nextWebpackPlugin({ options: { locales: ['en'] } })`.
Error: Unsupported file extension '.ts'
TypeScript files not scanned by default; need lexer configuration.
fix
Add lexers for TypeScript: `options.lexers.ts: [{ lexer: 'JavascriptLexer', functions: ['t'] }]`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
webpackrequiredpeer dependency — plugin is designed for Webpack 5.x
i18next-parserrequiredunderlying scanner engine used for parsing translation keys
Agent activity
6 hits · last 30 days
node
6
Resources
i18next-scanner-webpack — npm install i18next-scanner-webpack · libregistry