-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that NoWorkResult
and LazyResult
have the same outcome.
#1909
Ensure that NoWorkResult
and LazyResult
have the same outcome.
#1909
Conversation
NoWorkResult
and LazyResult
NoWorkResult
and LazyResult
have the same outcome.
@@ -16,6 +16,7 @@ class MapGenerator { | |||
this.root = root | |||
this.opts = opts | |||
this.css = cssString | |||
this.originalCSS = cssString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -74,7 +75,7 @@ class MapGenerator { | |||
} | |||
} | |||
} 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no sourcemap is requested the already present inline sourcemap must also be removed.
Thanks. Released in 8.4.33. |
see : #1869