Skip to content

Commit 4f882f2

Browse files
feat: Bump scw_core to the 15.0.1, update readme (#149)
1 parent d42b844 commit 4f882f2

File tree

8 files changed

+59
-54
lines changed

8 files changed

+59
-54
lines changed

Cargo.lock

Lines changed: 41 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lingui_macro_plugin"
3-
version = "5.4.0"
3+
version = "5.5.0"
44
edition = "2021"
55

66
[lib]
@@ -22,7 +22,7 @@ serde = "1.0.207"
2222
serde_json = "1.0.125"
2323
regex = "1.10.6"
2424
once_cell = "1.19.0"
25-
swc_core = { version = "14.1.0", features = [
25+
swc_core = { version = "15.0.1", features = [
2626
"ecma_plugin_transform",
2727
"ecma_utils",
2828
"ecma_visit",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Below is a table referencing the swc_core version used during the plugin build,
106106
| `4.1.0`, `5.0.0` ~ `5.2.0` | [`0.106.3`](https://plugins.swc.rs/versions/range/95) |
107107
| `5.3.0` | [`5.0.4`](https://plugins.swc.rs/versions/range/116) |
108108
| `5.4.0` | [`14.1.0`](https://plugins.swc.rs/versions/range/138) |
109+
| `5.5.0` | [`15.0.1`](https://plugins.swc.rs/versions/range/271) |
109110

110111

111112
> **Note**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lingui/swc-plugin",
3-
"version": "5.4.0",
3+
"version": "5.5.0",
44
"description": "A SWC Plugin for LinguiJS",
55
"author": {
66
"name": "Timofei Iatsenko",

src/ast_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashSet;
22
use swc_core::common::DUMMY_SP;
33
use swc_core::ecma::ast::*;
4-
use swc_core::ecma::atoms::JsWord;
4+
use swc_core::ecma::atoms::Atom;
55
use swc_core::ecma::utils::quote_ident;
66

77
pub fn get_jsx_attr<'a>(el: &'a JSXOpeningElement, name: &str) -> Option<&'a JSXAttr> {
@@ -151,7 +151,7 @@ pub fn get_object_prop<'a>(props: &'a Vec<PropOrSpread>, name: &str) -> Option<&
151151
})
152152
}
153153

154-
pub fn get_prop_key(prop: &KeyValueProp) -> Option<&JsWord> {
154+
pub fn get_prop_key(prop: &KeyValueProp) -> Option<&Atom> {
155155
match &prop.key {
156156
PropName::Ident(IdentName { sym, .. }) | PropName::Str(Str { value: sym, .. }) => Some(sym),
157157
_ => None,
@@ -176,7 +176,7 @@ pub fn create_key_value_prop(key: &str, value: Box<Expr>) -> PropOrSpread {
176176
})));
177177
}
178178

179-
pub fn create_import(source: JsWord, imported: IdentName, local: IdentName) -> ModuleItem {
179+
pub fn create_import(source: Atom, imported: IdentName, local: IdentName) -> ModuleItem {
180180
ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl {
181181
span: DUMMY_SP,
182182
phase: ImportPhase::default(),

src/jsx_visitor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use once_cell::sync::Lazy;
55
use regex::Regex;
66
use swc_core::common::DUMMY_SP;
77
use swc_core::ecma::ast::*;
8-
use swc_core::ecma::atoms::JsWord;
8+
use swc_core::ecma::atoms::Atom;
99
use swc_core::ecma::visit::{Visit, VisitWith};
1010
use swc_core::plugin::errors::HANDLER;
1111

@@ -77,7 +77,7 @@ fn clean_jsx_element_literal_child(value: &str) -> String {
7777
result
7878
}
7979

80-
fn is_allowed_plural_option(key: &str) -> Option<JsWord> {
80+
fn is_allowed_plural_option(key: &str) -> Option<Atom> {
8181
if PLURAL_OPTIONS_WHITELIST.is_match(key) {
8282
let key = NUM_OPTION.replace(key, "=$1");
8383
let key = WORD_OPTION.replace(&key, "$1");

src/macro_utils.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ use crate::tokens::*;
33
use crate::LinguiOptions;
44
use std::collections::{HashMap, HashSet};
55
use swc_core::ecma::utils::quote_ident;
6-
use swc_core::ecma::{ast::*, atoms::JsWord};
6+
use swc_core::ecma::{ast::*, atoms::Atom};
77

88
const LINGUI_T: &str = &"t";
99

1010
#[derive(Default, Clone)]
1111
pub struct MacroCtx {
1212
// export name -> local name
13-
symbol_to_id_map: HashMap<JsWord, HashSet<Id>>,
13+
symbol_to_id_map: HashMap<Atom, HashSet<Id>>,
1414
// local name -> export name
15-
id_to_symbol_map: HashMap<Id, JsWord>,
15+
id_to_symbol_map: HashMap<Id, Atom>,
1616

1717
pub should_add_18n_import: bool,
1818
pub should_add_trans_import: bool,
@@ -74,7 +74,7 @@ impl MacroCtx {
7474

7575
/// given import {plural as i18nPlural} from "@lingui/macro";
7676
/// get_ident_export_name("i18nPlural") would return `plural`
77-
pub fn get_ident_export_name(&self, ident: &Ident) -> Option<&JsWord> {
77+
pub fn get_ident_export_name(&self, ident: &Ident) -> Option<&Atom> {
7878
if let Some(name) = self.id_to_symbol_map.get(&ident.to_id()) {
7979
return Some(name);
8080
}
@@ -88,7 +88,7 @@ impl MacroCtx {
8888
|| self.is_lingui_ident("SelectOrdinal", ident)
8989
}
9090

91-
pub fn register_reference(&mut self, symbol: &JsWord, id: &Id) {
91+
pub fn register_reference(&mut self, symbol: &Atom, id: &Id) {
9292
self.symbol_to_id_map
9393
.entry(symbol.clone())
9494
.or_default()
@@ -228,7 +228,7 @@ impl MacroCtx {
228228

229229
/// Take KeyValueProp and return Key as string if parsable
230230
/// If key is numeric, return an exact match syntax `={number}`
231-
pub fn get_js_choice_case_key(&self, prop: &KeyValueProp) -> Option<JsWord> {
231+
pub fn get_js_choice_case_key(&self, prop: &KeyValueProp) -> Option<Atom> {
232232
match &prop.key {
233233
// {one: ""}
234234
PropName::Ident(IdentName { sym, .. })

src/tokens.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use swc_core::ecma::ast::{Expr, JSXOpeningElement};
2-
use swc_core::ecma::atoms::JsWord;
2+
use swc_core::ecma::atoms::Atom;
33

44
pub enum MsgToken {
55
String(String),
@@ -17,7 +17,7 @@ pub struct TagOpening {
1717
pub struct IcuChoice {
1818
pub value: Box<Expr>,
1919
/// plural | select | selectOrdinal
20-
pub format: JsWord,
20+
pub format: Atom,
2121
pub cases: Vec<CaseOrOffset>,
2222
}
2323

@@ -26,7 +26,7 @@ pub enum CaseOrOffset {
2626
Offset(String),
2727
}
2828
pub struct ChoiceCase {
29-
pub key: JsWord,
29+
pub key: Atom,
3030
pub tokens: Vec<MsgToken>,
3131
}
3232

0 commit comments

Comments
 (0)