vitepodmanesbuild

Podman builds of Vite project fail


Our frontend project based on Vite is running in the backend with Docker. During release, Podman runs automated npm install and npm run build commands.

Recently, the Podman builds fail. One of the 3rd party scripts (html2pdf.js / jspdf) is transpiled wrongly.

Original from jspdf.es.js:

case 0:
case false:
case "fill":

When we build it locally it's something like:

switch(P){case 0:case!1:case"fill":

But Podman compiles it to:

switch(P){case 0:casefalse:case"fill":

... which crashes with an error message from vite:esbuild-transpile.

On our local machines we tried different Node versions and switched between npm and yarn but could not reproduce this error. With Podman, we didn't get a single proper build -- not even with older code versions that used to work.

Any ideas how we can change Podman's build options? Or just use the precompiled html2pdf.min.js that comes with the node module?


Solution

  • The issue lies with the Rollup package, which is used internally by Vite for bundling.

    To fix it, you can update the Rollup package to a specific working version.

    For NPM:

    "overrides": {
        "rollup": "4.29.2"
      },
    

    For Yarn:

    "resolutions": {
      "rollup": "4.29.2"
    }
    

    This worked for me.

    For more details, you can refer to the related issue on the Rollup GitHub repository: enter link description here