compiler
compiler copied to clipboard
Astro 3.5.5 compiler regression for whitespace
Astro Info
Astro v3.5.5
Node v18.17.1
System macOS (arm64)
Package Manager pnpm
Output static
Adapter none
Integrations @astrojs/tailwind
@astrojs/react
@astrojs/sitemap
astro-compress
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Astro v3.5.5 (or specifically @astrojs/compiler 2.3.1) generates additional whitespace for the same code compared to previous versions, presumably due to different handling of new lines in source code.
For the following example, taken out of astro-paper:
<nav class="breadcrumb" aria-label="breadcrumb">
<ul>
<li>
<a href="/">Home</a>
<span aria-hidden="true"> > </span>
</li>
...
Locking to Astro 3.5.3 and @astrojs/compiler 2.3.0 would give the following breadcrumbs, which I believe is the correct behavior
But the latest Astro 3.5.5 (@astrojs/compiler 2.3.2) generates additional whitespaces around the <span>
, which can only be removed if I manually format the file where the <a>
and <span>
above are on the same line. The whitespace is visible as 1 character wide, and also shown in the FireFox DevTools.
Using Astro 3.5.5 with compiler 2.3.0 works fine, and is my current workaround. This narrows the problem to @astrojs/compiler rather than the astro main package. And the above can be reproduced with a fresh clone of https://github.com/satnaing/astro-paper after running npm upgrade
, and the workaround can be verified by locking
"@astrojs/compiler": "2.3.0"
What's the expected result?
I would expect the old version to be correct, i.e. behavior from @astrojs/compiler 2.3.0 and before. But I don't know much about web dev to be sure if this is a regression or just a previously wrong behavior fixed.
Link to Minimal Reproducible Example
https://github.com/satnaing/astro-paper
Sorry, I'm not able to figure out what's wrong to put it inside a minimal example, and I was hoping devs working on @astrojs/compiler would know from the description above. Also the astro-paper project can also be used to reproduce the issue.
Participation
- [ ] I am willing to submit a pull request for this issue.