Skip to content

Conversation

@just-boris
Copy link
Member

@just-boris just-boris commented Jun 19, 2025

Description

Added check for this old issue: AWSUI-55709

Since releasing VR only artifacts, a few more teams reported the same. Let's add a check to monitor this.

Related links, issue #, if available: n/a

How has this been tested?

  • Added a unit test
  • Checked the dev pages locally to ensure no false alarms
  • Deployed to my dev pipeline, reproduced missing styles via Devtools' request blocking
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@just-boris just-boris force-pushed the detect-missing-styles branch 2 times, most recently from 03f6b14 to e6aefe1 Compare June 19, 2025 11:39
`${workspace.targetPath}/**`,
`${workspace.staticSitePath}/**`,
`${workspace.generatedTestUtils}/**`,
`${workspace.generatedPath}/custom-css-properties/**`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workspace.generatedPath contains other non-generated files: https://github.com/cloudscape-design/components/tree/main/src/internal/generated

Ideally we should clean up them all (or move to a different path), but not in this PR

@use '../generated/custom-css-properties' as custom-styles;

:root {
--awsui-version-info-#{custom-styles.$awsui-commit-hash}: true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core of this check. We check presence of this CSS var in Javascript. If not found – the styles are missing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if an app doesn't bundle and server styles but another app on the same page has a similar git commit. it wouldn't be detected.

but I guess this is acceptable, and better than what we have now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is a chance of missing some cases, if they happen to have the same commit

import { PACKAGE_SOURCE, PACKAGE_VERSION, THEME } from './environment';

export const metrics = new Metrics(PACKAGE_SOURCE, PACKAGE_VERSION);
export const metrics = new Metrics({ packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme: THEME });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing this follow-up cloudscape-design/component-toolkit#136 (comment)

Yes I know this THEME value does not support vr, but it is fine for this use-case

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain a bit more?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before it was like this

const metrics = new Metrics(PACKAGE_SOURCE, PACKAGE_VERSION);
metrics.initMetrics(theme);

This is not safe, because it metrics.initMetrics(theme) sets theme as a global variable inside @cloudscape-design/component-toolkit package

Multiple packages may call the same toolkit instance and the same metrics.initMetrics(theme) will overwrite each other theme.

So, now we finally got the theme properly scoped to each bundle

@codecov
Copy link

codecov bot commented Jun 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.59%. Comparing base (1ac1315) to head (5236ace).
Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3591   +/-   ##
=======================================
  Coverage   96.59%   96.59%           
=======================================
  Files         806      807    +1     
  Lines       23500    23530   +30     
  Branches     8211     8216    +5     
=======================================
+ Hits        22699    22729   +30     
  Misses        794      794           
  Partials        7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@just-boris just-boris force-pushed the detect-missing-styles branch from e6aefe1 to 89568bb Compare June 19, 2025 11:58
}
}

export function idleWithDelay(cb: () => void) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exported checkMissingStyles and idleWithDelay as separate functions to allow write simpler unit tests on each part of the functionality

// Custom Property
if (prop.startsWith('--')) {
const valueWithoutPostfix = prop.substring(2, prop.length - 7);
const valueWithoutPostfix = prop.replace(/^--/, '').replace(/-[\d\w]+$/, '');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code assumed the hash is always 7 characters, which is not true

@just-boris just-boris force-pushed the detect-missing-styles branch from 97c9d30 to 5236ace Compare June 19, 2025 14:12
@just-boris just-boris marked this pull request as ready for review June 19, 2025 14:42
@just-boris just-boris requested a review from a team as a code owner June 19, 2025 14:42
@just-boris just-boris requested review from a team, abdhalees and georgylobko and removed request for a team and georgylobko June 19, 2025 14:42
@just-boris just-boris added this pull request to the merge queue Jun 20, 2025
Merged via the queue into main with commit fd8eb3d Jun 20, 2025
40 checks passed
@just-boris just-boris deleted the detect-missing-styles branch June 20, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants