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-messageformatVerified import paths — ran on the pinned version, not inferred.
Sets up Rollup with the messageformat plugin, imports YAML message files, and uses the generated message functions with locale data.
Explicitly list your supported locales in an array: locales: ['en', 'fr', 'de'].
Install @messageformat/runtime: npm install @messageformat/runtime
Use import { messageformat } from 'rollup-plugin-messageformat' in ESM, or const { messageformat } = require('rollup-plugin-messageformat') in CJS.