Adding this to vite config will solve the problem:
{
build: {
target: "es2022"
},
esbuild: {
target: "es2022"
},
optimizeDeps:{
esbuildOptions: {
target: "es2022",
}
}
}
Find more here: https://github.com/mozilla/pdf.js/issues/17245