How to add a new feature in electron and export it to JS?


#1

Hi all,

I found there is no documentation analysis the c++ codes of electron. For example, i want to add a new module mymodule and export it to JS. The module will work as dialog that exported by electron default. What should i do?


#2

You should use the native node-module system for that: http://electron.atom.io/docs/v0.32.0/tutorial/using-native-node-modules/.


#3

Hi @appelgriebsch
Thanks for the answer.

I am not sure if i catch the idea. By using native node-module, does my codes been built as part of electron? I mean the electron program includes my codes.

Thanks.


#4

Hey,

if you install your node-modules they will be placed within the node_modules/ directory of your app. When you package and ship your app (hint: check out electron-packager) the node_modules/ directory is put into the app folder and you can easily access the native module via:

var module = require('my-module');

#5

Thanks.
If i want to do it in electron source code itself, is there any clue?


#6

Why you would want to do that? I highly recommend to go the “save” way. On the other hand you could fork the GitHub repo of Electron, put in your own stuff and build your own version (check the development section in http://electron.atom.io/docs/v0.32.0/)


#7

I want to protect my app and to learn electron source code too.
Thanks for the link, but the documentation doesn’t say too much about native development.