AMP Optimizer shouldn’t strip `sizes` without `srcset`
In packages/optimizer/lib/transformers/ApplyCommonAttributes.js line 81-83, the optimizer strips the sizes attribute when srcset is not also present. Here is the related comment in the code::
// According to the Mozilla docs, a sizes attribute without a valid srcset attribute should have no effect. // Therefore, it should simply be stripped, without producing media queries. // @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-sizes
But for AMP elements, sizes has a bigger meaning; see "Sizes" on https://amp.dev/documentation/guides-and-tutorials/learn/amp-html-layout/?format=websites
Stripping it causes some amp elements to size incorrectly after server-side-rendering is applied.
Good point! We should fix this!