-
Notifications
You must be signed in to change notification settings - Fork 496
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
fix(core): 🐛 Preserve meaningful whitespace #1219
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
This seems unrelated to my changes. It must have been regenerated when I updated the snapshots. Please confirm if this is correct, or if I should revert this file
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.
Are you on the latest main
? This change shouldn't happen.
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 2dd44ba. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 4 targetsSent with 💌 from NxCloud. |
You also need to run |
Awesome PR, thanks for raising it! I believe this also helps us close #310, which was waiting on React/Solid generator to stop creating new lines for each text block. :) |
Fixes #1218
Description
Some code generators were joining blocks with newlines (
\n
), which, when run through thededent
helper, would then trim any trailing whitespace. This ended up causing problems with significant whitespace in some scenarios.This PR simply changes the join operation to use the empty string. The parser for mitosis already preserves the significant whitespace, so this makes the output components more closely resemble their mitosis source code. Prettier can still be used to format the output code, which will use a syntax tree that preserves meaningful whitespace while avoiding excessively long line lengths and adding stylistic line breaks.
The main focus for review should be:
componentToX
function that calls ablockToX
function recursively and joins children together, would it make sense to have a helper method for the join operation so that this type of change can be made more accurately across generators?