Skip to content

Commit

Permalink
chore(prelude/webpack): enhance error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
gretzkiy committed Nov 26, 2024
1 parent fe59f3f commit e2bb39d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Changelog
_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-beta.158 (2024-11-26)

#### :house: Internal

* Added error details to the logging when checking the stylesheet loading status

## v4.0.0-beta.157 (2024-11-25)

#### :bug: Bug Fix
Expand Down
6 changes: 6 additions & 0 deletions src/core/prelude/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Changelog
> - :house: [Internal]
> - :nail_care: [Polish]
## v4.0.0-beta.158 (2024-11-26)

#### :house: Internal

* Added error details to the logging when checking the stylesheet loading status

## v4.0.0-beta.134 (2024-09-16)

#### :house: Internal
Expand Down
18 changes: 14 additions & 4 deletions src/core/prelude/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down

0 comments on commit e2bb39d

Please sign in to comment.