react-pdf-html
react-pdf-html copied to clipboard
Using with vanilla js ESM causes TypeError on console
I am getting an TypeError to console from react-pdf-html when running it.
console.error
Error parsing style attribute "width:100%;height:100%" for tag: SVG TypeError: cssParse is not a function
at convertElementStyle (/proj/node_modules/react-pdf-html/src/parse.ts:108:20)
at convertNode (/proj/node_modules/react-pdf-html/src/parse.ts:146:13)
at Array.map (<anonymous>)
at convertNode (/proj/node_modules/react-pdf-html/src/parse.ts:133:35)
at parseHtml (/proj/node_modules/react-pdf-html/src/parse.ts:171:18)
at renderHtml (/proj/node_modules/react-pdf-html/src/render.tsx:369:18)
at Html (/proj/node_modules/react-pdf-html/src/Html.tsx:15:13)
This is probably caused by: https://github.com/danomatic/react-pdf-html/blob/b6aa22455379ac8664d878e7756bc07e819c4f75/src/parse.ts#L10-L11
Everything works alright if I change it to the following:
import cssTree from 'css-tree';
const { generate, parse: cssParse } = cssTree;
related: #83
I have the same issue I think. OPs fix also fixes this for me.