-
Notifications
You must be signed in to change notification settings - Fork 323
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
Incorrect sourcemap for multi-line comment when css source from other module #593
Comments
Thanks for creating a repo for the error report, much appreciated! I'll take a look at what less does with multiine comments and how we fail to handle it. |
I did some investigation and it does not seem to be a clean-css issue. I managed to solve your problem by passing If you take a look at https://github.com/jakubpawlowicz/clean-css/blob/master/lib/stringifier/source-maps.js#L14 you'll see it can't be a problem with multiline comments since clean-css ignores string tokens - see line 19. I have also found that issue which seems similar - less/less-plugin-clean-css#8 |
Thanks @lukeapage! The interesting bit is that if I run it from CLI there's no reference to $stdin but to both CSS and Less files. I'll give it a try later on. |
I think this is the problem
less uses just No-one has just |
Will leave it to you.. changing the line break didn't fix the problem, though it did change things that looked important 😕 |
@jakubpawlowicz do you want to re-open this so its not forgotten? or did you get somewhere? |
Yeah, let's reopen it. |
Hi @jakubpawlowicz, Any updates on this? |
I have had no time to work on this yet but I may have in the coming weeks. |
+1 I'm using node-sass piped to autoprefixer to cleancss. The source map file appears as $stdin. |
Just found out this issue is probably the source of my issue. See linked issues in gulp-less and less.js. It seems clean-css assumes the line breaks of input sourcemaps are in format of the current platform it's running on: Changing the lineBreak to The code which tries to match line breaks can be found in comments-processor.js: https://github.com/jakubpawlowicz/clean-css/blob/v3.4.8/lib/text/comments-processor.js#L72-L95 The other text processor files contain similar line break matching code. Although I haven't had issues with them, I assume this can cause this issue as well. Related files:
My guess is these processors have to detect the line breaks used in each of the elements of @jakubpawlowicz Is there any way I can help you resolve this issue? |
Thanks @rros for detailed report. You are right about line breaks, those are OS line breaks by default. We can definitely detect line breaks (you can't mix different line breaks in a single file, can you?) but as a scope of a next minor clean-css version. Btw, if you use git you can force line breaks on a repository level. Have no idea if that helps you as a workaround: https://help.github.com/articles/dealing-with-line-endings/ |
@jakubpawlowicz thanks for the suggestion. We use Mercurial for version control and just changed the line breaks of the less files for now. However we primarily use Windows machines, so when we add a new file, it will have windows line breaks by default. As a workaround this is fine, but I like to get this issue fixed :) Regarding mixing line breaks, I think there are two cases here:
I think the first case is just bad input and we can ignore it, but the second is probably common. For example when I import a less-file (line break |
Thanks @rros for a valuable suggestion regarding mixed line breaks! I agree, we should handle it gracefully as people may be coming from different environments. |
clean-css 4 got rid of content escaping and deals with windows and *nix line breaks interchangeably. Internally all line breaks are removed and upon serializing written as Please reopen this issue (or open a new one) if this continues to be a problem. |
Close searx#2670 Note: clean-css contains a bug: * a multiline comment or URL adds "$stdin" to the sourcemap (see src/less/logicodev/search.less) * in this case when the user opens the devtools, the browser fails to load this "https://.../$stdin" URL * it is not a problem and the error appears only when the user actively tries to debug the CSS. * seems related to clean-css/clean-css#593
https://github.com/Splurov/lpcc-error
How to reproduce:
Output:
Unhandled rejection goes from https://github.com/jenius/accord/blob/master/lib/sourcemaps.coffee#L17
'$stdin' goes from https://github.com/jakubpawlowicz/clean-css/blob/master/lib/stringifier/source-maps.js#L39
Here is console.log(element) if put it on line 13 in https://github.com/jakubpawlowicz/clean-css/blob/master/lib/stringifier/source-maps.js#L13
Looks like a problem in generating sourcemap data for multi-line comment.
clean-css version is 3.3.1
Unfortunately I can't provide clean-css only example, I tried to minimize dependencies, but it works as expected in basic cases.
The text was updated successfully, but these errors were encountered: