`<svg>` tag makes the next siblings disappear
🐛 bug report
If you try to parcel an HTML file such as this:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<div>
<svg></svg>
<p>aaa</p>
<p>bbb</p>
</div>
</body>
</html>
the HTML file produced by Parcel will have two newlines instead of paragraphs, i.e.
<div>
<svg></svg>
</div>
This happens only for the tags which follow after the svg tag.
🎛 Configuration (.babelrc, package.json, cli command)
Default settings, running parcel build test.html
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 2.15.2 |
| Node | 22.15.0 |
| npm/Yarn | 11.3.0 |
| Operating System | macOS Sequoia 15.5 |
I have a similar problem in my project.
When I tried to migrate from 2.13 to 2.15 I thought there was a problem with the svg tag.
However, when creating a basic project to report it, I can reproduce the problem with a very basic html file and without svgs. The sample project is https://github.com/rferrerasm/parcel-minimal-example.
I get a partially minifyed, truncated index.html:
<!DOCTYPE html><html lang=en><meta charset=utf-8><meta name=viewport content="width=device-width, initial-scale=1.0"><title>Title</title><body>
<p>
Body.
</p>
I am using Windows 11. I have tried Node 20, 22 and 24 all with the same results.
Im having the same issue. It seems like it's only happening when building a file not in development mode. Maybe related to https://github.com/parcel-bundler/parcel/pull/10090
I'm getting this issue as well. I had to go back to 2.14.4 to get it working. From 2.15.0 and up it doesn't work
A Containerfile with minimal reproduction:
FROM node:24-alpine
WORKDIR /app
RUN npm install -g parcel@latest
RUN echo '<div><p>Before</p><svg><circle/></svg><p>After</p><p>Also removed</p></div>' > index.html && \
parcel build index.html && \
echo "=== Original ===" && cat index.html && \
echo "=== Built ===" && cat dist/index.html && \
grep -q "Also removed" dist/index.html || (echo "❌ BUG: Siblings after <svg> gone" && exit 1)
$ podman build .
...
dist/index.html 46 B 90ms
=== Original ===
<div><p>Before</p><svg><circle/></svg><p>After</p><p>Also removed</p></div>
=== Built ===
<div><p>Before</p><svg><circle /></svg></div>
This is not a solution, but a temporary workaround. Add this to your .parcelrc to be able to use the latest versions when experiencing this issue.
"optimizers": {
"*.html": []
},
Alternative workaround that keeps most optimizations enabled: config .htmlnanorc.json
{
"minifySvg": false
}