Registry / serialization / rollup-plugin-messageformat

rollup-plugin-messageformat

JSON →
library3.0.0jsnpmunverified

Rollup plugin that lets you import JSON, YAML, and .properties files containing ICU MessageFormat messages, converting them into message functions compatible with @messageformat/react and @messageformat/runtime. Current stable version is 3.0.0, supporting Node >=14 and shipping TypeScript types. The plugin handles locale-aware file matching, key-path parsing for .properties, and tree-shaking by extracting only used messages. It requires @messageformat/runtime as a runtime peer dependency for generated code. Unlike manual message loading, it integrates directly into the Rollup build pipeline, enabling efficient code splitting and smaller bundles.

npm install rollup-plugin-messageformat
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-MESS
R
rollup-plugin-messageformat
serializationjavascriptv3.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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

messageformat
import { messageformat } from 'rollup-plugin-messageformat'
const messageformat = require('rollup-plugin-messageformat')
The plugin exports a named export, not a default. CJS require will not work as expected in ESM projects.

Sets up Rollup with the messageformat plugin, imports YAML message files, and uses the generated message functions with locale data.

// rollup.config.js import { messageformat } from 'rollup-plugin-messageformat'; export default { input: 'src/index.js', output: { format: 'es', dir: 'dist' }, plugins: [ messageformat({ locales: ['en', 'fr'], include: ['**/messages/**'] }) ] }; // src/index.js import frMessages from './messages/fr.yaml'; import enMessages from './messages/en.yaml'; const messages = { en: enMessages, fr: frMessages }; console.log(messages.en.hello({ name: 'World' })); console.log(messages.fr.hello({ name: 'Monde' })); // messages/en.yaml // hello: "Hello, {name}!" // messages/fr.yaml // hello: "Bonjour, {name}!"
Debug
Known issues
deprecatedThe "locales" option with value '*' is deprecated and will be removed in a future major version.
fix
Explicitly list your supported locales in an array: locales: ['en', 'fr', 'de'].
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module '@messageformat/runtime'
Missing runtime dependency required by generated code.
fix
Install @messageformat/runtime: npm install @messageformat/runtime
TypeError: messageformat is not a function
Attempting to call the plugin as a function instead of using the named export.
fix
Use import { messageformat } from 'rollup-plugin-messageformat' in ESM, or const { messageformat } = require('rollup-plugin-messageformat') in CJS.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
@messageformat/runtimerequiredRequired at runtime for generated message function code (e.g., plural, number, cardinal functions). Must be listed as a production dependency if publishing a library.
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-messageformat — npm install rollup-plugin-messageformat · libregistry