/lingui:swc-plugin-compatibilityfrom Lingui Skills
Diagnoses and fixes Lingui SWC plugin compatibility errors with Next.js, Vite, Rspack, or other SWC runtimes. Helps when builds fail with Wasm plugin errors or macros silently render untranslated output.
Ships in Lingui Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
If you see errors like these during your build:
failed to invoke plugin on 'Some("/app/src/file.ts")'
failed to run Wasm plugin transform. Please ensure the version of `swc_core` used by the plugin is compatible with the host runtime.
swc_plugin_runner: <n>
: Failed to deserialize program received from host
Failed to execute SWC plugin (Next.js / Turbopack wording of the same failure)
RuntimeError: out of bounds memory access (older hosts)
LayoutError called Result::unwrap() (older hosts)
This is NOT a bug in your code or in Lingui. The installed @lingui/swc-plugin was built against an swc_core version your SWC host cannot run.
Every @lingui/swc-plugin release is compiled against one pinned swc_core version — the plugin's compatibility table lists them. The host (Next.js's bundled SWC, or the @swc/core that @vitejs/plugin-react-swc / Rspack resolves) accepts plugins from a range of swc_core versions. Outside that range the Wasm plugin cannot deserialize the AST it is handed, and the build fails on every file that uses a macro.
SWC has stabilised the plugin ABI over time, so mismatches are rarer than they were, but hosts still move past plugins and plugins past hosts (see lingui/swc-plugin #250 and #253 for one of each). The pairing is something to check, never assume.
| Signal in the project | Host | Read the version from |
|---|---|---|
next in dependencies, no .babelrc | Next.js's bundled SWC | npm ls next |
@vitejs/plugin-react-swc | @swc/core | npm ls @swc/core — the lockfile resolution, not the caret range the plugin declares |
Rspack / @swc/core directly | @swc/core | npm ls @swc/core |
Next.js embeds SWC and ignores any @swc/core in package.json; only the Next.js version decides its swc_core. On Vite, two projects with identical package.json can resolve different @swc/core versions — the lockfile is the source of truth.
On Vite, the first fix is the native transform ("Native Transform on Vite" below): @lingui/vite-plugin transforms the macros with its own prebuilt binary, outside the host's SWC, so there is no swc_core pairing and nothing to pin. The steps that follow are for Next.js, Rspack, and Vite builds the native binary can't run on.
swc_core range. The error message usually prints a https://plugins.swc.rs/versions/from-plugin-runner/<n> URL — open it in a browser; for Next.js, select runtime next and the resolved version on https://plugins.swc.rs. The site is client-rendered, so a plain fetch returns an empty page; the fallback is the host's own pin: for Next.js, swc_core in the root Cargo.toml of the vercel/next.js tag (v<version>), for @swc/core, its GitHub release notes.@lingui/swc-plugin whose swc_core falls inside that range.npm view @lingui/swc-plugin@<version> peerDependencies. Each plugin major requires the matching @lingui/core major as a required peer (a newer plugin major may also admit the previous core major). A candidate whose peer excludes the installed @lingui/core is not a candidate — the install fails with ERESOLVE instead of the build failing. Pick the next-newest that passes, or go to "What If No Compatible Version Exists?".The compatibility site has lagged behind releases before. When the table and the site disagree, or the host is newer than either lists, decide by building: try the newest plugin, then step back one swc_core row at a time until a macro-using file compiles.
Hosts drift independently, so two hosts in one repo (a Next.js app and a Vite app) can legitimately need two different plugin versions.
{
"devDependencies": {
"@lingui/swc-plugin": "<exact version>"
}
}
Use an exact version (no ^ or ~) so a routine dependency bump cannot move it. Done when the build passes on a file that uses a macro and the rendered output shows translated text rather than raw macro source.
swc_core in minor and patch releases, so a Next.js or @vitejs/plugin-react-swc bump needs the same check — put both packages in one update group.@lingui/swc-plugin does not track the other @lingui/* versions; it releases on its own cadence, so its version number carries no information about which @lingui/core it pairs with beyond the peer field.
// next.config.mjs
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
swcPlugins: [
['@lingui/swc-plugin', {
// Plugin options
}],
],
},
};
export default nextConfig;
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"experimental": {
"plugins": [
["@lingui/swc-plugin", {}]
]
}
}
}
// vite.config.ts — no @lingui/swc-plugin
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc"; // or @vitejs/plugin-react
import { lingui } from "@lingui/vite-plugin";
export default defineConfig({
plugins: [react(), lingui({ macroTransform: true })],
});
Requirements: @lingui/vite-plugin 6.9.1+, and a build machine with a prebuilt @lingui/native-tools binary (macOS, Windows, Linux glibc/musl on x64/arm64). There is no WASM fallback, so browser sandboxes such as StackBlitz WebContainers still need the SWC or Babel plugin.
// vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { lingui } from "@lingui/vite-plugin";
export default defineConfig({
plugins: [
react({ plugins: [["@lingui/swc-plugin", {}]] }),
lingui(),
],
});
Every SWC plugin entry must be a [name, options] tuple, even with empty options. Passing the plugin name as a bare string silently disables the macro transform: the build succeeds, but <Trans> never resolves and messages render as raw macro output.
// ❌ Silently does nothing
react({ plugins: ["@lingui/swc-plugin"] })
// ✅ Tuple with options object
react({ plugins: [["@lingui/swc-plugin", {}]] })
The same applies to Next.js swcPlugins and .swcrc plugins arrays.
Fixing the shape is the fix. On Vite, close by offering the native transform ("Native Transform on Vite") as a follow-up the user chooses: it drops the SWC plugin for good.
When no plugin version that installs beside the project's @lingui/core fits the host, make an explicit choice rather than guessing:
swc_core range has a matching plugin (usually forward: newer hosts accept newer plugins)@lingui/babel-plugin-lingui-macro) — see the caveats belowForcing the install (--legacy-peer-deps) or downgrading @lingui/core to satisfy an old plugin's peer are not on this list: the first hides the mismatch until the build, the second regresses the runtime to please a build tool.
npm install -D @lingui/babel-plugin-lingui-macro babel-plugin-macros @babel/types
// .babelrc
{ "presets": ["next/babel"], "plugins": ["macros"] }
Remove the experimental.swcPlugins entry. Three things the Babel path needs that the SWC plugin did not:
@babel/types installed explicitly. Next bundles its own Babel and does not expose it to plugins; without it the build fails with Cannot find package '@babel/types'.lingui.config.ts (or .js/.mjs). The Babel macro reads it at compile time; the SWC plugin never did, so a project that got by without one breaks here..babelrc turns off Next's SWC compiler for the whole project — Next prints Disabled SWC as replacement for Babel because of custom Babel configuration, and compiler options in next.config are ignored from then on. Builds get slower; prefer moving the host when that is an option.@vitejs/plugin-react@6 dropped its internal Babel and removed the babel option entirely. On v6+, the classic form:
react({ babel: { plugins: ["@lingui/babel-plugin-lingui-macro"] } })
no longer works — a TypeScript config fails with TS2353 ("babel does not exist in type..."); a plain JS config is silently ignored and macros never get transformed.
Your options on Vite:
lingui({ macroTransform: true }) with the stock React plugin — no Babel, no SWC plugin, no pin (preferred; see "Native Transform on Vite")@vitejs/plugin-react-swc + an exactly pinned @lingui/swc-plugin chosen by the steps above@rolldown/plugin-babel on Vite 8, vite-plugin-babel on Vite ≤ 7) — the lingui-framework-setup skill has the wiring@vitejs/plugin-react@^5, which still supports the babel optionWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub lingui/skills --plugin lingui6 skills in this plugin
/enhanced-message-contextAdd translator comments to Lingui messages so translations are accurate. Use in Lingui projects when adding or modifying translatable messages, when strings are short or ambiguous ("Back", "Delete", "Post"), when placeholders are unclear ({count}, {name}), when deciding between comment and context, or when auditing extracted .po catalogs for missing translator context./find-unwrapped-stringsAudit a Lingui project for hardcoded user-facing strings that were never wrapped in macros. Use when asked to find untranslated, unwrapped, or hardcoded strings, to check i18n coverage, to audit what an i18n setup or migration missed, or when text renders in the source language after everything was supposedly translated./lingui-best-practicesImplement internationalization with Lingui in React, Vue and JavaScript applications. Use when adding i18n, translating UI, working with Trans/useLingui/Plural, extracting messages, compiling catalogs, or when the user mentions Lingui, message extraction, ICU MessageFormat, or working with .po files. Not for projects on another i18n library (i18next, react-intl, next-intl) unless they are moving to Lingui./lingui-framework-setupSet up Lingui in a React or Vue framework. Use when adding Lingui to a Next.js App Router, Vite, React Router 7, Remix, TanStack Start, or Vue 3 (Vite, Nuxt) project, when wiring locale detection, locale-prefixed URLs, or SSR locale resolution, or when a working setup breaks after a framework or build-tool upgrade./migrate-i18next-to-linguiMigrate i18next/react-i18next projects to Lingui. Use when the user wants to replace i18next, react-i18next, useTranslation, i18n.t(), Trans i18nKey, or i18next JSON catalogs with Lingui equivalents. Covers package installation, config setup, code transformation patterns, plural migration, namespace handling, and catalog conversion.Other plugins' skills for the same job