Ok, shortly after posting I found the answer myself by just trying out a few things. To ensure that the third-party modules are converted properly, one simply has to include them in the vite config like so:
{
optimizeDeps: {
include: ["prop-types", "sanitize-html"]
},
}
(I had originally tried optimizeDeps, but only by including our own module, which did not help.)