Skip to content

fix: use default DOMpurify export

What does this MR do?

Replace 'magic' named import from dompurify to a default one.

Right now named import from dompurify works because of the Webpack magic under the hood that allows to have a named import from a default export.

Example:

// module.a.js
export default { foo: 1 }
// module.b.js
import { foo } from 'module.a.js' // works in Webpack

However this doesn't work in Vite and workarounds are required to deal with these:

// dompurify-export-polyfill.js
import DOMPurify from 'node_modules/dompurify/dist/purify.es.js';

const { sanitize, addHook, isValidAttribute } = DOMPurify;

export { sanitize, addHook, isValidAttribute };

This MR intends to fix that by using a proper default import with restructuring to retain the import logic.

Does this MR meet the acceptance criteria?

Conformity

  • Code review guidelines.
  • GitLab UI's contributing guidlines.
  • If it changes a Pajamas-compliant component's look & feel, the MR has been reviewed by a UX designer.
  • If it changes GitLab UI's documentation guidelines, the MR has been reviewed by a Technical Writer.
  • If the MR changes a component's API, integration MR(s) have been opened in the following projects to ensure that the @gitlab/ui package can be upgraded quickly after the changes are released:
  • Added the ~"component:*" label(s) if applicable.

Merge request reports

Loading