Skip to content

Commit 369a1ab

Browse files
authored
fix(turbopack): remove unpure selector err report & invalid selector err (#71)
1 parent b071a36 commit 369a1ab

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

turbopack/crates/turbopack-css/src/process.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,25 +459,23 @@ async fn process_content(
459459
let mut validator = CssValidator { errors: Vec::new() };
460460
ss.visit(&mut validator).unwrap();
461461

462-
for err in validator.errors {
463-
err.report(source);
464-
}
462+
// TODO: remove pure selector
463+
// for err in validator.errors {
464+
// err.report(source);
465+
// }
465466
}
466467

467468
// We need to collect here because we need to avoid holding the lock while calling
468469
// `.await` in the loop.
469470
let warnings = warnings.read().unwrap().iter().cloned().collect::<Vec<_>>();
470471
for err in warnings.iter() {
471472
match &err.kind {
472-
// Ignore :global pseudo-class errors from preprocessors like LESS
473-
lightningcss::error::ParserError::SelectorError(
474-
lightningcss::error::SelectorError::UnsupportedPseudoClass(name),
475-
) if name.as_ref() == "global" => {
473+
// Ignore all SelectorError errors
474+
lightningcss::error::ParserError::SelectorError(..) => {
476475
continue;
477476
}
478477
lightningcss::error::ParserError::UnexpectedToken(_)
479478
| lightningcss::error::ParserError::UnexpectedImportRule
480-
| lightningcss::error::ParserError::SelectorError(..)
481479
| lightningcss::error::ParserError::EndOfInput => {
482480
let source = match &err.loc {
483481
Some(loc) => {
@@ -541,6 +539,11 @@ async fn process_content(
541539
stylesheet_into_static(&ss, without_warnings(config.clone()))
542540
}
543541
Err(e) => {
542+
// Ignore all SelectorError errors
543+
if matches!(e.kind, lightningcss::error::ParserError::SelectorError(..)) {
544+
return Ok(ParseCssResult::Unparsable.cell());
545+
}
546+
544547
let source = match &e.loc {
545548
Some(loc) => {
546549
let pos = SourcePos {
@@ -597,6 +600,7 @@ enum CssError {
597600
}
598601

599602
impl CssError {
603+
#[allow(unused)]
600604
fn report(self, source: ResolvedVc<Box<dyn Source>>) {
601605
match self {
602606
CssError::CssSelectorInModuleNotPure { selector } => {

0 commit comments

Comments
 (0)