Skip to content
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

[Bug]: remove whitespaces out of comments unexpectedly #1509

Open
alcapitan opened this issue Jun 7, 2023 · 3 comments
Open

[Bug]: remove whitespaces out of comments unexpectedly #1509

alcapitan opened this issue Jun 7, 2023 · 3 comments
Labels

Comments

@alcapitan
Copy link

Describe the bug

I installed the package postcss-discard-comments in my existing NPM project.
It removed comments as I wanted but it also removed whitespaces out of comments unexpectedly.
I have not installed cssnano, actually the postcss-discard-comments's NPM page give the link to cssnano's github page.

Expected behaviour

I expected it removes comments without removing whitespaces out of comments.

The best thing in my opinion to constat the bug and view my configuration is my commit that revealed the issue.

Steps to reproduce

May run for the first time postcss-discard-comments in an existing NPM project.

Version

6.0.0

Preset

(no preset)

Environment

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz
    Memory: 958.45 MB / 7.75 GB

Package details

├─┬ autoprefixer@10.4.14
│ └── postcss@8.4.23 deduped
├─┬ postcss-cli@10.1.0
│ ├─┬ postcss-load-config@4.0.1
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-reporter@7.0.5
│ │ └── postcss@8.4.23 deduped
│ └── postcss@8.4.23 deduped
├─┬ postcss-discard-comments@6.0.0
│ └── postcss@8.4.23 deduped
├─┬ postcss-import@15.1.0
│ └── postcss@8.4.23 deduped
├─┬ postcss-preset-env@8.4.1
│ ├─┬ @csstools/postcss-cascade-layers@3.0.1
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-color-function@2.2.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-color-mix-function@1.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-font-format-keywords@2.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-gradients-interpolation-method@3.0.5
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-hwb-function@2.2.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-ic-unit@2.0.3
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-is-pseudo-class@3.2.1
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-logical-float-and-clear@1.0.1
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-logical-resize@1.0.1
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-logical-viewport-units@1.0.3
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-media-minmax@1.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-media-queries-aspect-ratio-number-values@1.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-nested-calc@2.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-normalize-display-values@2.0.1
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-oklab-function@2.2.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-progressive-custom-properties@2.2.0
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-relative-color-syntax@1.0.0
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-scope-pseudo-class@2.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-stepped-value-functions@2.1.1
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-text-decoration-shorthand@2.2.4
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-trigonometric-functions@2.1.1
│ │ └── postcss@8.4.23 deduped
│ ├─┬ @csstools/postcss-unset-value@2.0.1
│ │ └── postcss@8.4.23 deduped
│ ├─┬ css-blank-pseudo@5.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ css-has-pseudo@5.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ css-prefers-color-scheme@8.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-attribute-case-insensitive@6.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-clamp@4.1.0
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-color-functional-notation@5.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-color-hex-alpha@9.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-color-rebeccapurple@8.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-custom-media@9.1.3
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-custom-properties@13.1.5
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-custom-selectors@7.1.3
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-dir-pseudo-class@7.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-double-position-gradients@4.0.3
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-place@8.0.1
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-pseudo-class-any-link@8.0.2
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-replace-overflow-wrap@4.0.0
│ │ └── postcss@8.4.23 deduped
│ ├─┬ postcss-selector-not@7.0.1
│ │ └── postcss@8.4.23 deduped
│ └── postcss@8.4.23 deduped
├── postcss@8.4.23
└─┬ stylelint@15.6.2
  ├─┬ postcss-safe-parser@6.0.0
  │ └── postcss@8.4.23 deduped
  └── postcss@8.4.23 deduped

Additional context

No response

@ludofischer
Copy link
Collaborator

ludofischer commented Jun 7, 2023

I might be missing something obvious, but I do not see where the white space changed inside comments in the commit you've linked (alcapitan/atui@2f5ab80#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519)? I do see white space changes but only outside of comments, for example the white space after the colon (:) disappears. Could you point me to a line where you see white space inside comments disappearing?
Sorry, I think I understand now what you mean by "out" of comments.

@ludofischer ludofischer removed the triage label Jun 7, 2023
@ludofischer
Copy link
Collaborator

It's an interesting situation, I think it's the first time someones reports using the comment remover without the rest of cssnano. Why do you want to only remove comments without also minifying the CSS? It might be unfixable if the AST does not contain enough information about these spaces.

@alcapitan
Copy link
Author

Sorry, I think I understand now what you mean by "out" of comments.

Yes indeed, I am not a native english speaker and I wrote with my live skills.

It's an interesting situation, I think it's the first time someones reports using the comment remover without the rest of cssnano. Why do you want to only remove comments without also minifying the CSS? It might be unfixable if the AST does not contain enough information about these spaces.

Yes, I can use CSSnano. But in my (surely questionable) NPM setup, I'm using Esbuild for minification.
Also this independent package exists, so it should work as expected. I just wanted to alert you to this strange behavior, in itself it is not a bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants