breautek commented on issue #278:
URL: 
https://github.com/apache/cordova-electron/issues/278#issuecomment-2126769632

   electron has 2 processes, a webview process and a nodejs process. In 
Cordova, the NodeJS process is akin to the "native" process seen in other 
platforms. It's only exposed to plugins. Your web app lives in the webview 
process which does not run in a NodeJS environment and therefore doesn't have 
access to the `require` method, like other browser environments.
   
   In order to use NodeJS APIs you will have to create a cordova plugin that 
implements an interface into the NodeJS API. We don't have a guide available at 
this time, but the [device 
plugin](https://github.com/apache/cordova-plugin-device/tree/master/src/electron)
 can be used as an example. The notable files are:
   
   - `/plugin.xml` for to see how things are binded
   - `/src/electron` for the nodejs implementation for the cordova API
   - `/www/device.js` 
(https://github.com/apache/cordova-plugin-device/blob/master/www/device.js#L91) 
which is the webview implementation of the plugin, that calls on the native API.
   
   Note that it's important to restrict access to only what is necessary by the 
webview side. For example, the full ChildProcess/spawn APIs should not be 
exposed to the webview as that can be used as an exploit.
   
   If you have further questions on how to build an electron plugin or 
integrating them, please use [Cordova 
Discussions](https://github.com/apache/cordova/discussions).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to