tomnil / emptyts

A working (empty) TypeScript project
9 stars 4 forks source link

Converting to electron #1

Open fomerbay opened 2 years ago

fomerbay commented 2 years ago

Hello, I am trying to use this ts template to create a desktop app, and I was wondering if it was possible to convert this template to an electron project?

Thank you.

tomnil commented 2 years ago

maybe, but I assume it's much more easy to start with a clean Electron project and then copy the configuration settings and files from this project. I've written a "how to get going with Electron" article here. https://tomasnilsson71.medium.com/electron-react-with-typescript-7decae392b50

fomerbay commented 2 years ago

Hy @tomnil thank you for your kind reply. I was wondering if using the node modules such as sqlite3, fs also possible? You've mentioned in your electron-react-with-typesciprt article however, I've read some stackoverflow saying if window.require was used, it would be possible. What is your opinion on this? Also, thank you for the all your awesome works!

tomnil commented 2 years ago

So Electron is bascially a browser with the limitations that comes with it. You don't have (easy) access to stuff related to the system (such as the filesystem, running files and similar). It can be done though - google "preload.js". There you have the opportunity to do:

const fs = require("fs");
global.myfs=fs

... and then access it within Electron. Tip: think of the security since the web-app will be able to access all objects you expose this way.