From 8f781b46624acdb6909d9389ebd72a0f3955665a Mon Sep 17 00:00:00 2001 From: gretzkiy Date: Sat, 23 Nov 2024 13:54:29 +0300 Subject: [PATCH] chore(prelude/webpack): enhance error logging --- CHANGELOG.md | 6 ++++++ src/core/prelude/CHANGELOG.md | 6 ++++++ src/core/prelude/webpack.ts | 18 ++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cf6ba4886..2366f07d09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ Changelog _Note: Gaps between patch versions are faulty, broken or test releases._ +## v4.0.0-beta.148 (2024-11-23) + +#### :house: Internal + +* Added error details to the logging when checking the stylesheet loading status + ## v4.0.0-beta.147 (2024-10-25) #### :bug: Bug Fix diff --git a/src/core/prelude/CHANGELOG.md b/src/core/prelude/CHANGELOG.md index 2d69fc8d67..ac39d7088c 100644 --- a/src/core/prelude/CHANGELOG.md +++ b/src/core/prelude/CHANGELOG.md @@ -9,6 +9,12 @@ Changelog > - :house: [Internal] > - :nail_care: [Polish] +## v4.0.0-beta.148 (2024-11-23) + +#### :house: Internal + +* Added error details to the logging when checking the stylesheet loading status + ## v4.0.0-beta.134 (2024-09-16) #### :house: Internal diff --git a/src/core/prelude/webpack.ts b/src/core/prelude/webpack.ts index 04dc8fa77c..513b8926b7 100644 --- a/src/core/prelude/webpack.ts +++ b/src/core/prelude/webpack.ts @@ -40,9 +40,20 @@ function __webpack_component_styles_are_loaded__(componentName: string): boolean const {styleSheets} = document; for (let i = 0; i < styleSheets.length; i++) { - const rules = styleSheets[i].cssRules; + const styleSheet = styleSheets[i]; - if (rules[loadedStylesIndexed] === true) { + if (styleSheet[loadedStylesIndexed] === true) { + continue; + } + + let rules: CSSRuleList; + + try { + rules = styleSheet.cssRules; + + } catch (err) { + stderr(err, {styleSheetHref: styleSheet.href}); + styleSheet[loadedStylesIndexed] = true; continue; } @@ -53,10 +64,9 @@ function __webpack_component_styles_are_loaded__(componentName: string): boolean const component = selector.slice(1, -'-is-style-loaded'.length); loadedStyles.add(component); } - } - rules[loadedStylesIndexed] = true; + styleSheet[loadedStylesIndexed] = true; } return loadedStyles.has(componentName);