sanitize-html shows "Module 'path' has been externalized" warnings — how to hide them?

Discussão em 'Angular' iniciado por Jon, Agosto 9, 2025.

  1. Jon

    Jon Guest

    I’m using sanitize-html in my Angular app (with Vite), and I don’t want to replace it because it works great.

    Packages:

    "@types/sanitize-html": "^2.16.0",
    "sanitize-html": "^2.17.0",
    "@angular/core": "~19.2.0"


    Code:

    import sanitizeHtml, { IOptions } from 'sanitize-html';

    export class Clipboard {
    onPaste(range: Range, { text, html }: { text?: string; html?: string }): void {
    html = html?.replace(`<meta charset='utf-8'>`, '');
    html = (html && sanitizeHtml(html, this.options as IOptions)) || html;
    this.fn(range, { html, text });
    }
    }


    When I run Angular with Vite, I get a lot of warnings like this:

    Module "path" has been externalized for browser compatibility.
    Cannot access "path.isAbsolute" in client code.
    See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.


    All of them come from sanitize-html. The library still works fine at runtime, but the warnings are noisy.

    Question: How can I tell Angular/Vite to stop showing these warnings for sanitize-html? I’m not looking for a replacement library — just a way to suppress these messages.

    [​IMG]

    Continue reading...

Compartilhe esta Página