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

Comments are deleted although minify is set to false #18605

Closed
7 tasks done
joseangel-mm opened this issue Nov 7, 2024 · 4 comments
Closed
7 tasks done

Comments are deleted although minify is set to false #18605

joseangel-mm opened this issue Nov 7, 2024 · 4 comments
Labels
wontfix This will not be worked on

Comments

@joseangel-mm
Copy link

joseangel-mm commented Nov 7, 2024

Describe the bug

In a very simple Vite + React app, I am trying to keep comments in the code. To do so I've set minify to false, but in the final built index.js the comments are deleted.

Reproduction

no link

Steps to reproduce

vite-project-comments.zip

You can reproduce the issue in this PoC, to do is, just run the following command npm i && npm run build and check that the index created inside the dist folder doesn't have the comments set in the App.js file.

System Info

System:
    OS: macOS 15.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 333.97 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.12.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 130.0.6723.93
    Edge: 130.0.2849.68
    Safari: 18.1
    Safari Technology Preview: 18.0

Used Package Manager

npm

Logs

> simple-react-app@0.0.0 build
> vite build

vite v5.4.10 building for production...
✓ 30 modules transformed.
dist/index.html                  0.39 kB │ gzip:  0.27 kB
dist/assets/index-CP4adKi0.js  215.84 kB │ gzip: 54.45 kB
✓ built in 392ms

Validations

@sapphi-red
Copy link
Member

This is an expected behavior by esbuild (evanw/esbuild#3943 (comment)).

If you disable esbuild by esbuild: false, the comments will be preserved (repro).
But that of course means you cannot use any features powered by esbuild.

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
@sapphi-red sapphi-red added wontfix This will not be worked on and removed pending triage labels Nov 8, 2024
@joseangel-mm
Copy link
Author

This is an expected behavior by esbuild (evanw/esbuild#3943 (comment)).

If you disable esbuild by esbuild: false, the comments will be preserved (repro). But that of course means you cannot use any features powered by esbuild.

Hi @sapphi-red, thanks for your response.

I've tested it with esbuild disabled but the result was the same, the comments were removed. You can see here.

@sapphi-red
Copy link
Member

That's because plugin-react depends on esbuild and turns it on.

@joseangel-mm
Copy link
Author

That's because plugin-react depends on esbuild and turns it on.

Understood, thanks for the clarification.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants