apostrophecms / sanitize-html

Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis. Built on htmlparser2 for speed and tolerance

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems running applications bundled using Vite

truesteps opened this issue · comments

To Reproduce

Step by step instructions to reproduce the behavior:

  1. Install sanitize-html with
  2. Try run project with Vite dev
  3. Open page
  4. See error

Expected behavior

A working build with vite

Describe the bug

Seems like V-sanitize implements some functions from the path node library and path uses process.platform, meanwhile Vite doesn't send the process into context, it uses import.meta. The two attached screenshots showcase the issue, as well as the problem line.

Details

Version of Node.js:
v16.11.1

Server Operating System:
Docker Ubuntu

Additional context:

I'm using sanitize-html within a package called v-sanitize for vue and I wanted to rewrite it to Vue 3 and Vite support.

Screenshots
Screenshot 2022-07-07 at 10 06 16
Screenshot 2022-07-07 at 10 06 10

I updated 2nd step, since Vite only uses esmodules on dev, this only breaks when bundling app for development. When bundling for production, Vite uses rollup, so production builds work as expected.

This looks like a bundling / frontend build issue at the postcss level. You could open a ticket with postcss, or it may be an issue with the way your bundling for frontend use works, but it's not something that can be resolved within sanitize-html.

Excuse me, I meant to say "within sanitize-html."