-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Question about comments deletion #578
Comments
This is a duplicate of #516. Here is my reply from that thread:
|
Thank you @evanw for your reply, I am sorry but somehow I did not manage to found the old issue. I am not sure to have got the point, but I thought that since esbuild preserves |
Comment preservation is generally done with specific semantics in mind since the comments are usually annotations that mean something specific. Semantically Semantically Comments for Istanbul have different semantics that are specific to Istanbul. I'm not familiar with Istanbul but from what I've read here it's something like this:
To pass these comments through esbuild's build pipline correctly (including tree shaking, constant folding, code reordering, dead code elimination, etc.) esbuild would have to encode comments using Istanbul's specific notion of "next thing" in its AST. Other tools requiring comment preservation for their own purposes may have different needs altogether. For example, I could imagine that some other tools use line-by-line comments and would require that esbuild preserve the line breaks in between operators and/or the number of lines in between comments. I want esbuild to be a general-purpose tool without having to encode the specifics of many other tools into esbuild itself. So I believe this to be out of esbuild's scope. The general way of solving all of these use cases is to use something more like a code formatter that preserves the original source code as much as possible. Other tools are better set up to do this. I believe Rollup does something like this with the magic string library, for example. This is not easy to do for esbuild because internally it's built more like a compiler instead of a code formatter. |
Thanks for the explanation, I am going to close this issue 🙂 |
Anyone coming by here, you can use https://esbuild.github.io/api/#legal-comments |
Hello!
Why does esbuild strips out comments even when minification is not required? Having an option to leave comments could be useful for interoperability. For example,
istanbul
refers to some comments to ignore part of the code when computing the coverage.The text was updated successfully, but these errors were encountered: