Skip to content

@ladjs/i18n / i18n-locales silently broken by webpack 5.108.x — all emails fail with empty locale list #478

Description

@daniel5150

Bug report

Summary

A webpack regression introduced between v5.104.1 and v5.108.0 causes the i18n-locales JSON array (a transitive dependency of email-templates via @ladjs/i18n) to be emitted as an empty stub (module.exports = []) when bundled with usedExports: true. This makes every new I18N({ locales: ['de', 'en'] }) call throw Invalid locales: de, en at render time, causing the mailer to silently skip every email job.

Dependency chain

email-templates@ladjs/i18ni18n-locales (JSON array, last published 2021)

Root cause

With optimization.usedExports: true and sideEffects: false, webpack 5.108.x incorrectly treats individual array elements as named exports, finds none referenced, and stubs the entire module as []. A bug report has been filed with webpack: webpack/webpack#21426

Impact

  • All email rendering silently fails — no error surfaced to callers, jobs report { sent: true }
  • The build stays green (no compilation error or warning)
  • Affects any project that bundles email-templates with webpack's usedExports optimization enabled

Workarounds (for users)

  1. Pin webpack to 5.104.1 in resolutions
  2. Add { test: /\.json$/, sideEffects: true } to webpack.module.rules

Suggested fix for this library

  1. Add "sideEffects": true to i18n-locales/package.json — one-liner PR to ladjs/i18n-locales
  2. Replace @ladjs/i18n with i18next — actively maintained, same dot-notation JSON locale format, identical t(key) API, not affected by this regression

Environment

  • email-templates: 13.0.1
  • @ladjs/i18n: 10.0.0
  • i18n-locales: 0.0.5 (no updates since 2021)
  • webpack: 5.108.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions