It seems to me that the problem would be caused by Mongoose packing, rather than vite/rollup's build, since it seems to run fine on your development environment.
PS: Could you try reproducing the Problem using a mongoose server running on your development machine, or even better: on a Dockerfile? Then you could share a minimal example that could help to further diagnose the issue.
You wouldn't download a car‽