Error while using jsPDF( Error: Could not load dompurify: ReferenceError: dompurify is not defined) in Angular 14 application

I am using jsPDF for angular and created custom config file and added this code,

module.exports = {
    // ...
    externals: {
      canvg: "canvg",
      html2canvas: "html2canvas",
      dompurify: "dompurify"
    }
  };

The app runs using ng build –watch.
I have tried many options but it still gives me an error: ERROR Error: Uncaught (in promise): Error: Could not load dompurify: ReferenceError: dompurify is not defined
Error: Could not load dompurify: ReferenceError: dompurify is not defined

Is there any workround for this? Any suggestions will be helpful.