title: import menu to browser window by "require" function
body: <p>I am working on a electron demo by following <a href="https://www.christianengvall.se/electron-menu/" rel="nofollow noreferrer">this tutorial</a>.</p>
  <p>just wondering what happened in the require line of code.</p>
  <p><strong>./menu/mainmenu.js</strong> defines the menu items.</p>
  <pre><code>const {Menu} = require('electron')
  const electron = require('electron')
  const app = electron.app
  
  const template = [
    {
      label: 'Edit',
      submenu: [
        {
          role: 'undo'
        },
        {
          role: 'redo'
        },
        {
          type: 'separator'
        },
        {
          role: 'cut'
        },
        {
          role: 'copy'
        },
        {
          role: 'paste'
        },
        {
          role: 'pasteandmatchstyle'
        },
        {
          role: 'delete'
        },
        {
          role: 'selectall'
        }
      ]
    }
  ]
  
  const menu = Menu.buildFromTemplate(template)
  Menu.setApplicationMenu(menu)
  </code></pre>
  <p><strong>main.js</strong></p>
  <pre><code>const { app, BrowserWindow, ipcMain } = require('electron');
  let win;
  
  function createWindow () {
    win = new BrowserWindow({
      width: 880,
      height: 660,
      webPreferences: {
        nodeIntegration: true
      }
    })
    // and load the index.html of the app.
    win.loadFile('index.html')
  
    require('./menu/mainmenu') //does this line copied the whole mainmenu.js file?
  }
  </code></pre>
  <p>does the <code>require('./menu/mainmenu')</code>  copy whole file into <code>main.js</code>?</p>
  <p>Or imported some modules? In the mainmenu.js file There is no <code>export</code> keyword.</p>
  <p>according to the <a href="https://nodejs.org/en/knowledge/getting-started/what-is-require/" rel="nofollow noreferrer">node.js documentation</a>,</p>
  <p><em>&quot;The basic functionality of require is that it reads a JavaScript file, executes the file, and then proceeds to return the exports object.&quot;</em></p>