fix: Declare the SCSS license headers with line comments - #248
Open
TrevorBurnham wants to merge 1 commit into
Open
fix: Declare the SCSS license headers with line comments#248TrevorBurnham wants to merge 1 commit into
TrevorBurnham wants to merge 1 commit into
Conversation
Sass copies loud comments into the compiled CSS, so the header of a partial is emitted once per stylesheet that @uses it. Both of these files are consumed that way: they are copied into lib and exported as the sass/style entry points for @cloudscape-design/components and its siblings. Declaring the header with line comments keeps the notice in the shipped source while keeping it out of consumers' compiled output. Measured against cloudscape-design/components, this removes 16.5 KB of duplicated comments from its 1770 KB of published CSS and takes the median from two license blocks per stylesheet down to one. Neither file is compiled to CSS in this repo, and both already use line comments throughout their bodies. Refs cloudscape-design/components#4905.
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
Part of cloudscape-design/components#4905.
Sass copies loud comments into the compiled CSS, so a partial's license header is emitted once per stylesheet that
@uses it. Both SCSS files in this repo are consumed exactly that way:postbuildcopies them intolib, andpackage.jsonexports them as thesass/styleentry points that@cloudscape-design/componentsand its siblings@use.Declaring the header with line comments keeps the notice in the shipped source while keeping it out of consumers' compiled output.
Measured by building
cloudscape-design/componentsagainst this change: 16.5 KB of duplicated comments removed from its 1770 KB of published CSS, and the median goes from two license blocks per stylesheet down to one. I diffed all 229 compiled stylesheets before and after; the only differences are the removed comments and the generated scoped-name hashes, which embed a content hash and a line number.Two notes on why this is safe:
npm run buildonly copies them.@mixin,@use 'sass:map', and//comments throughout their bodies. Nothing can consume them as plain CSS today, so line comments add no new constraint. The block header was the only comment in either file not already using//.This is independent of the two related PRs and can land in any order:
commentTypeoption to thelicense-headersstylelint rule. This repo has no stylelint config, so it does not need that rule.How has this been tested?
Built
cloudscape-design/componentsagainst the patched files and compared all 229 compiled stylesheets, as described above.