nativejsx
nativejsx copied to clipboard
Comments are removed from code, even for files with no JSX
If nativejsx encounters a source code file where there is no JSX (which is the majority of files in my 200 KLOC project), it still passes the file through its parser and code generator, which results in comments being removed and string quote style being changed.
What I'd like to see, ideally:
-
Comments to be retained everywhere. It's the minifier's job to remove them at a later stage in non-debug builds. As far as I understand, these instructions need to be followed to achieve this: https://github.com/ternjs/acorn#note-on-using-with-escodegen
-
Files to be kept completely intact if there is no JSX in them.
Thanks for all your hard work.
- This is actually non-trivial. I'm running several mutations to the AST which throws off ranges. While some comments are left intact, others cause an immediate failure. I'm not sure I have the time to figure out the range math involved.
- I'm now relying on internal transformed state to decide whether or not to send the AST back. If it's not transformed, I'm handing back the contents of the original file/string untouched.
Number 2 is nice, thanks a lot.
Dunno if this is the same issue but I can't comment on the JSX file:
{/* Comment 1 : Comment 2 */}
Gives me an:
TypeError: base[type] is not a function
Can I comment on my JSX file using Nativejsx? If so, how can I do that? Thanks!