Open
Description
Describe the problem
sveltejs/kit#11059 as it stands now would change the output of the @sveltejs/enhanced-img
preprocessor to:
<picture><source srcset={"/1 1440w, /2 960w"} type="image/avif" /><source srcset={"/3 1440w, /4 960w"} type="image/webp" /><source srcset={"5 1440w, /6 960w"} type="image/png" /><img src={"/7"} alt="basic test" width=1440 height=1440 /></picture>
This would cause extra output to be inserted into the generated JS:
var source = $.child(picture);
$.attr(source, "srcset", "/1 1440w, /2 960w");
var source_1 = $.sibling(source);
$.attr(source_1, "srcset", "/3 1440w, /4 960w");
var source_2 = $.sibling(source_1);
$.attr(source_2, "srcset", "5 1440w, /6 960w");
It would be nice not to have these calls and still continue to rely only on the $.template
call
Describe the proposed solution
Automatically evaluate and inline any expressions known to have constant values
Alternatives considered
Possibly we can make relative paths not the default in SvelteKit so that we hit this case less often. This optimization may be nice nonetheless not only for the relative paths case, but for other instances where the user may write such code
Importance
nice to have