Open PlopTheReal opened 2 years ago
I see. Since we don't use sanitize-html on the front end, support for front end use comes from the community. It will likely help if you can provide a simple test project.
Here we can see the error in the console: https://stackblitz.com/edit/sveltejs-kit-template-default-7tj64c?file=src/routes/index.svelte
@PlopTheReal If you are in a hurry, can try dompurify 👆
I tried using dompurify but it was missing some features that I depend on such as not lower casing tags since I'm using Vue there are some Vue Components involved and also closing tags that are missing them. I was able to work around the Module "fs" has been externalized for browser compatibility issue by aliasing some nodejs packages to an empty file, we are using Nuxt 3 here is an example of how I was able to alias this, I only needed to do it in dev, in build it is not an issue
nuxt.config.js
const aliasedPackages = process.env.NODE_ENV !== 'production'
? {
vueBundler: 'vue/dist/vue.esm-bundler.js',
url: 'empty-file.txt',
fs: 'empty-file.txt',
path: 'empty-file.txt',
}
: { vueBundler: 'vue/dist/vue.esm-bundler.js' };
export default defineNuxtConfig({
vite: {
resolve: {
alias: aliasedPackages,
},
any updates?
Not sure if that's not postcss issue but when importing the library on the browser I'm getting the following:
sanitize-html 2.7.1 postcss 8.4.14
Server Operating System: System: OS: Linux 5.15 Ubuntu 22.04 LTS 22.04 LTS (Jammy Jellyfish) CPU: (1) x64 Intel(R) Xeon(R) CPU X5570 @ 2.93GHz Memory: 3.26 GB / 12.68 GB Container: Yes Shell: 5.1.16 - /bin/bash Binaries: Node: 18.4.0 - ~/.nvm/versions/node/v18.4.0/bin/node Yarn: 1.22.19 - /usr/bin/yarn npm: 8.12.1 - ~/.nvm/versions/node/v18.4.0/bin/npm Browsers: Firefox: 102.0.1
The base framework is SvelteKit