node-html-to-text
node-html-to-text copied to clipboard
.DefaultHandler is not a constructor
Getting this error .DefaultHandler is not a constructor in console when using a production build with angular 6 Using the code in a service:
const { htmlToText } = require('nxt-html-to-text'); const text = htmlToText(html, {})
Package versions are as follow: { "@angular/cdk": "^7.3.6", "@angular/common": "^6.1.0", "@angular/compiler": "^6.1.0", "@angular/core": "^6.1.0", "html-to-text": 7.0.0,
}
Please find screenshot attached
No idea why you run into this issue.
htmlparser2
still exports DomHandler
as DefaultHandler
and that shouldn't cause any issue.
This might be related to how your web project is assembled.
html-to-text
was made as a Node.js package and is not tested for web compatibility.
I plan to make it more web-friendly in version 9, when I will move CLI to a separate package. For now I won't make any attempt to understand how different bundlers might butcher the library. If you can explain the cause of this issue to me then I'd be happy to include the fix. So far the change you did in your fork seems pointless to me.
Version 9 is out and it should work better with various bundlers. Please open a new issue if there is any issue with version 9.