Repository: vercel/next.js
Pull request: Turbopack: treat unknown CSS selectors as warnings

In many cases, these are just modern selectors that aren't supported yet.

Changed files:
filename: turbopack/crates/turbopack-css/src/process.rs
patch: @@ -3,6 +3,7 @@ use std::sync::{Arc, RwLock};
 use anyhow::{Result, bail};
 use lightningcss::{
     css_modules::{CssModuleExport, Pattern, Segment},
+    error::SelectorError,
     stylesheet::{MinifyOptions, ParserOptions, PrinterOptions, StyleSheet, ToCssResult},
     targets::{BrowserslistConfig, Features, Targets},
     traits::ToCss,
@@ -23,8 +24,8 @@ use turbopack_core::{
     chunk::{ChunkingContext, MinifyType},
     environment::Environment,
     issue::{
-        AdditionalIssueSources, Issue, IssueExt, IssueSource, IssueStage, OptionIssueSource,
-        OptionStyledString, StyledString,
+        AdditionalIssueSources, Issue, IssueExt, IssueSeverity, IssueSource, IssueStage,
+        OptionIssueSource, OptionStyledString, StyledString,
     },
     reference::ModuleReferences,
     reference_type::ImportContext,
@@ -505,10 +506,23 @@ async fn process_content(
                                 None => IssueSource::from_source_only(source),
                             };
 
+                            let severity = match &err.kind {
+                                lightningcss::error::ParserError::SelectorError(
+                                    SelectorError::UnsupportedPseudoClass(_)
+                                    | SelectorError::UnsupportedPseudoElement(_),
+                                ) => {
+                                    // In most cases, these are new selectors not yet
+                                    // implemented in LightningCSS.
+                                    IssueSeverity::Warning
+                                }
+                                _ => IssueSeverity::Error,
+                            };
+
                             ParsingIssue {
                                 msg: err.kind.to_string().into(),
                                 stage: IssueStage::Parse,
                                 source: issue_source,
+                                severity,
                             }
                             .resolved_cell()
                             .emit();
@@ -550,6 +564,7 @@ async fn process_content(
                         msg: e.kind.to_string().into(),
                         stage: IssueStage::Transform,
                         source: issue_source,
+                        severity: IssueSeverity::Error,
                     }
                     .resolved_cell()
                     .emit();
@@ -589,6 +604,7 @@ async fn process_content(
                     msg: e.kind.to_string().into(),
                     stage: IssueStage::Parse,
                     source: issue_source,
+                    severity: IssueSeverity::Error,
                 }
                 .resolved_cell()
                 .emit();
@@ -643,6 +659,7 @@ impl CssError {
                     stage: IssueStage::Transform,
                     // TODO: This should include the location of the selector in the file.
                     source: IssueSource::from_source_only(source),
+                    severity: IssueSeverity::Error,
                 }
                 .resolved_cell()
                 .emit();
@@ -742,10 +759,15 @@ struct ParsingIssue {
     msg: RcStr,
     stage: IssueStage,
     source: IssueSource,
+    severity: IssueSeverity,
 }
 
 #[turbo_tasks::value_impl]
 impl Issue for ParsingIssue {
+    fn severity(&self) -> IssueSeverity {
+        self.severity
+    }
+
     #[turbo_tasks::function]
     fn file_path(&self) -> Vc<FileSystemPath> {
         self.source.file_path()

filename: turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/issues/Parsing CSS source code failed-0827e0.txt
patch: @@ -1,4 +1,4 @@
-error - [parse] /turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/input/style.css:25:14  Parsing CSS source code failed
+warning - [parse] /turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/input/style.css:25:14  Parsing CSS source code failed
       21 | .carousel > *::scroll-marker {
       22 |   content: "";
       23 | }

filename: turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/issues/Parsing CSS source code failed-18c92d.txt
patch: @@ -1,4 +1,4 @@
-error - [parse] /turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/input/style.css:13:12  Parsing CSS source code failed
+warning - [parse] /turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/input/style.css:13:12  Parsing CSS source code failed
        9 | .after {
       10 |   color: green;
       11 | }

filename: turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/issues/Parsing CSS source code failed-9d560b.txt
patch: @@ -1,4 +1,4 @@
-error - [parse] /turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/input/style.css:25:29  Parsing CSS source code failed
+warning - [parse] /turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/input/style.css:25:29  Parsing CSS source code failed
       21 | .carousel > *::scroll-marker {
       22 |   content: "";
       23 | }

filename: turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/issues/Parsing CSS source code failed-fefb8d.txt
patch: @@ -1,4 +1,4 @@
-error - [parse] /turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/input/style.css:21:14  Parsing CSS source code failed
+warning - [parse] /turbopack/crates/turbopack-tests/tests/snapshot/css/css-parse-error/input/style.css:21:14  Parsing CSS source code failed
       17 | .carousel {
       18 |   scroll-marker-group: after;
       19 | }