1

I'm trying to use dompurify in my angular application, where in a service. I'm importing it as

import * as DOMPurify from 'dompurify';

This works fine when run normally as a CSR application. But if I run it as a SSR, I get

export 'sanitize' (imported as 'DOMPurify') was not found in 'dompurify' (possible exports: default)

I'm using dompurify v3.0.3. On the other hand, If I use

const DOMPurify = require('dompurify')

It works without an error . But I'm not sure if this is the correct way to use it as angular recommends using ES6 imports.

coding life
  • 42
  • 1
  • 9
  • https://www.npmjs.com/package/isomorphic-dompurify – Adam Jenkins Jun 26 '23 at 10:28
  • @AdamJenkins I actually already tried that, but when i use isomorphic-dompurify I get Unhandled Promise rejection: Cannot convert undefined or null to object, when compiling in node 16.19.1 – coding life Jun 26 '23 at 11:47
  • Where does that error come from? I ran into this same problem on an SSR app and isomorphic dompurify solved it for me – Adam Jenkins Jun 26 '23 at 11:53
  • @AdamJenkins getting error in vendor.js file inside dist/server . which version of isomorphic-dompurify and nodejs were you using ? – coding life Jun 26 '23 at 12:08
  • See https://github.com/cure53/DOMPurify#running-dompurify-on-the-server – kemsky Jun 28 '23 at 16:49

0 Answers0