Warn instead of fail on exceptions thrown from postcss (#1580)
* postcss was introduced in #1458 for use within adaptCssForReplay * #1600 fixes the main case where invalid css could be introduced when if valid css from the output of `sheet.cssRules` was split according to how it was split across text nodes of the <style> * the guard introduced here is still useful as we likely in future will switch to capturing the raw stylesheet contents (both <style> and <link>), at which point we will be much less confident of getting valid css
This commit is contained in:
committed by
GitHub
parent
a6893f73ab
commit
47a7c3faa6
@@ -62,11 +62,17 @@ export function adaptCssForReplay(cssText: string, cache: BuildCache): string {
|
||||
const cachedStyle = cache?.stylesWithHoverClass.get(cssText);
|
||||
if (cachedStyle) return cachedStyle;
|
||||
|
||||
const ast: { css: string } = postcss([
|
||||
mediaSelectorPlugin,
|
||||
pseudoClassPlugin,
|
||||
]).process(cssText);
|
||||
const result = ast.css;
|
||||
let result = cssText;
|
||||
try {
|
||||
const ast: { css: string } = postcss([
|
||||
mediaSelectorPlugin,
|
||||
pseudoClassPlugin,
|
||||
]).process(cssText);
|
||||
result = ast.css;
|
||||
} catch (error) {
|
||||
console.warn('Failed to adapt css for replay', error);
|
||||
}
|
||||
|
||||
cache?.stylesWithHoverClass.set(cssText, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user