-
-
Notifications
You must be signed in to change notification settings - Fork 420
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
The upgrade of @babel/generator
to v7.20.5
ignores new lines from the template
#809
Comments
Previously babel didn't preserve newlines, it just added them forever. |
SVGR allows passing options to Babel. I tried this: .svgrc {
"typescript": true,
"jsx": {"babelConfig": {"retainLines": true}}
} Then: npx @svgr/cli test.svg I get the output file using Typescript (so svgr is reading the config), but the |
https://babeljs.io/docs/en/options#generatoropts
|
Temporarily I'm fixing this by adding Screen.Recording.2022-12-16.at.23.14.02.mov |
Thanks for the suggestion! I tried it, but it didn't work: {
"typescript": true,
"jsx": {
"babelConfig": { "generatorOpts": {"retainLines": true } }
}
} |
@roni-castro-db thanks! that hack worked for me |
I did some research.
This sucks and I haven't thought of a good solution. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
💥 Regression Report
The upgrade of
@babel/generator
tov7.20.5
ignores new lines from the templateRelated Babel issue (closed as "won't fix"): babel/babel#15064
The babel generator caused this issue. But, it will affect users of SVGR that are sensitive to the output format (ie. tests that compare SVGR output or lint checks). In theory, it shouldn't affect the runtime behavior.
Last working version
Worked up to version: 6.3.1 (==> it worked when @babel/generator resolves to pre-7.20, but you can reproduce this issue in 6.3.1 and a newer babel version that matches the semver in @svgr/core)
Stopped working in version: 6.5.1
Forcing NPM to use
@babel/generator
7.18.3 works.To Reproduce
Use a test file (like the one from the playground):
Then run
@svgr/cli
with the default options:Output:
The output ignores the new lines in the
defaultTemplate
: https://github.com/gregberge/svgr/blob/main/packages/babel-plugin-transform-svg-component/src/defaultTemplate.tsExpected behavior
The output should preserve the new lines of the template:
The text was updated successfully, but these errors were encountered: