You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid mapping (generated column -1) when CSS contains <style and HTML escaping applies #2168
Since 8.5.29, SafeStringifier.escapeHTML escapes <style / <!-- in the output. When escaping kicks in, the source map generator adds a mapping with generated.column: -1, and source-map-js prints Invalid mapping.
Reproduction
importpostcssfrom'postcss'constcss='/* see <style> */\na { color: red }\n'constresult=awaitpostcss([{postcssPlugin: 'noop',Once(){}}]).process(css,{from: 'in.css',map: {inline: false}})console.log(result.css)
Output (postcss 8.5.29, Node 24):
Invalid mapping: {"generated":{"column":-1,"line":3},"source":"in.css","original":{"column":0,"line":3},"name":null}
/* see \3c style> */
a { color: red }
Without <style in the CSS there is no warning.
Cause
In lib/stringify.js, if the escaped CSS differs from the original, the whole string is passed to the builder at once: builder(escaped, node) with the root node and no type. MapGenerator.generateString then treats it as both start and end of the root. For the end mapping it uses column - 2, and when the escaped string ends with \n, column is 1, so the generated column becomes -1.
Real-world impact
Vite 8 depends on postcss@^8.5.29, so any Vue SFC <style> block whose comment mentions <style> (for example /* keep this in <style> */) prints Invalid mapping in nuxt dev / vite dev.
Activity
ai commentedon Oct 9, 2026
Please send PR
deps: batch five soaked Dependabot updates (#2194)