I just set up a project with electron-vite, that sets everything up for you to use modern syntax including import, with the framework of your choice. Maybe that solves your problem?
There were some caveats to getting it up and running with Phaser, see my post here: