Skip to content

Commit

Permalink
fix: fix duplicate plugin/preset detected error (#747)
Browse files Browse the repository at this point in the history
Closes: #746
  • Loading branch information
sinchang authored Jul 19, 2022
1 parent d2a2f07 commit 3c6a54c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/babel-preset/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ describe('preset', () => {
`)
})

it('handles descProp and titleProp', () => {
expect(
testPreset('<svg></svg>', {
titleProp: true,
descProp: true,
}),
).toMatchInlineSnapshot(`
"import * as React from \\"react\\";
const SvgComponent = ({
title,
titleId,
desc,
descId
}) => <svg aria-labelledby={titleId} aria-describedby={descId}>{desc ? <desc id={descId}>{desc}</desc> : null}{title ? <title id={titleId}>{title}</title> : null}</svg>;
export default SvgComponent;"
`)
})

it('handles replaceAttrValues', () => {
expect(
testPreset('<svg a="#000" b="#fff" />', {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const plugin = (_: ConfigAPI, opts: Options) => {
}

if (opts.descProp) {
plugins.push([svgDynamicTitle, { tag: 'desc' }])
plugins.push([svgDynamicTitle, { tag: 'desc' }, 'desc'])
}

if (opts.native) {
Expand Down

1 comment on commit 3c6a54c

@vercel
Copy link

@vercel vercel bot commented on 3c6a54c Jul 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svgr – ./

api.react-svgr.com
svgr-gregberge.vercel.app
svgr-git-main-gregberge.vercel.app

Please sign in to comment.