Skip to content

Commit

Permalink
feat(css): remove the builtin autoprefixer ability (#3874)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf0 authored and hardfist committed Aug 15, 2023
1 parent 7cf0c2c commit 006599d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 28 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion crates/rspack_plugin_css/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ bitflags = { workspace = true }
heck = "0.4.1"
indexmap = { workspace = true }
once_cell = { workspace = true }
preset_env_base = { workspace = true }
rayon = { workspace = true }
regex = { workspace = true }
rspack_core = { path = "../rspack_core" }
Expand Down
27 changes: 1 addition & 26 deletions crates/rspack_plugin_css/src/parser_and_generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use indexmap::IndexMap;
use once_cell::sync::Lazy;
use preset_env_base::query::{Query, Targets};
use regex::Regex;
use rspack_core::{
rspack_sources::{
Expand All @@ -17,12 +16,7 @@ use rspack_error::{internal_error, IntoTWithDiagnosticArray, Result, TWithDiagno
use rustc_hash::FxHashSet;
use sugar_path::SugarPath;
use swc_core::{
css::{
modules::CssClassName,
parser::parser::ParserConfig,
prefixer::{options::Options, prefixer},
visit::VisitMutWith,
},
css::{modules::CssClassName, parser::parser::ParserConfig},
ecma::atoms::JsWord,
};

Expand All @@ -47,19 +41,6 @@ pub struct CssParserAndGenerator {
pub exports: Option<IndexMap<JsWord, Vec<CssClassName>>>,
}

impl CssParserAndGenerator {
pub fn get_query(&self) -> Option<Query> {
// TODO(h-a-n-a): figure out if the prefixer visitMut is stateless
// I need to clone the preset_env every time, due to I don't know if it is stateless
// If it is true, I reduce this clone
if !self.config.targets.is_empty() {
Some(Query::Multiple(self.config.targets.clone()))
} else {
None
}
}
}

impl ParserAndGenerator for CssParserAndGenerator {
fn source_types(&self) -> &[SourceType] {
if self.config.modules.exports_only {
Expand Down Expand Up @@ -121,12 +102,6 @@ impl ParserAndGenerator for CssParserAndGenerator {
},
)?;

if let Some(query) = self.get_query() {
stylesheet.visit_mut_with(&mut prefixer(Options {
env: Some(Targets::Query(query)),
}));
}

let locals = if is_enable_css_modules {
let result = swc_core::css::modules::compile(
&mut stylesheet,
Expand Down

0 comments on commit 006599d

Please # to comment.