Fix JSX comment duplication in both React and preserve modes#12
Fix JSX comment duplication in both React and preserve modes#12
Conversation
…issue Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
…odes Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
RyanCavanaugh
left a comment
There was a problem hiding this comment.
You absolutely cannot use Regexes to fix stuff like this, it will not work in all cases.
The investigation was pretty OK but you need to work on getting a minimal testcase first, understand exactly what's going wrong, and then do a proper fix either in the emitter, parser, scanner, or transformer depending on what you find out.
… scanning Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
You're absolutely right about regex being the wrong approach. I've implemented a proper fix by modifying the The fix detects Fixed in commit d6d8785. |
This PR fixes an issue where JSX comments were being duplicated in the transpiled output.
Problem
Comments within JSX elements were being treated as JSX text content rather than actual comments, causing duplication:
Input:
Before (problematic output):
Solution
The fix addresses the root cause in two places:
jsx.ts): AddedstripCommentsFromJsxText()function that removes comments from JSX text during transformation for React/ReactJSX modesemitter.ts): ModifiedemitJsxText()to filter out comments from JSX text nodes for preserve modeResults
After fix:
Testing
Fixes #11.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.