coolblue2000
coolblue2000

Reputation: 4928

Can I move an Angular app from Electron to Browser?

I have an angular app currently in Electron. (It was built by someone else) I would like to run this in my browser (possibly converting it to a Progressive Web App). Is this possible? If so how?

Upvotes: 4

Views: 119

Answers (1)

GrahamMc
GrahamMc

Reputation: 3124

A short summary from some of my own experience doing something similar. In my case it was possible but this might not always be true. Hope this helps.

Find and assess the app's dependencies on the Electron api - try searching for require('electron') or more likely in Angular, ngxElectron or another Angular Electron api wrapper, fixing or changing the app so that it no longer depends on Electron.

Do a search for Electron API keywords and usages and decide how to handle them. Examples where the app might use Electron - the Electron menu, clipboard, BrowserView, or more behind-the-scenes the app might use IPC.

The app might reference the Node api since Node is relatively easy to mix in to your app in Electron, and this will be a problem that needs to be fixed. Search for Node api references.

Some apps have native dependencies outside of Electron, you'll need to find any such API's and decide how to handle them.

The size of work (and even if it's possible at all) will depend on the functionality the app itself provides and the extent of native features required, the extent of dependency on Electron features, dependencies on Node.

For example, within Electron, developers have more control over the browser than usual, and can choose to switch off normal web security features. Cross site scripting (CORS, etc) or other security issues might crop up when you move the app to the browser. Take a look at the options passed when BrowserWindows are created. If the app has exotic settings these might necessitate architecture changes.

You need to decide whether the app still needs to work in Electron after porting (this might be possible but can make things complicated)

If the app should still run in Electron, you'll need to decide a strategy for how to handle this (for example, if statements checking for Electron, or another strategy).

Upvotes: 2

Related Questions