Closed baltpeter closed 2 years ago
Setup Electron with TypeScript.
There's a whole bunch of templates that we could use to setup the project (like https://github.com/electron-react-boilerplate/electron-react-boilerplate or https://github.com/electron-userland/electron-webpack) but I much prefer setting up projects myself, to really understand what things are doing and be able to configure it exactly as I want. Also, I really don't want to have to use Webpack. :D
The next choice is for a bundling/packaging/build tool for Electron. The options for that are basically https://github.com/electron-userland/electron-builder and https://github.com/electron-userland/electron-forge. Both offer similar features and seem mature and well supported. Electron Forge seems to lean towards a create-react-app
-like approach, whereas with electron-builder you have to (or can, depending on how you want to frame it :D) configure everything yourself. Also, electron-builder seems to have more features and just seems… nicer to me on first glance. I'll go with that.
What is the recommended way of accessing native functions from the app code these days?
Electron's documentation has actually vastly improved since I wrote my bachelor's thesis and focuses heavily on security these days! The "Processes in Electron" chapter explains the approach we should (and will) use really well. Basically:
contextIsolation
enabled (default).contextBridge
in preload script to expose (heavily guarded) API to the renderer process.I'll even give enabling the sandbox a try. Seems like that is actually viable these days.
I've also gone through the security checklist and implemented everything that applies to us.
Closed in 8a5c9f061d73921a1c939f1772c5b39ba044abf4 and 958ade285f11672d9db0c830ea06f19d3694192a.
I've opted to use Parcel 2 for the build system. The ergonomics of that are truly excellent! I didn't have to do anything and it genuinely just worked. Wow.