JezerM / nody-greeter

LightDM greeter that allows to create wonderful themes with web technologies. Made in Node.js
https://web-greeter-page.vercel.app
GNU General Public License v3.0
125 stars 8 forks source link

got 3 error when running #7

Closed ekoputrapratama closed 2 years ago

ekoputrapratama commented 2 years ago

i got 3 error in preloader.ts, i can't give you the error message but i can point out what is the cause.

first thing is you need to remember that preload script in electron is running in renderer process not in main process, but your tsconfig tell otherwise. you need to change the way you access global variable

first error appear here https://github.com/JezerM/nody-greeter/blob/b49016991ac5ed9b61555dccfd2e4b59a698348a/ts/preload.ts#L747

this _ready_event won't work because after being compiled it will use the wrong global variable.

if you see the compiled version it would be like below

window.addEventListener("DOMContentLoaded", () => {
    setTimeout(() => {
        window.dispatchEvent(exports._ready_event);
    }, 2);
});

it reference to a wrong global variable exports instead of globalThis, global or window. this is caused by your tsconfig moduleResolution that tells the typescript compiler to assume that it was a node module

the same apply with 2 other error https://github.com/JezerM/nody-greeter/blob/b49016991ac5ed9b61555dccfd2e4b59a698348a/ts/preload.ts#L682

https://github.com/JezerM/nody-greeter/blob/b49016991ac5ed9b61555dccfd2e4b59a698348a/ts/preload.ts#L713

JezerM commented 2 years ago

I understand your point, and I'll fix it, but... could you provide the error logs? It would be very helpful~