title: Cannot import file in preload
body: <p>for some reason I cannot import js files in preload.js (electron).
  Error: <code>Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: </code><br>
  preload.js:</p>
  <pre><code>const {ipcRenderer} = require('electron');
  const repo = require(&quot;./lib/test.mjs&quot;)
  
  window.addEventListener('DOMContentLoaded', () =&gt; {
  
  })
  
  </code></pre>
  <p>test.mjs:</p>
  <pre><code>const request = require('request')
  
  class Repository {
      constructor(repoUrl){
          this.repoUrl = repoUrl
          request ({
              url: this.repoUrl,
              json: true
          }, (error, response, body) =&gt;{
              !error &amp;&amp; response.statusCode === 200
                  ? this.repoSettings = body
                  : console.log(error)
          })
      }
  }
  
  module.exports = {Repository}
  </code></pre>
  <p>According to my research, this should work. adding <code>&quot;type&quot;: &quot;module&quot;</code> to package.json only breaks things further.</p>