unplugin-lingui-macro is a bundler-agnostic plugin that compiles Lingui macros in plain JavaScript and TypeScript modules. It provides `unplugin` entrypoints for various build tools including Vite, Rollup, Webpack, esbuild, Rolldown, Rspack, and Bun. This package is specifically designed for applications that use Lingui macros outside of framework-specific files (e.g., `.svelte` or `.astro`), where dedicated framework plugins handle the transformation. The current stable version is 0.3.1, with releases occurring as part of the broader `lingui-for` monorepo, suggesting an active but coordinated release cadence. A key differentiator is its focus on generic JS/TS files, offering optional `linguiConfig` overrides for macro and runtime bindings, but it does not perform Lingui message extraction; that remains a task for `@lingui/cli` and related extractors.
npm install unplugin-lingui-macroVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `unplugin-lingui-macro` into a Vite project using TypeScript, including basic plugin configuration and an example of how Lingui macros are used in a plain JavaScript/TypeScript module.
Review your `linguiConfig` plugin options and migrate to the new `config` option structure as described in the documentation, potentially utilizing `defineConfig` helpers if available.
Ensure your project's `package.json` specifies `@lingui/core` at `^5.0.0` or higher and that you are running Node.js 22 or newer. Update dependencies if necessary.
If working with framework-owned files, ensure you are using the correct framework-specific Lingui plugin in addition to or instead of `unplugin-lingui-macro`.
Set up `@lingui/cli` in your project, including `lingui extract` commands in your build pipeline, to manage the extraction of translatable messages from your source code.
Ensure you are importing the plugin with the correct suffix for your bundler, e.g., `import linguiMacro from 'unplugin-lingui-macro/vite';` for Vite.
Verify that `unplugin-lingui-macro` is added to your bundler's plugin list (e.g., `plugins: [linguiMacro()]` in Vite config). Ensure that Lingui dependencies are correctly installed and version compatible.
Install `@lingui/core` as a runtime dependency (`npm install @lingui/core`) and ensure that Lingui's `I18nProvider` (if using React) or `i18n` instance is initialized and available where needed.