Skip to content

Commit

Permalink
feat: add missing jsx plugin
Browse files Browse the repository at this point in the history
closes #77
  • Loading branch information
pd4d10 committed May 3, 2023
1 parent f25ff52 commit 1dd7200
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 41 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
},
"dependencies": {
"@rollup/pluginutils": "^5.0.2",
"@svgr/core": "^7.0.0"
"@svgr/core": "^7.0.0",
"@svgr/plugin-jsx": "^7.0.0"
},
"packageManager": "pnpm@8.4.0"
}
108 changes: 68 additions & 40 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default function viteSvgr({
async transform(code, id) {
if (filter(id)) {
const { transform } = await import("@svgr/core");
const { default: jsx } = await import("@svgr/plugin-jsx");

const svgCode = await fs.promises.readFile(
id.replace(/\?.*$/, ""),
"utf8"
Expand All @@ -40,6 +42,7 @@ export default function viteSvgr({
filePath: id,
caller: {
previousExport: exportAsDefault ? null : code,
defaultPlugins: [jsx],
},
});

Expand Down

0 comments on commit 1dd7200

Please sign in to comment.