{"id":22127,"library":"rollup-plugin-messageformat","title":"rollup-plugin-messageformat","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/messageformat/messageformat","tags":["javascript","i18n","pluralformat","icu","selectformat","messageformat","internationalization","json","yaml","typescript"],"install":[{"cmd":"npm install rollup-plugin-messageformat","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-messageformat","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-messageformat","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required at runtime for generated message function code (e.g., plural, number, cardinal functions). Must be listed as a production dependency if publishing a library.","package":"@messageformat/runtime","optional":false}],"imports":[{"note":"The plugin exports a named export, not a default. CJS require will not work as expected in ESM projects.","wrong":"const messageformat = require('rollup-plugin-messageformat')","symbol":"messageformat","correct":"import { messageformat } from 'rollup-plugin-messageformat'"}],"quickstart":{"code":"// rollup.config.js\nimport { messageformat } from 'rollup-plugin-messageformat';\n\nexport default {\n  input: 'src/index.js',\n  output: { format: 'es', dir: 'dist' },\n  plugins: [\n    messageformat({\n      locales: ['en', 'fr'],\n      include: ['**/messages/**']\n    })\n  ]\n};\n\n// src/index.js\nimport frMessages from './messages/fr.yaml';\nimport enMessages from './messages/en.yaml';\n\nconst messages = { en: enMessages, fr: frMessages };\nconsole.log(messages.en.hello({ name: 'World' }));\nconsole.log(messages.fr.hello({ name: 'Monde' }));\n\n// messages/en.yaml\n// hello: \"Hello, {name}!\"\n// messages/fr.yaml\n// hello: \"Bonjour, {name}!\"","lang":"typescript","description":"Sets up Rollup with the messageformat plugin, imports YAML message files, and uses the generated message functions with locale data."},"warnings":[{"fix":"Explicitly list your supported locales in an array: locales: ['en', 'fr', 'de'].","message":"The \"locales\" option with value '*' is deprecated and will be removed in a future major version.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install @messageformat/runtime: npm install @messageformat/runtime","cause":"Missing runtime dependency required by generated code.","error":"Error: Cannot find module '@messageformat/runtime'"},{"fix":"Use import { messageformat } from 'rollup-plugin-messageformat' in ESM, or const { messageformat } = require('rollup-plugin-messageformat') in CJS.","cause":"Attempting to call the plugin as a function instead of using the named export.","error":"TypeError: messageformat is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}