Skip to content
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

Does not transform SVG (v3.0.2) #917

Open
JonnyBurger opened this issue Nov 2, 2023 · 3 comments
Open

Does not transform SVG (v3.0.2) #917

JonnyBurger opened this issue Nov 2, 2023 · 3 comments

Comments

@JonnyBurger
Copy link

I ran the following script off the documentation:

optimize.mjs

import { transform } from "@svgr/core";

const svgCode = `
<svg xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">
  <rect x="10" y="10" height="100" width="100"
    style="stroke:#ff0000; fill: #0000ff"/>
</svg>
`;

const jsCode = transform.sync(
  svgCode,
  { icon: true },
  { componentName: "MyComponent" }
);

console.log(jsCode);

And ran it with Node. The output was

<svg xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">
  <rect x="10" y="10" height="100" width="100"
    style="stroke:#ff0000; fill: #0000ff"/>
</svg>

I expected the output to be in React syntax.

I used v3.0.2 of the package.

@JonnyBurger JonnyBurger changed the title Does not transform SVG (Bun / v3.0.2) Does not transform SVG (v3.0.2) Nov 3, 2023
@AlpayC
Copy link

AlpayC commented Nov 12, 2023

yea this happens also in next js, when i using the app router endpoint

@rossmoody
Copy link
Contributor

rossmoody commented Nov 23, 2023

@JonnyBurger I think the config may need the plugins: ['@svgr/plugin-jsx'] part to transform to JSX. Otherwise it only transforms the SVG.

@ggdaltoso
Copy link

I was running into the same issue and @rossmoody suggestion worked for me.
Thanks 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@JonnyBurger @ggdaltoso @rossmoody @AlpayC and others