redhat-developer / podman-desktop-redhat-account-ext

Podman Desktop Red Hat Account Extension
Apache License 2.0
3 stars 9 forks source link

fix: use vite build instead of rollup #147

Closed dgolovin closed 4 months ago

dgolovin commented 4 months ago

fix #65.

Switching to vite for build leads to the error below

Error: Algorithm "sha256"  not supported. supported values: sha1, md5, passthrough
console.<computed> @ VM5:2
(anonymous) @ VM5:2
emit @ VM4 sandbox_bundle:2
onMessage @ VM4 sandbox_bundle:2

It seems vite always assumes the app is going to be running in browser and embeds polyfill for 'crypto' package which supports only digests listed in the message above.

Rollup works fine, except the build.js script is very slow because it packages node_modules folder into .cdix archive. This PR addresses it buy using .extfiles that specifies what to package. The result is a build that works much faster - 3 vs 300 seconds.

benoitf commented 4 months ago

I'm still wondering why we can't use vite we were able to switch all podman desktop extensions to vite

benoitf commented 4 months ago

you're specifying build.target to be node ?

dgolovin commented 4 months ago

you're specifying build.target to be node ?

yes, the same way other extensions does where node version comes from .electron-vendors.cache.json file.

I'm still wondering why we can't use vite we were able to switch all podman desktop extensions to vite

After it built with vite 'crypto' package is loosing sha256 digest and 'openid-client' cannot calculate required digests.

Tried to use polifills, plugins and marking 'crypto' as external and I still get the same message when signing in with RH SSO.

dgolovin commented 4 months ago

@benoitf I figured out why digest is missing, tried different solutions. Making module 'object-hash' external works. See explanation in commit comment.

benoitf commented 4 months ago

awesome 😎