Merge pull request #8917 from bcomnes/patch-1

Clarify remote require of relative modules
This commit is contained in:
Kevin Sawicki 2017-03-30 12:00:47 -07:00 committed by GitHub
commit 3100463117

View file

@ -141,6 +141,36 @@ The `remote` module has the following methods:
* `module` String * `module` String
Returns `any` - The object returned by `require(module)` in the main process. Returns `any` - The object returned by `require(module)` in the main process.
Modules specified by their relative path will resolve relative to the entrypoint
of the main process.
e.g.
```
project/
├── main
│   ├── foo.js
│   └── index.js
├── package.json
└── renderer
└── index.js
```
```js
// main process: main/index.js
const {app} = require('electron')
app.on('ready', () => { /* ... */ })
```
```js
// some relative module: main/foo.js
module.exports = 'bar'
```
```js
// renderer process: renderer/index.js
const foo = require('electron').remote.require('./foo') // bar
```
### `remote.getCurrentWindow()` ### `remote.getCurrentWindow()`