Skip to content

Commit

Permalink
Create a reusable lightningcss-napi crate
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Feb 23, 2024
1 parent 4eaed5c commit db5a8ed
Show file tree
Hide file tree
Showing 9 changed files with 1,258 additions and 1,201 deletions.
46 changes: 27 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
@@ -1,6 +1,7 @@
[workspace]
members = [
"node",
"napi",
"selectors",
"c",
"derive",
Expand Down
25 changes: 25 additions & 0 deletions napi/Cargo.toml
@@ -0,0 +1,25 @@
[package]
authors = ["Devon Govett <devongovett@gmail.com>"]
name = "lightningcss-napi"
version = "0.1.0"
description = "Node-API bindings for Lightning CSS"
license = "MPL-2.0"
repository = "https://github.com/parcel-bundler/lightningcss"
edition = "2021"

[features]
default = []
visitor = ["lightningcss/visitor"]
bundler = ["dep:crossbeam-channel", "dep:rayon"]

[dependencies]
serde = { version = "1.0.123", features = ["derive"] }
serde_bytes = "0.11.5"
cssparser = "0.33.0"
lightningcss = { path = "../", features = ["nodejs", "serde"] }
parcel_sourcemap = { version = "2.1.1", features = ["json"] }
serde-detach = "0.0.1"
smallvec = { version = "1.7.0", features = ["union"] }
napi = {version = "=2.10.3", default-features = false, features = ["napi4", "napi5", "compat-mode", "serde-json"]}
crossbeam-channel = { version = "0.5.6", optional = true }
rayon = { version = "1.5.1", optional = true }
5 changes: 4 additions & 1 deletion node/src/at_rule_parser.rs → napi/src/at_rule_parser.rs
Expand Up @@ -11,7 +11,6 @@ use lightningcss::{
string::CowArcStr,
syntax::{ParsedComponent, SyntaxString},
},
visitor::{Visit, VisitTypes, Visitor},
};
use serde::{Deserialize, Deserializer, Serialize};

Expand Down Expand Up @@ -198,6 +197,10 @@ impl<'i> ToCss for AtRule<'i> {
}
}

#[cfg(feature = "visitor")]
use lightningcss::visitor::{Visit, VisitTypes, Visitor};

#[cfg(feature = "visitor")]
impl<'i, V: Visitor<'i, AtRule<'i>>> Visit<'i, AtRule<'i>, V> for AtRule<'i> {
const CHILD_TYPES: VisitTypes = VisitTypes::empty();

Expand Down

0 comments on commit db5a8ed

Please sign in to comment.