-
Notifications
You must be signed in to change notification settings - Fork 3
Fix JSX comment duplication in both React and preserve modes #12
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
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.