@@ -8,6 +8,7 @@ use cow_utils::CowUtils;
88use derive_more:: Debug ;
99pub use lightningcss;
1010use lightningcss:: {
11+ error:: { ParserError , SelectorError } ,
1112 printer:: { PrinterOptions , PseudoClasses } ,
1213 stylesheet:: { MinifyOptions , ParserFlags , ParserOptions , StyleSheet } ,
1314 targets:: { Features , Targets } ,
@@ -21,7 +22,7 @@ use rspack_core::{
2122 SourceMapSourceOptions , encode_mappings,
2223 } ,
2324} ;
24- use rspack_error:: { Result , ToStringResultToRspackResultExt } ;
25+ use rspack_error:: { Diagnostic , Result , ToStringResultToRspackResultExt } ;
2526use rspack_loader_runner:: Identifier ;
2627use tokio:: sync:: Mutex ;
2728
@@ -99,31 +100,25 @@ impl LightningCssLoader {
99100 flags : parser_flags,
100101 } ;
101102 let stylesheet = StyleSheet :: parse ( & content_str, option. clone ( ) ) . to_rspack_result ( ) ?;
102- // FIXME: Disable the warnings for now, cause it cause too much positive-negative warnings,
103- // enable when we have a better way to handle it.
104-
105- // if let Some(warnings) = warnings {
106- // #[allow(clippy::unwrap_used)]
107- // let warnings = warnings.read().unwrap();
108- // for warning in warnings.iter() {
109- // if matches!(
110- // warning.kind,
111- // lightningcss::error::ParserError::SelectorError(
112- // lightningcss::error::SelectorError::UnsupportedPseudoClass(_)
113- // ) | lightningcss::error::ParserError::SelectorError(
114- // lightningcss::error::SelectorError::UnsupportedPseudoElement(_)
115- // )
116- // ) {
117- // // ignore parsing errors on pseudo class from lightningcss-loader
118- // // to allow pseudo class in CSS modules and Vue.
119- // continue;
120- // }
121- // loader_context.emit_diagnostic(Diagnostic::warn(
122- // "builtin:lightningcss-loader".to_string(),
123- // format!("LightningCSS parse warning: {}", warning),
124- // ));
125- // }
126- // }
103+ if let Some ( warnings) = warnings {
104+ #[ allow( clippy:: unwrap_used) ]
105+ let warnings = warnings. read ( ) . unwrap ( ) ;
106+ for warning in warnings. iter ( ) {
107+ if matches ! (
108+ warning. kind,
109+ ParserError :: SelectorError (
110+ SelectorError :: UnsupportedPseudoClass ( _) | SelectorError :: UnsupportedPseudoElement ( _)
111+ )
112+ ) {
113+ // Keep CSS modules and framework pseudo selectors usable.
114+ continue ;
115+ }
116+ loader_context. emit_diagnostic ( Diagnostic :: warn (
117+ "builtin:lightningcss-loader" . to_string ( ) ,
118+ format ! ( "LightningCSS parse warning: {warning}" ) ,
119+ ) ) ;
120+ }
121+ }
127122
128123 let mut stylesheet = to_static (
129124 stylesheet,
0 commit comments