fix: Stop repeating the license header in every compiled stylesheet - #4906
Open
TrevorBurnham wants to merge 1 commit into
Open
fix: Stop repeating the license header in every compiled stylesheet#4906TrevorBurnham wants to merge 1 commit into
TrevorBurnham wants to merge 1 commit into
Conversation
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
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.
TrevorBurnham
force-pushed
the
fix-license-headers-in-partials
branch
from
August 27, 2026 17:03
5627044 to
555ee3e
Compare
jperals
approved these changes
Aug 28, 2026
pan-kot
approved these changes
Aug 28, 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 2304 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. Thetest-utilsselectors snapshot passes unchanged because it truncates to the path-derived hash. Two snapshots do change, both becausetokenStylesSuffixhashessrc/internal/styles/global.scss, whose header changed: the design tokens snapshot, and thethemesintegration snapshot, whose recorded keyframe names embed the suffix (awsui-fade-in-35003c→awsui-fade-in-592d6e). 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, thecontentHash/lineNumbersegments of scoped names, andtokenStylesSuffix, 228 of 229 stylesheets are byte-identical. The one exception istop-navigation/styles.scoped.css, where a scoped name embedded in a#awsui_\9 _…escape defeats the normaliser; its only differing line is that name's content hash (xji5f→oc0g1), with identical line counts and selectors. No file was added, removed, or left empty.Both snapshot updates are hash-only: normalising the old and new suffix to a placeholder makes the before and after files identical, so no token value, property name, or ordering changed.
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.