The error "Uncaught TypeError: Class constructor _ cannot be invoked without 'new'" when using new html2pdf()... suggests that while the outer call is attempting to instantiate a class, an internal operation within html2pdf.js might be failing and incorrectly calling an internal class constructor without new.
Looking at the common usage patterns and the typical structure of html2pdf.js, the library often exposes a factory function. This function, when called (e.g., html2pdf()), returns an instance (often a "worker") on which methods like from, set, and save are chained.
If esm.sh provides this factory function as the default export (which is typical for how html2pdf.js is structured), then calling new html2pdf() would be incorrect. The correct invocation would be html2pdf().from(element).set(options).save().
The previous change introduced new html2pdf(). Since the error persists, it's possible that this was a misstep and the library expects to be called as a factory. The error "Class constructor _ cannot be invoked without 'new'" would then indicate an issue triggered inside the library, possibly due to the outer factory function being called with new when it doesn't expect it, leading to incorrect this binding or internal state.