A Rust versions of LinguiJS Macro
Install plugin:
npm install --save-dev @lingui/swc-plugin
# or
yarn add -D @lingui/swc-plugin
You still need to install @lingui/macro
for typings support:
npm install @lingui/macro
# or
yarn add @lingui/macro
.swcrc
https://swc.rs/docs/configuration/swcrc
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"experimental": {
"plugins": [
[
"@lingui/swc-plugin",
{
// Optional
// Unlike the JS version this option must be passed as object only.
// Docs https://lingui.dev/ref/conf#runtimeconfigmodule
// "runtimeModules": {
// "i18n": ["@lingui/core", "i18n"],
// "trans": ["@lingui/react", "Trans"]
// }
},
],
],
},
},
}
Or Next JS Usage:
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: {
swcPlugins: [
['@lingui/swc-plugin', {
// the same options as in .swcrc
}],
],
},
};
module.exports = nextConfig;
Note Consult with full working example for NextJS in the
/examples
folder in this repo.
SWC Plugin support is still experimental. They do not guarantee a semver backwards compatibility between different swc-core
versions.
So you need to select an appropriate version of the plugin to match compatible swc_core
.
Plugin Version | used swc_core |
Compatibility |
---|---|---|
0.1.0 , 4.0.0-next.0 |
0.52.8 |
[email protected] ~ [email protected] |
0.2.* , 4.0.0-next.1 ~ 4.0.0-next.3 |
0.56.1 |
@swc/[email protected] ~ @swc/[email protected] [email protected] ~ [email protected] |
4.0.0 |
0.75.33 |
@swc/[email protected] ~ @swc/[email protected] [email protected] ~ [email protected] |
4.0.1 |
0.76.0 |
@swc/[email protected] ~ [email protected] ~ |
If this table becomes outdated, it is recommended to check the compatibility by referring to the upstream's Selecting the version article. This will help you select the appropriate plugin version for your project.
Note next
v13.2.4
~v13.3.1
cannot execute SWC Wasm plugins, due to a bug of next-swc.
- Version
0.1.0
~0.*
compatible with@lingui/core@3.*
- Version
4.*
compatible with@lingui/core@4.*
The project is licensed under the MIT license.