@lingui/swc-plugin 0.2.0 → 0.2.1

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <div align="center">
4
4
 
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)
5
+ A Rust versions of [LinguiJS Macro](https://lingui.dev/ref/macro) [<img src="https://img.shields.io/badge/beta-yellow"/>](https://github.com/lingui/swc-plugin)
6
6
 
7
7
  [![npm](https://img.shields.io/npm/v/@lingui/swc-plugin?logo=npm&cacheSeconds=1800)](https://www.npmjs.com/package/@lingui/swc-plugin)
8
8
  [![npm](https://img.shields.io/npm/dt/@lingui/swc-plugin?cacheSeconds=500)](https://www.npmjs.com/package/@lingui/swc-plugin)
@@ -12,6 +12,22 @@ A Rust versions of [LinguiJS Macro](https://lingui.js.org/ref/macro.html) [<img
12
12
 
13
13
  </div>
14
14
 
15
+ ## Installation
16
+
17
+ Install plugin:
18
+ ```bash
19
+ npm install --save-dev @lingui/swc-plugin
20
+ # or
21
+ yarn add -D @lingui/swc-plugin
22
+ ```
23
+
24
+ You still need to install `@lingui/macro` for typings support:
25
+ ```bash
26
+ npm install @lingui/macro
27
+ # or
28
+ yarn add @lingui/macro
29
+ ```
30
+
15
31
  ## Usage
16
32
 
17
33
  `.swcrc`
@@ -22,18 +38,22 @@ https://swc.rs/docs/configuration/swcrc
22
38
  "$schema": "https://json.schemastore.org/swcrc",
23
39
  "jsc": {
24
40
  "experimental": {
25
- "plugins": ["@lingui/swc-plugin", {
26
-
27
- // Optional
28
- // Unlike the JS version this option must be passed as object only.
29
- // Docs https://lingui.js.org/ref/conf.html#std-config-runtimeConfigModule
30
- // "runtimeModules": {
31
- // "i18n": ["@lingui/core", "i18n"],
32
- // "trans": ["@lingui/react", "Trans"]
33
- // }
34
- }]
35
- }
36
- }
41
+ "plugins": [
42
+ [
43
+ "@lingui/swc-plugin",
44
+ {
45
+ // Optional
46
+ // Unlike the JS version this option must be passed as object only.
47
+ // Docs https://lingui.dev/ref/conf#runtimeconfigmodule
48
+ // "runtimeModules": {
49
+ // "i18n": ["@lingui/core", "i18n"],
50
+ // "trans": ["@lingui/react", "Trans"]
51
+ // }
52
+ },
53
+ ],
54
+ ],
55
+ },
56
+ },
37
57
  }
38
58
  ```
39
59
 
@@ -56,44 +76,8 @@ const nextConfig = {
56
76
  module.exports = nextConfig;
57
77
  ```
58
78
 
59
- ### Tasks
60
- - [x] Essential `t` macro cases:
61
- - [x] ``t`Some string` ``
62
- - [x] ``t`Some ${variable} string` ``
63
- - [x] ``t`Some ${expression} string` ``
64
- - [x] ``t(i18n)`Some string` `` - custom i18n instance
65
- - [x] dedup values object literal when the same variable appears few time, eq avoid `{name, name, count}`
66
- - [x] NON Essential `t` macro cases:
67
- - [x] `t({ message descriptor })` call with message descriptor object
68
- - [x] Passing other macros as arguments for `t()` eq: `t({message: plural(...)})`
69
- - [x] `defineMessage`
70
- - [x] Transform
71
- - [x] Strip non-essential props on production
72
- - [x] JS ICU calls (plural, select, selectOrdinal)
73
- - [x] ``plural(count, {one: '# item', few: '# items'})`` - simple strings
74
- - [x] ``plural(count, {one: `${variable} # item`, few: '# items'})`` - tpls with placeholders
75
- - [x] ``plural(expression(), {one: `${variable} # item`, few: '# items'})`` - expression as parameter
76
- - [x] dedup values object literal when the same variable appears few time, eq avoid `{name, name, count}`
77
- - [x] nesting expressions as described here https://lingui.js.org/ref/macro.html#plural
78
- - [X] Support `offset:1` and exact matches `=1 {...}`
79
- - [x] Support JSX transformation
80
- - [x] `<Trans>`
81
- - [x] Simple cases `<Trans>Hello World</Trans>` -> `<Trans message="Hello World" />`
82
- - [x] Variables interpolation `<Trans>Hello {name} and {getName()}</Trans>` -> `<Trans variables={name, 1: getName()} msg="Hello {name} and {1}"/>`
83
- - [x] Recursive Components interpolation `<Trans>Hello <strong>World!</strong></Trans>`
84
- - [x] Support edge cases `<Trans>{'Hello World'}</Trans>` and ``<Trans>{`How much is ${expression}? ${count}`}</Trans>``
85
- - [x] Normalizing whitespaces
86
- - [x] Stripping non-essential props in production
87
- - [x] ICU: `<Plural>` `<SelectOrdinal>` `<Select>`
88
- - [x] Support `offset:1` and exact matches `=1 {...}`
89
- - [x] Support narrowing transformation to only function exported from `@lingui/macro`
90
- - [x] Automatic adding `import { i18n } from @lingui/core`
91
- - [x] Unicode escaping, validate how SWC produce values
92
- - [x] Support `runtimeConfigModule` settings
93
- - [ ] NON-ESSENTIAL Injecting uniq variables, avoiding collision with existing variables
94
- - [x] NON-ESSENTIAL support renamed macro calls `import {t as macroT} from "@lingui/macro"`
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)
96
- - [x] Building binary and publishing
79
+ > **Note**
80
+ > Consult with full working example for NextJS in the `/examples` folder in this repo.
97
81
 
98
82
  ## License
99
83
 
package/package.json CHANGED
@@ -1,30 +1,35 @@
1
1
  {
2
- "name": "@lingui/swc-plugin",
3
- "version": "0.2.0",
4
- "description": "A SWC Plugin for LinguiJS",
5
- "author": {
6
- "name": "Timofei Iatsenko",
7
- "email": "ty@road.travel"
8
- },
9
- "license": "MIT",
10
- "keywords": [
11
- "swc-plugin",
12
- "swc",
13
- "nextjs",
14
- "lingui",
15
- "lingui-js",
16
- "icu",
17
- "message-format",
18
- "i18n",
19
- "internalization"
20
- ],
21
- "main": "target/wasm32-wasi/release/lingui_macro_plugin.wasm",
22
- "exports": {
23
- ".": "./target/wasm32-wasi/release/lingui_macro_plugin.wasm"
24
- },
25
- "scripts": {
26
- "prepublishOnly": "cargo build-wasi --release"
27
- },
28
- "files": [],
29
- "packageManager": "yarn@3.3.1"
2
+ "name": "@lingui/swc-plugin",
3
+ "version": "0.2.1",
4
+ "description": "A SWC Plugin for LinguiJS",
5
+ "author": {
6
+ "name": "Timofei Iatsenko",
7
+ "email": "ty@road.travel"
8
+ },
9
+ "repository": "lingui/swc-plugin",
10
+ "bugs": "https://github.com/lingui/swc-plugin/issues",
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "swc-plugin",
14
+ "swc",
15
+ "nextjs",
16
+ "lingui",
17
+ "lingui-js",
18
+ "icu",
19
+ "message-format",
20
+ "i18n",
21
+ "internalization"
22
+ ],
23
+ "main": "target/wasm32-wasi/release/lingui_macro_plugin.wasm",
24
+ "exports": {
25
+ ".": "./target/wasm32-wasi/release/lingui_macro_plugin.wasm"
26
+ },
27
+ "scripts": {
28
+ "prepublishOnly": "cargo build-wasi --release"
29
+ },
30
+ "files": [],
31
+ "packageManager": "yarn@3.3.1",
32
+ "peerDependencies": {
33
+ "@lingui/macro": "3 < 4"
34
+ }
30
35
  }