Skip to content

Commit ecbaf83

Browse files
authored
feat: legacy api (#3)
* update * feat: impl done * chore: feature legacy * test: update * fix: importer_is_sharp_2 * test: add more test and fix bugs * test: finish legacy importer tests
1 parent 5689585 commit ecbaf83

File tree

15 files changed

+5187
-1496
lines changed

15 files changed

+5187
-1496
lines changed

Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@
22
name = "sass-embedded-host-rust"
33
version = "0.1.0"
44
edition = "2021"
5+
resolver = "2"
6+
7+
[features]
8+
legacy = ["dep:regex", "dep:serde_json"]
59

610
[dependencies]
7-
prost = "0.10"
11+
prost = "0.11"
812
url = "2"
913
atty = "0.2"
1014
parking_lot = "0.12"
1115
dashmap = "5"
1216
crossbeam-channel = "0.5"
1317
rustc-hash = "1"
18+
regex = { version = "1", optional = true }
19+
serde_json = { version = "1", optional = true }
1420

1521
[dev-dependencies]
1622
serde_json = "1"
1723
tempfile = "3"
1824

1925
[build-dependencies]
20-
prost-build = "0.10"
26+
prost-build = "0.11"

examples/bootstrap5/main.rs

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::time;
22

3+
#[cfg(feature = "legacy")]
4+
use sass_embedded_host_rust::legacy::LegacyOptionsBuilder;
35
use sass_embedded_host_rust::{Options, Sass};
46

57
fn exe_path() -> std::path::PathBuf {
@@ -19,7 +21,6 @@ fn main() {
1921
let bootstrap_grid = path.join("bootstrap-grid.scss");
2022
let bootstrap_reboot = path.join("bootstrap-reboot.scss");
2123
let bootstrap_utilities = path.join("bootstrap-utilities.scss");
22-
let now = time::Instant::now();
2324
let mut sass = Sass::new(exe_path());
2425
let _ = sass
2526
.compile(bootstrap.to_string_lossy(), Options::default())
@@ -33,5 +34,53 @@ fn main() {
3334
let _ = sass
3435
.compile(bootstrap_utilities.to_string_lossy(), Options::default())
3536
.unwrap();
36-
dbg!(now.elapsed());
37+
38+
let now = time::Instant::now();
39+
let _ = sass
40+
.compile(bootstrap.to_string_lossy(), Options::default())
41+
.unwrap();
42+
let _ = sass
43+
.compile(bootstrap_grid.to_string_lossy(), Options::default())
44+
.unwrap();
45+
let _ = sass
46+
.compile(bootstrap_reboot.to_string_lossy(), Options::default())
47+
.unwrap();
48+
let _ = sass
49+
.compile(bootstrap_utilities.to_string_lossy(), Options::default())
50+
.unwrap();
51+
println!("modern: {:?}", now.elapsed());
52+
53+
#[cfg(feature = "legacy")]
54+
{
55+
let now = time::Instant::now();
56+
let _ = sass
57+
.render(
58+
LegacyOptionsBuilder::default()
59+
.file(bootstrap.to_string_lossy())
60+
.build(),
61+
)
62+
.unwrap();
63+
let _ = sass
64+
.render(
65+
LegacyOptionsBuilder::default()
66+
.file(bootstrap_grid.to_string_lossy())
67+
.build(),
68+
)
69+
.unwrap();
70+
let _ = sass
71+
.render(
72+
LegacyOptionsBuilder::default()
73+
.file(bootstrap_reboot.to_string_lossy())
74+
.build(),
75+
)
76+
.unwrap();
77+
let _ = sass
78+
.render(
79+
LegacyOptionsBuilder::default()
80+
.file(bootstrap_utilities.to_string_lossy())
81+
.build(),
82+
)
83+
.unwrap();
84+
println!("legacy: {:?}", now.elapsed());
85+
}
3786
}

0 commit comments

Comments
 (0)