Closed connor-baer closed 3 years ago
Any chance to update the npm package with this very useful PR?
This has been published in v2.0.1
Still not working. When I set "['inline-react-svg', { svgo: false }]",and import a normal svg,babel throw an error "Unexpected token"
@YaoKaiLun can you file a new issue, and include the full svg content in question?
👌
@ljharb I found it was my problem, my svg file has the below unclosed tag
<?xml version="1.0" encoding="UTF-8"?>
Purpose
The plugin crashes when SVGO is turned off (e.g.
[['inline-react-svg', { svgo: false }]]
). Here's the error message:Full stack trace
``` TypeError: /home/runner/work/icons/icons/AddItemFilled.js: Cannot read property 'replace' of undefined at escapeBraces (/home/runner/work/icons/icons/node_modules/babel-plugin-inline-react-svg/lib/escapeBraces.js:24:20) at applyPlugin (/home/runner/work/icons/icons/node_modules/babel-plugin-inline-react-svg/lib/index.js:112:58) at PluginPass.ImportDeclaration (/home/runner/work/icons/icons/node_modules/babel-plugin-inline-react-svg/lib/index.js:199:11) at newFn (/home/runner/work/icons/icons/node_modules/@babel/traverse/lib/visitors.js:175:21) at NodePath._call (/home/runner/work/icons/icons/node_modules/@babel/traverse/lib/path/context.js:55:20) at NodePath.call (/home/runner/work/icons/icons/node_modules/@babel/traverse/lib/path/context.js:42:17) at NodePath.visit (/home/runner/work/icons/icons/node_modules/@babel/traverse/lib/path/context.js:92:31) at TraversalContext.visitQueue (/home/runner/work/icons/icons/node_modules/@babel/traverse/lib/context.js:116:16) at TraversalContext.visitMultiple (/home/runner/work/icons/icons/node_modules/@babel/traverse/lib/context.js:80:17) at TraversalContext.visit (/home/runner/work/icons/icons/node_modules/@babel/traverse/lib/context.js:142:19) ```Approach & Changes
Note: PR https://github.com/airbnb/babel-plugin-inline-react-svg/pull/49 which adds a test for this use case should be merged alongside this to prevent future regressions.