-
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
Add option to don't drop comments #221
Comments
The esbuild parser was designed for speed. It's not designed to be a code formatter. It will likely be extremely difficult to modify esbuild to ensure that all comments are preserved and in their original locations, especially as code can be moved around due to syntax transformations. I don't think esbuild is the right tool if you need to do this, and I am not planning on adding general comment preservation to esbuild. You will want to use other tools to do this instead. I can see adding a special case for statement-level comments only. I believe I should be able to guarantee that those are preserved without rewriting the parser. That should be sufficient to cover license comments I think. |
Is that comments "attached" to a nodes? I mean a comments right before a node something like it's in TypeScript AST). If so, I think it might cover cases with "class" comment as well. |
Attaching comments to nodes makes it easy for them to be accidentally lost. Instead I'm planning on creating a new kind of statement AST node for statement-level comments. |
Relevant to this issue: I'm currently adding limited support for |
I just published a release with support for Edit: Note that this is only for |
I closed this because both |
Related to #218 and #220.
Tools like
uglifyjs
orterser
may rely on some comments like/*@__PURE__*/
(seeside_effects
on https://github.com/terser/terser/blob/504b9677d2d6086025ead5afb713e151877944b2/README.md#compress-options).In some projects you can't use TypeScript in
transpileOnly
mode (or don't want because you have already compiled code and just want to process JS files itself). The TypeScript leaves a comment like/** @class */
right before class' IIFE, which could be replaced (somehow) with/*@__PURE__*/
soterser
/uglifyjs
can understand it and do its magic with them (see mishoo/UglifyJS#2279).It seems that
esbuild
drop all comments (licences as well) which does all comments-dependent processing unreal (dropping licences is the issue as well).The text was updated successfully, but these errors were encountered: