fix: Stop repeating the license header in every compiled stylesheet - #4906
Merged
pan-kot merged 1 commit intoSep 2, 2026
Merged
Conversation
This was referenced Aug 14, 2026
Closed
pan-kot
reviewed
Aug 18, 2026
TrevorBurnham
force-pushed
the
fix-license-headers-in-partials
branch
3 times, most recently
from
August 27, 2026 15:16
70da272 to
5627044
Compare
TrevorBurnham
marked this pull request as ready for review
August 27, 2026 15:19
TrevorBurnham
requested review from
jperals and
pan-kot
and removed request for
a team
August 27, 2026 15:19
pan-kot
previously approved these changes
Aug 27, 2026
TrevorBurnham
force-pushed
the
fix-license-headers-in-partials
branch
from
August 27, 2026 17:03
5627044 to
555ee3e
Compare
jperals
previously approved these changes
Aug 28, 2026
pan-kot
previously approved these changes
Aug 28, 2026
Sass copies loud comments into the compiled CSS, so each partial's header was emitted once per entry point that @uses it. Every published stylesheet carried a median of 34 copies, and 580 KB of the 2304 KB of CSS was the same four lines repeated. Partials now declare the header with Sass line comments, which the compiler strips. Entry points keep the block comment, so every output file still carries one. Stylelint enforces the right form for each via the commentType option from cloudscape-design/build-tools#75. Published CSS drops from 2304 KB to 1743 KB, and the median number of headers per stylesheet from 34 to 1. The 48 files that still carry more than one hit a Sass behaviour that re-emits an entry point's leading comments once per module when the entry and its partials share a dependency, which is tracked in the issue. The compiled CSS is otherwise byte-identical. Generated scoped class names change because the name embeds a content hash and a line number, and the design tokens snapshot changes because tokenStylesSuffix hashes internal/styles/global.scss. Refs cloudscape-design#4905.
auto-merge was automatically disabled
September 1, 2026 14:18
Head branch was pushed to by a user without write access
TrevorBurnham
force-pushed
the
fix-license-headers-in-partials
branch
from
September 1, 2026 14:18
555ee3e to
582c306
Compare
jperals
approved these changes
Sep 2, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4906 +/- ##
==========================================
- Coverage 97.66% 93.75% -3.92%
==========================================
Files 959 958 -1
Lines 31342 27138 -4204
Branches 11577 9345 -2232
==========================================
- Hits 30610 25443 -5167
- Misses 725 790 +65
- Partials 7 905 +898 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 2, 2026
pan-kot
approved these changes
Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4905.
Sass copies loud comments into the compiled CSS, so each partial's license header was emitted once per entry point that
@uses it. Every published stylesheet carried a median of 34 copies, and 580 KB of the 2305 KB of CSS was the same four lines repeated.The 91 partials under
src/now declare the header with Sass line comments, which the compiler strips. Thestyles.scssentry points keep the block comment, so every output file still carries one..stylelintrcenforces the right form for each using thecommentTypeoption added in cloudscape-design/build-tools#75.The gzipped win is small because gzip already deduped the identical blocks. The win is in unminified bytes, which is what dev servers serve and what the internal package ships. Minified production bundles are unaffected either way, since minifiers strip the comments already.
Two things reviewers should know:
1. Every generated scoped class name changes. The name is
awsui_{name}_{fileHash}_{contentHash}_{lineNumber}, and removing comments moves both the content hash and the line numbers. No snapshot needs updating, though: thetest-utilsselectors snapshot truncates to the path-derived hash, and since #4936, keyframe names derive from stable per-keyframe hashes rather than from a hash ofsrc/internal/styles/global.scss, so the design tokens andthemessnapshots no longer move with this change either. The compiled CSS is otherwise identical, verified as described below.2. This does not remove every duplicate. 48 stylesheets still carry more than one header, up to 5. That remainder is a Dart Sass behaviour, not something this repo controls: an entry point's leading comments are re-emitted once per module when the entry point and its partials share a dependency. Minimal repro on Sass 1.89.2, no Cloudscape code involved:
ENTRY HEADERis emitted three times. This is the shape of every Cloudscape component that has sub-partials, which is whypopoverstill ends up with several headers rather than one. It accounts for roughly 6 KB and is worth a follow-up upstream; it does not block this change.The other source named in #4905,
@cloudscape-design/component-toolkit, is already resolved: cloudscape-design/component-toolkit#248 converted its two SCSS files and shipped in1.0.0-beta.182, which this branch builds against. That is why the median here reaches 1 rather than 2.How has this been tested?
A normalised comparison of all 229 compiled stylesheets against a build of
mainfrom the samenode_modules. After neutralising license blocks and thecontentHash/lineNumbersegments of scoped names, all 229 stylesheets are byte-identical. No file was added, removed, or left empty.Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.