{"library":"messageformat-loader","title":"messageformat-loader","description":"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.","language":"javascript","status":"maintenance","last_verified":"Sat Apr 25","install":{"commands":["npm install messageformat-loader"],"cli":null},"imports":["// In webpack.config.js:\nmodule.exports = {\n  module: {\n    rules: [\n      { test: /\\.json$/, use: 'messageformat-loader' }\n    ]\n  }\n}"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  entry: './src/index.js',\n  module: {\n    rules: [\n      {\n        test: /\\.json$/,  // or .yaml, .yml\n        use: [\n          {\n            loader: 'messageformat-loader',\n            options: {\n              locale: 'en',         // default locale\n              locales: ['en', 'fr'], // available locales\n              biDiSupport: false\n            }\n          }\n        ]\n      }\n    ]\n  }\n};\n\n// src/messages/en.json\n{\n  \"greeting\": \"Hello {name}!\",\n  \"items\": \"You have {count, plural, =0 {no items} one {# item} other {# items}}.\"\n}\n\n// src/index.js\nimport messages from './messages/en.json';\nconsole.log(messages.greeting({ name: 'World' })); // \"Hello World!\"\nconsole.log(messages.items({ count: 3 })); // \"You have 3 items.\"","lang":"javascript","description":"Configures webpack to load JSON message files and compile ICU patterns using messageformat-loader.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}