Skip to content

taozhou-glean/swc-plugin

 
 

Repository files navigation

A SWC Plugin For LinguiJS

A Rust versions of LinguiJS Macro

npm npm CI GitHub contributors GitHub

Installation

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

Usage

.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.

License

The project is licensed under the MIT license.

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%