mirror of
https://github.com/swc-project/swc.git
synced 2024-11-28 02:29:04 +03:00
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:
parent
f6cd0dcb5c
commit
b3bbd742bf
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3372,6 +3372,7 @@ dependencies = [
|
||||
name = "swc_css_compat"
|
||||
version = "0.16.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -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"
|
||||
|
1
crates/swc_css_compat/src/compiler/custom_media.rs
Normal file
1
crates/swc_css_compat/src/compiler/custom_media.rs
Normal file
@ -0,0 +1 @@
|
||||
|
26
crates/swc_css_compat/src/compiler/mod.rs
Normal file
26
crates/swc_css_compat/src/compiler/mod.rs
Normal 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 {}
|
7
crates/swc_css_compat/src/feature.rs
Normal file
7
crates/swc_css_compat/src/feature.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use bitflags::bitflags;
|
||||
|
||||
bitflags! {
|
||||
pub struct Features: u64 {
|
||||
const NESTING = 0b00000001;
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
#![feature(box_patterns)]
|
||||
#![allow(clippy::vec_box)]
|
||||
|
||||
pub mod compiler;
|
||||
pub mod feature;
|
||||
pub mod nesting;
|
||||
|
Loading…
Reference in New Issue
Block a user