Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lingui/swc-plugin
A SWC Plugin For LinguiJS
https://github.com/lingui/swc-plugin
hacktoberfest i18n icu internationalization lingui messageformat swc swc-plugin
Last synced: about 17 hours ago
JSON representation
A SWC Plugin For LinguiJS
- Host: GitHub
- URL: https://github.com/lingui/swc-plugin
- Owner: lingui
- License: mit
- Created: 2022-12-15T15:20:37.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-06T08:40:02.000Z (14 days ago)
- Last Synced: 2025-02-12T06:12:19.929Z (8 days ago)
- Topics: hacktoberfest, i18n, icu, internationalization, lingui, messageformat, swc, swc-plugin
- Language: Rust
- Homepage: https://www.npmjs.com/package/@lingui/swc-plugin
- Size: 477 KB
- Stars: 64
- Watchers: 4
- Forks: 17
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
#
A SWC Plugin For LinguiJSA Rust versions of [LinguiJS Macro](https://lingui.dev/ref/macro) [
](https://github.com/lingui/swc-plugin)
[](https://www.npmjs.com/package/@lingui/swc-plugin)
[](https://www.npmjs.com/package/@lingui/swc-plugin)
[](https://github.com/lingui/swc-plugin/actions/workflows/ci.yml)
[](https://github.com/lingui/swc-plugin/graphs/contributors)
[](https://github.com/lingui/swc-plugin/blob/main/LICENSE)## Installation
Install plugin:
```bash
npm install --save-dev @lingui/swc-plugin
# or
yarn add -D @lingui/swc-plugin
```You still need to install `@lingui/macro` for typings support:
```bash
npm install @lingui/macro
# or
yarn add @lingui/macro
```## Usage
`.swcrc`
https://swc.rs/docs/configuration/swcrc```json5
{
"$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`
```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/.
> **Note**
> next `v13.2.4` ~ `v13.3.1` cannot execute SWC Wasm plugins, due to a [bug of next-swc](https://github.com/vercel/next.js/issues/46989#issuecomment-1486989081).
>
> next `v13.4.3` ~ `v13.4.5-canary.7` cannot execute SWC Wasm plugins, due to [missing filesystem cache](https://github.com/vercel/next.js/pull/50651).- 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](https://github.com/lingui/swc-plugin/blob/main/LICENSE) license.