microsoft / fast

The adaptive interface system for modern web experiences.
https://www.fast.design
Other
9.28k stars 595 forks source link

fix: Suggested Rollup config corrupts output html #6795

Closed timfish closed 5 months ago

timfish commented 1 year ago

Pull Request

📖 Description

I found that the suggested Rollup config results in corrupted html: image

In the output bundle you can see the missing space: image

I tied these regexes and they fix the issue: https://github.com/microsoft/fast/blob/50dba9c58b1bc6ac0c8b948f68dd0cfb6485460b/build/transform-fragments.js

timfish commented 1 year ago

There are probably still some improvements to be had with the css regex since the output still has some unnessary spaces:

image
timfish commented 1 year ago

The css regex in transform-fragments.js actually needs a minor addition. It doesn't strip leading whitespace and needs an additional ^\s+.

https://github.com/microsoft/fast/blob/50dba9c58b1bc6ac0c8b948f68dd0cfb6485460b/build/transform-fragments.js#L31

So it would become:

/(?:\s*\/\*(?:[\s\S])+?\*\/\s*)|(?:;)\s+(?=\})|\s+(?=\{)|(?<=:)\s+|\s*([{};,])\s*|^\s+/g

Shall I create a PR for that first?