@lingui/swc-plugin 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Lingui
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,9 +1,18 @@
1
- # A SWC Plugin For LinguiJS
1
+ # <div align="center">A SWC Plugin For LinguiJS</div>
2
2
 
3
- ## Description
4
- This is a Rust versions of [LinguiJS Macro](https://lingui.js.org/ref/macro.html)
3
+ <div align="center">
5
4
 
6
- # Usage
5
+ A Rust versions of [LinguiJS Macro](https://lingui.js.org/ref/macro.html) [<img src="https://img.shields.io/badge/beta-yellow"/>](https://github.com/lingui/swc-plugin)
6
+
7
+ [![npm](https://img.shields.io/npm/v/@lingui/swc-plugin?logo=npm&cacheSeconds=1800)](https://www.npmjs.com/package/@lingui/swc-plugin)
8
+ [![npm](https://img.shields.io/npm/dt/@lingui/swc-plugin?cacheSeconds=500)](https://www.npmjs.com/package/@lingui/swc-plugin)
9
+ [![CI](https://github.com/lingui/swc-plugin/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/lingui/swc-plugin/actions/workflows/ci.yml)
10
+ [![GitHub contributors](https://img.shields.io/github/contributors/lingui/swc-plugin?cacheSeconds=1000)](https://github.com/lingui/swc-plugin/graphs/contributors)
11
+ [![GitHub](https://img.shields.io/github/license/lingui/swc-plugin)](https://github.com/lingui/swc-plugin/blob/main/LICENSE)
12
+
13
+ </div>
14
+
15
+ ## Usage
7
16
 
8
17
  `.swcrc`
9
18
  https://swc.rs/docs/configuration/swcrc
@@ -18,17 +27,36 @@ https://swc.rs/docs/configuration/swcrc
18
27
  // Optional
19
28
  // Unlike the JS version this option must be passed as object only.
20
29
  // Docs https://lingui.js.org/ref/conf.html#std-config-runtimeConfigModule
21
- "runtimeModules": {
22
- "i18n": ["@lingui/core", "i18n"],
23
- "trans": ["@lingui/react", "Trans"]
24
- }
30
+ // "runtimeModules": {
31
+ // "i18n": ["@lingui/core", "i18n"],
32
+ // "trans": ["@lingui/react", "Trans"]
33
+ // }
25
34
  }]
26
35
  }
27
36
  }
28
37
  }
29
38
  ```
30
39
 
31
- ### Tasks:
40
+ Or Next JS Usage:
41
+
42
+ `next.config.js`
43
+ ```js
44
+ /** @type {import('next').NextConfig} */
45
+ const nextConfig = {
46
+ reactStrictMode: true,
47
+ experimental: {
48
+ swcPlugins: [
49
+ ['@lingui/swc-plugin', {
50
+ // the same options as in .swcrc
51
+ }],
52
+ ],
53
+ },
54
+ };
55
+
56
+ module.exports = nextConfig;
57
+ ```
58
+
59
+ ### Tasks
32
60
  - [x] Essential `t` macro cases:
33
61
  - [x] ``t`Some string` ``
34
62
  - [x] ``t`Some ${variable} string` ``
@@ -63,6 +91,10 @@ https://swc.rs/docs/configuration/swcrc
63
91
  - [x] Unicode escaping, validate how SWC produce values
64
92
  - [x] Support `runtimeConfigModule` settings
65
93
  - [ ] NON-ESSENTIAL Injecting uniq variables, avoiding collision with existing variables
66
- - [ ] NON-ESSENTIAL support renamed macro calls `import {t as macroT} from "@lingui/macro"`
94
+ - [x] NON-ESSENTIAL support renamed macro calls `import {t as macroT} from "@lingui/macro"`
67
95
  - [ ] Error handling: how to properly behave to do if user passed something not expected [HANDLER](https://rustdoc.swc.rs/swc_common/errors/struct.Handler.html)
68
- - [ ] Building binary and publishing
96
+ - [x] Building binary and publishing
97
+
98
+ ## License
99
+
100
+ The project is licensed under the [MIT](https://github.com/lingui/swc-plugin/blob/main/LICENSE) license.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@lingui/swc-plugin",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "A SWC Plugin for LinguiJS",
5
5
  "author": {
6
6
  "name": "Timofei Iatsenko",
7
7
  "email": "ty@road.travel"
8
8
  },
9
- "license": "ISC",
9
+ "license": "MIT",
10
10
  "keywords": [
11
11
  "swc-plugin",
12
12
  "swc",