5.5.2 • Published 10 months ago

@lingui/swc-plugin v5.5.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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"]
            // }
            // Lingui strips non-essential fields in production builds for performance.
            // You can override the default behavior with:
            // "stripNonEssentialFields": false/true
          },
        ],
      ],
    },
  },
}

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.

Compatibility

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 using a https://plugins.swc.rs/.

Below is a table referencing the swc_core version used during the plugin build, along with a link to the plugin's site to check compatibility with runtimes for this swc_core range.

Plugin Versionused swc_core
0.1.0, 4.0.0-next.00.52.8
0.2.*, 4.0.0-next.1 ~ 4.0.0-next.30.56.1
4.0.00.75.33
4.0.10.76.0
4.0.20.76.41
4.0.30.78.28
4.0.40.79.x
4.0.5, 4.0.60.87.x
4.0.7, 4.0.8, 5.0.0-next.0 ~ 5.0.0-next.10.90.35
4.0.90.96.9
4.0.100.101.4
4.1.0, 5.0.0 ~ 5.2.00.106.3
5.3.05.0.4
5.4.014.1.0
5.5.0 ~ 5.5.215.0.1

Note next v13.2.4 ~ v13.3.1 cannot execute SWC Wasm plugins, due to a bug of next-swc.

next v13.4.3 ~ v13.4.5-canary.7 cannot execute SWC Wasm plugins, due to missing filesystem cache.

  • Version 0.1.0 ~ 0.* compatible with @lingui/core@3.*
  • Version 4.* compatible with @lingui/core@4.*
  • Version 5.* compatible with @lingui/core@5.*

License

The project is licensed under the MIT license.

5.5.1

11 months ago

5.5.0

11 months ago

5.4.0

11 months ago

5.3.0

11 months ago

5.2.0

12 months ago

5.0.2

1 year ago

5.1.0

12 months ago

5.0.1

1 year ago

5.0.0

1 year ago

5.5.2

10 months ago

5.0.0-next.3

1 year ago

4.1.0

1 year ago

4.0.10

1 year ago

4.0.9

1 year ago

5.0.0-next.1

1 year ago

5.0.0-next.2

1 year ago

5.0.0-next.0

2 years ago

4.0.8

2 years ago

4.0.7

2 years ago

4.0.6

2 years ago

4.0.5

2 years ago

4.0.4

3 years ago

4.0.3

3 years ago

4.0.1

3 years ago

4.0.2

3 years ago

4.0.0

3 years ago

4.0.0-next.1

3 years ago

4.0.0-next.0

3 years ago

4.0.0-next.3

3 years ago

4.0.0-next.2

3 years ago

0.2.1

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago