kazijawad/esbuild-plugin-svgr

namedExport not working

fschwalm opened this issue · 3 comments

Hello!
I'm trying to use named exports and it's not working.

export { ReactComponent as Example } from './example.svg';
results in:
src/components/example.svg import { createElement } from "react";

It only works if i use:
export { default as Example } from './example.svg';

I have tried with the following config but it's not worked too.
svgrPlugin({namedExport: 'ReactComponent'}),

Any suggestion?

Thank you!

Hi! It looks like that parameter isn't supported in SVGR's Node API. After looking through the SVGR documentation, these are the supported parameters: https://react-svgr.com/docs/options/

I think you can use the template parameter to setup a function to change the component name. I updated the package with the correct type declarations.

I found an issue here:
gregberge/svgr#557

It seems a svgr/core issue.

Thank you so much!

RIP21 commented

@fschwalm can you share how you end up fixing that?