Skip to content

fix(global-css): make generated global element CSS deterministic#6461

Merged
rubencarvalho merged 2 commits into
mainfrom
rubencarvalho/fix-global-css-deterministic-build
Jul 7, 2026
Merged

fix(global-css): make generated global element CSS deterministic#6461
rubencarvalho merged 2 commits into
mainfrom
rubencarvalho/fix-global-css-deterministic-build

Conversation

@rubencarvalho

Copy link
Copy Markdown
Contributor

Description

yarn build reliably left global-action-button.css and global-button.css modified in the working tree, even on a clean checkout.

Root cause: the vite-global-elements-css plugin ran a best-effort stylelint --fix on each generated file purely to reorder properties. That subprocess ignored its exit code and swallowed all errors, so whenever it didn't apply — binary not found, or the process killed under CPU contention during parallel workspace builds — the raw generation order was written instead of the stylelint-ordered version that was checked in. The result was a phantom diff after every build.

Fix: remove the reorder step. Output is now deterministic (generation order), and the two affected files are regenerated to match.

Key decisions

  • Deleted the reorder rather than making it reliable. The 2nd-gen/packages/swc/stylesheets/global directory is already in .stylelintignore, so property order on these DO NOT EDIT, machine-generated files is enforced nowhere. It is also functionally irrelevant: the cascade is unaffected and duplicate declarations are already deduped during generation (mergeRules). The reorder was cosmetic and was the sole source of nondeterminism.
  • Chose this over generating in canonical order. Reproducing stylelint's property order in-process would mean owning a second ordering implementation coupled to stylelint.config.js — real maintenance to satisfy a convention nothing enforces on this directory. The order difference originates only from concatenating the base file's declarations with the component's during merge; both inputs are individually canonical.

Motivation and context

Removes a recurring source of dirty working trees and accidental file churn in unrelated PRs.

Related issue(s)

  • fixes [N/A — internal build-determinism bug]

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature.
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Manual review test cases

  • Build no longer dirties generated global CSS
    1. From a clean checkout on this branch, run yarn build
    2. Run git status
    3. Expect no changes to 2nd-gen/packages/swc/stylesheets/global/*.css

Accessibility testing checklist

  • Keyboard (required)

    • No focusable parts; this changes only build output (CSS property ordering in generated files). No runtime or DOM behavior changes; confirm no regressions in surrounding component examples.
  • Screen reader (required)

    • No role, name, structure, or announcement changes — generated CSS is byte-equivalent in behavior; property order does not affect rendering or the cascade.

@rubencarvalho
rubencarvalho requested a review from a team as a code owner June 30, 2026 13:55
@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b20601d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

📚 Branch Preview Links

🔍 First Generation Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-6461

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@rubencarvalho rubencarvalho added Status:Ready for review PR ready for review or re-review. run_vrt Triggers the Chromatic VRT run for 2nd-gen and removed ready-for-review labels Jun 30, 2026
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 28449794503

Coverage remained the same at 96.246%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 39173
Covered Lines: 37902
Line Coverage: 96.76%
Relevant Branches: 6460
Covered Branches: 6018
Branch Coverage: 93.16%
Branches in Coverage %: Yes
Coverage Strength: 458.86 hits per line

💛 - Coveralls

Remove the best-effort `stylelint --fix` post-process from the
vite-global-elements-css plugin. It reordered properties in the
generated, do-not-edit, .stylelintignore'd global-*.css files but
ignored its exit code and swallowed errors, so when it was skipped
(binary missing, or killed under parallel-build load) the raw output
was written and the checked-in files showed as modified after a build.

Property order on these files is unenforced and functionally irrelevant
(cascade unaffected; duplicate declarations already deduped at
generation), so output is now deterministic = generation order.

Regenerated global-button.css and global-action-button.css to match.
@@ -0,0 +1,7 @@
---
'@adobe/spectrum-wc': patch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You dont need changeset for this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated!

@rubencarvalho
rubencarvalho force-pushed the rubencarvalho/fix-global-css-deterministic-build branch from b8f8e85 to b20601d Compare July 3, 2026 11:26
@rubencarvalho
rubencarvalho requested a review from Rajdeepc July 3, 2026 11:26
@rubencarvalho
rubencarvalho merged commit 3af384b into main Jul 7, 2026
33 checks passed
@rubencarvalho
rubencarvalho deleted the rubencarvalho/fix-global-css-deterministic-build branch July 7, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run_vrt Triggers the Chromatic VRT run for 2nd-gen Status:Ready for review PR ready for review or re-review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants