-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Usage in web worker #1403
Comments
@jlarmstrongiv could this help? remarkablemark/html-dom-parser#502 |
After an hour of debugging—I confirmed the answer is overriding the version to the server version. @remarkablemark adding |
@jlarmstrongiv would you be interested in improving the README.md? Since this feels more like an edge case, I think it makes more sense to make custom overrides in the bundler config. |
Rendering in WinterCG runtimes (Vercel, Cloudflare, and other functions) and web workers are becoming more and more common these days. I personally prefer adding the export because that will be the same no matter what. Overriding bundlers is often error prone, painful, and bundler-specific, particularly when throwing in esm. Sometimes it may not even be possible. For example, it’s not possible to override just the web worker—it’s all or nothing. Whereas, with imports, I have a lot more flexibility. If you’re up for adding that export, I’ll gladly update the README.md |
Could you clarify what you mean by adding an export? Do you mean this: import 'html-dom-parser/server'; |
Yes, like |
Gotcha that might be a bit tricky to propagate since |
we are running into this issue with |
Getting this issue as well with a CloudFlare worker environment and Vite. Would love a fix here. Adding
|
In my case, I want to render a PDF report using @react-pdf/renderer in the browser. Part of the report contains rich text, which we are using html-react-parser to transform into React DOM, and then into the React PDF object model. It makes sense to do this, since the reports are a subset of what we show in React, so that transformation always needs to be done anyway. However, now for long reports that are freezing the browser we want to move them to web workers, and we are finding we can't use this package inside web workers in those cases. |
Expected Behavior
Render html to react elements
Actual Behavior
Steps to Reproduce
Try using
html-react-parser
in a web workerReproducible Demo
I will create a demo if there is interest in fixing this bug.
I believe it’s due to the more limited environment of web workers, which does not have access to window or document objects.
A similar issue for Vercel Edge Functions was closed as
wontfix
#736Regardless, I’m open and looking for workarounds to make
html-react-parser
work in a web workerEnvironment
Keywords
Web worker
The text was updated successfully, but these errors were encountered: