feat(css/compat): Add Compiler (#6626)

**Description:**

Visitor patterns are inherently slow, so I decided to merge all compatibility passes into a single pass.
This commit is contained in:
Donny/강동윤 2022-12-12 15:27:05 +09:00 committed by GitHub
parent f6cd0dcb5c
commit b3bbd742bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 0 deletions

1
Cargo.lock generated
View File

@ -3372,6 +3372,7 @@ dependencies = [
name = "swc_css_compat"
version = "0.16.0"
dependencies = [
"bitflags",
"once_cell",
"serde",
"serde_json",

View File

@ -13,6 +13,7 @@ version = "0.16.0"
bench = false
[dependencies]
bitflags = "1.3.2"
once_cell = "1.10.0"
serde = {version = "1.0.118", features = ["derive"]}
serde_json = "1.0.61"

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,26 @@
use swc_css_visit::VisitMut;
use crate::feature::Features;
mod custom_media;
/// Compiles a modern CSS file to a CSS file which works with old browsers.
#[derive(Debug)]
pub struct Compiler {
#[allow(unused)]
c: Config,
}
#[derive(Debug)]
pub struct Config {
/// The list of features to **process**.
pub process: Features,
}
impl Compiler {
pub fn new(config: Config) -> Self {
Self { c: config }
}
}
impl VisitMut for Compiler {}

View File

@ -0,0 +1,7 @@
use bitflags::bitflags;
bitflags! {
pub struct Features: u64 {
const NESTING = 0b00000001;
}
}

View File

@ -1,4 +1,6 @@
#![feature(box_patterns)]
#![allow(clippy::vec_box)]
pub mod compiler;
pub mod feature;
pub mod nesting;