Ensure that NoWorkResult and LazyResult have the same outcome.#1909
Conversation
NoWorkResult and LazyResultNoWorkResult and LazyResult have the same outcome.
| this.root = root | ||
| this.opts = opts | ||
| this.css = cssString | ||
| this.originalCSS = cssString |
There was a problem hiding this comment.
There is a chicken vs. egg problem here that doesn't exist when fully parsing.
When the source is parsed there is already an Input instance created early. And this instance will have information about previous sourcemaps.
When the source is not parsed the Input instance is created in previous() but this is done after the annotation comments have already been removed.
Some mechanic is needed to get the previous sourcemaps from the original source and to store the modified css without the annotation comments.
I decided to add a second variable this.originalCSS which holds an unmodified copy.
I don't know if this is the best or even a good solution.
Please give feedback on this.
| } | ||
| } else if (this.css) { | ||
| this.css = this.css.replace(/(\n)?\/\*#[\S\s]*?\*\/$/gm, '') | ||
| this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, '') |
There was a problem hiding this comment.
When fully parsed all leading whitespace before an annotation comment will be removed, not only the first \n.
There was a problem hiding this comment.
I don't understand how this part is related to the PR's main purpose (ensuring both NoWorkResult and LazyResult have the same outcome)
There was a problem hiding this comment.
In a LazyResult the annotation is a parsed comment.
Comment nodes in PostCSS also contain all the leading whitespace.
In a NoWorkResult this RegExp is used and it only replaced a single preceding newline.
| } else { | ||
| map.clearAnnotation(); | ||
| this.result.css = map.css; | ||
| } |
There was a problem hiding this comment.
If no sourcemap is requested the already present inline sourcemap must also be removed.
|
Thanks. Released in 8.4.33. |
see : #1869