Registry / serialization / messageformat-loader

messageformat-loader

JSON →
library0.8.1jsnpmunverified

Webpack loader that compiles MessageFormat ICU message strings into JavaScript modules at build time. Supports JSON, YAML, and JS source files containing ICU MessageFormat strings. Compatible with messageformat 1.x and 2.x. The loader transforms message resources into pre-compiled functions for efficient runtime internationalization. While the core messageformat library has moved to v4 (prerelease) with a rewritten API and MF2 spec support, this loader remains at v0.8.1 and only supports the older 1.x/2.x versions. Key differentiator: integrates MessageFormat compilation into webpack pipeline, avoiding runtime compilation overhead.

npm install messageformat-loader
INSTALL
IMPORT
SIG · MESSAGEFORMAT-LOAD
M
messageformat-loader
serializationjavascriptv0.8.1
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.

default export
// In webpack.config.js: module.exports = { module: { rules: [ { test: /\.json$/, use: 'messageformat-loader' } ] } }
loader: 'messageformat-loader' // string is fine; but if using options object, must specify properly
Loader is used in webpack config, not in application code. Configure with 'messageformat-loader' as the loader name.

Configures webpack to load JSON message files and compile ICU patterns using messageformat-loader.

// webpack.config.js module.exports = { entry: './src/index.js', module: { rules: [ { test: /\.json$/, // or .yaml, .yml use: [ { loader: 'messageformat-loader', options: { locale: 'en', // default locale locales: ['en', 'fr'], // available locales biDiSupport: false } } ] } ] } }; // src/messages/en.json { "greeting": "Hello {name}!", "items": "You have {count, plural, =0 {no items} one {# item} other {# items}}." } // src/index.js import messages from './messages/en.json'; console.log(messages.greeting({ name: 'World' })); // "Hello World!" console.log(messages.items({ count: 3 })); // "You have 3 items."
Debug
Known issues
gotchaLoader only supports messageformat 1.x or 2.x; does not work with messageformat v4
fix
Use messageformat 2.x (e.g., 'messageformat': '^2.0.0') or stay on 1.x. Do not install messageformat@4.
affects: >=0.8.0
deprecatedThe loader is no longer actively maintained; the underlying messageformat library has moved to v4 with a completely different API
fix
Consider migrating to messageformat v4 and using a custom loader or runtime compilation with @messageformat/core
affects: >=0.8.0
gotchaLocale option is required; if not provided, the loader falls back to 'en' but may produce incorrect date/number formatting for other locales
fix
Always specify the 'locale' or 'locales' option matching your message files
affects: >=0.8.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'messageformat' in '...'
Missing peer dependency messageformat
fix
npm install messageformat@^2.0.0
Error: Cannot find module 'messageformat/compile-module'
messageformat version not compatible (e.g., v4 installed)
fix
npm install messageformat@^2.0.0
TypeError: messageformat_loader is not a function
Using loader incorrectly in webpack config (e.g., as a plugin)
fix
Configure as `loader: 'messageformat-loader'` inside a `rules` array, not as a plugin.
Upgrade
Version history
0.8.1latest on npm
Audit
Dependencies
messageformatrequiredRequired peer dependency; must be installed separately as messageformat 1.x or 2.x
Agent activity
3 hits · last 30 days
node
2
Amazon
1
Resources
messageformat-loader — npm install messageformat-loader · libregistry