Using ReScript with Electron?

Is anybody using ReScript in electron, or anything similar? Any code out there?

Thanks!

Found one by @ryyppy here on github

2 Likes

Yeah that one is still in Reason syntax because it was material for an old workshop I did a year ago.

There’s nothing special going on when doing Electron… you are still writing your typical one-off bindings with the ReScript interop layer. The React stuff stays pretty much the same, as with any React codebase.

Think about how you’d do it in JS, and then translate it into idiomatic ReScript bindings.

2 Likes

Understood, but it’s still very helpful to have a concrete example of working code to cut short the process, so thanks.

You can primarily feed off of the reason syntax and implement it in a ReScript format. Some things will carry over and some things you will have to mess around with. If you end up creating a usable ReScript Electron template, it would be great to see @rewrangler :slightly_smiling_face:

I’m planning an article on rescript with electron, but I don’t have an ETA yet.

2 Likes

Based off my previous template, I also implemented a basic app with a few views:

Quick update: The simple-wallet-prototype posted above is now upgraded to the newest rescript / @rescript/react version.

3 Likes

I made an alternative repo here:

The main problem I found with other setup instructions were the lack of a Content-Security-Policy; and that setting nodeIntegration: true and contextIsolation: false opens some pretty big security flaws in Electron.

Those security settings might not be important if you are not taking user input or using 3rd party remote calls, but it would still be best practice in electron to use them.

I also wrote about this here:
https://eitherorelse.com/rescript/how-to-setup-electron-with-rescript

3 Likes