Skip to content

Using with vanilla js ESM causes TypeError on console #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anajavi opened this issue Apr 26, 2024 · 5 comments · May be fixed by #95
Open

Using with vanilla js ESM causes TypeError on console #89

anajavi opened this issue Apr 26, 2024 · 5 comments · May be fixed by #95

Comments

@anajavi
Copy link

anajavi commented Apr 26, 2024

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:

import * as cssTree from 'css-tree';
const { generate, parse: cssParse } = cssTree;

Everything works alright if I change it to the following:

import cssTree from 'css-tree';
const { generate, parse: cssParse } = cssTree;

related: #83

@JorgeAtPaladin
Copy link

JorgeAtPaladin commented May 2, 2024

I have the same issue I think. OPs fix also fixes this for me.

@Vanals
Copy link

Vanals commented Nov 4, 2024

Hi, what was the solution for this issue? I am having the same problem..

@pdrymer
Copy link

pdrymer commented Dec 11, 2024

I have the same issue. OPs fix is also working for me.

@danomatic
Copy link
Owner

I would love if someone could submit a PR that fixes these import issues for ESM and CommonJS. I've tried a few times and it has remained broken for one type or another.

@coren-frankel
Copy link
Contributor

I would love if someone could submit a PR that fixes these import issues for ESM and CommonJS. I've tried a few times and it has remained broken for one type or another.

@danomatic Is that to say the solution in #95 doesn't work for CommonJS as well? I'd be willing to give this greater attention if that wasn't sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants