Skip to content

Unable to load dompourify dependency for html() #2991

@sebbalex

Description

@sebbalex

Hello, my issue is similar to #2846 I have an application created with create-react-app --template typescript

I use:

"react-app-rewired": "^2.1.6",
"jspdf": "^2.1.1"

My custom webpack configuration

module.exports = function override(config, env) {
  if (!config.externals) {
    config.externals = {};
  }
  config.externals = {
    ...config.externals,
    canvg: "canvg",
    html2canvas: "html2canvas",
    dompurify: "dompurify",
  };
  return config;
};

And code:

import { jsPDF } from "jspdf";
doc.html(<p>Hello world!</p>", {
  callback: function (doc) {
    doc.save('doc.pdf');
  }
});

And this is what I get:
Uncaught (in promise) Error: Could not load dompurify: Error: Could not load

They are both present in my node_modules folder.
PDF is generated but completely blank.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions