Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split macro crate into parser and macro #145

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ jobs:
run: cargo test-all-features

macros_test:
# Why not also use cargo-all-features with the macros package ?
# Why not also use cargo-all-features with the parser and macros packages ?
# Because all features are forwarded from leptos_i18n,
# so if some features mix creates a problem they will appear in leptos_i18n tests.
# All leptos_i18n_macro tests don't require any feature flag, so no need to test each feature and matchup
# just run once with default, this speeds up CI
name: Test leptos_i18n_macro package
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
packages: [leptos_i18n_macro, leptos_i18n_parser]
steps:
- name: "Checkout repo"
uses: actions/checkout@v4
Expand All @@ -45,7 +49,7 @@ jobs:
uses: dtolnay/rust-toolchain@stable

- name: "Run tests"
run: cargo test --package leptos_i18n_macro
run: cargo test --package ${{ matrix.packages }}

test_ssr_examples:
name: Test ${{ matrix.examples }} SSR example
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resolver = "2"
members = [
"leptos_i18n",
"leptos_i18n_macro",
"leptos_i18n_parser",
"tests/json",
"tests/common",
"tests/namespaces",
Expand All @@ -14,6 +15,7 @@ version = "0.5.0-gamma"

[workspace.dependencies]
leptos_i18n_macro = { path = "./leptos_i18n_macro", default-features = false, version = "0.5.0-gamma" }
leptos_i18n_parser = { path = "./leptos_i18n_parser", default-features = false, version = "0.5.0-gamma" }
leptos_i18n = { path = "./leptos_i18n", version = "0.5.0-gamma" }
tests_common = { path = "./tests/common", version = "0.1.0" }
leptos = { version = "0.7.0-gamma2" }
15 changes: 8 additions & 7 deletions leptos_i18n_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ toml = "0.8"
icu = "1.5"
fixed_decimal = { version = "0.5", features = ["ryu"] }
json5 = { version = "0.4", optional = true }
leptos_i18n_parser = { workspace = true, features = ["quote"] }

[features]
default = ["json_files"]
nightly = []
suppress_key_warnings = []
json_files = []
yaml_files = ["dep:serde_yaml"]
json5_files = ["dep:json5"]
json_files = ["leptos_i18n_parser/json_files"]
yaml_files = ["dep:serde_yaml", "leptos_i18n_parser/yaml_files"]
json5_files = ["dep:json5", "leptos_i18n_parser/json5_files"]
interpolate_display = []
track_locale_files = []
experimental-islands = []
Expand All @@ -40,10 +41,10 @@ dynamic_load = []
hydrate = []
csr = []
ssr = []
plurals = []
format_datetime = []
format_list = []
format_nums = []
plurals = ["leptos_i18n_parser/plurals"]
format_datetime = ["leptos_i18n_parser/format_datetime"]
format_list = ["leptos_i18n_parser/format_list"]
format_nums = ["leptos_i18n_parser/format_nums"]
icu_compiled_data = []

[package.metadata.cargo-all-features]
Expand Down
5 changes: 4 additions & 1 deletion leptos_i18n_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ use t_macro::{InputType, OutputType};
pub fn load_locales(_tokens: proc_macro::TokenStream) -> proc_macro::TokenStream {
match load_locales::load_locales() {
Ok(ts) => ts.into(),
Err(err) => err.into(),
Err(err) => {
let err = err.to_string();
quote::quote!(compile_error!(#err);).into()
}
}
}

Expand Down
Loading