title: ES6 import of electron modules with Vite/Vue fails
body: <p>I am trying to use electron with latest Vite 2/Vue 3. I have setup two versions of electron's main file so I can test and work with both dev server and the build:</p>
  <ul>
  <li>dev version loading the localhost:3000 (from <em>npm run dev</em>) with loadURL</li>
  <li>another version loading the built version (from <em>npm run build</em>)from the <em>dist</em> folder with loadFile</li>
  </ul>
  <p>I have set in the new BrowserWindow options:</p>
  <pre><code>webPreferences: {
     nodeIntegration: true,
     contextIsolation: false,
     enableRemoteModule: true,
     preload: path.join(app.getAppPath(), 'electron.preload.js')
  }
  </code></pre>
  <p>The app starts just fine in Electron in both dev and build version, loads all assets and without any security errors. However, when I try to import any module from 'electron' in my project, in example:</p>
  <pre><code>import electron from 'electron';
  </code></pre>
  <p>I get the error:</p>
  <pre><code>Uncaught TypeError: path.join is not a function
      at node_modules/electron/index.js (index.js:4)
  </code></pre>
  <p>I tried to check <em>path</em> and <em>__dirname</em>, to see if they work in my project:</p>
  <pre><code>import * as path from 'path';
  
  console.log(path);
  console.log(path.join);
  console.log(__dirname);
  </code></pre>
  <p>And these do trace out the following in Electron dev panel:</p>
  <p><a href="https://i.stack.imgur.com/0T53l.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0T53l.jpg" alt="enter image description here" /></a></p>
  <p>If I try to import <em>path</em> differntly:</p>
  <pre><code>import path from 'path'
  console.log(path);
  console.log(path.join);
  </code></pre>
  <p>I get the following result:</p>
  <p><a href="https://i.stack.imgur.com/aSeLY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aSeLY.png" alt="enter image description here" /></a></p>
  <p>In any case, <em>path.join</em> is undefined. And now I am pretty much stuck on how to go on.</p>
  <p>I can also add that I want to use fs-extra, but this also fails:</p>
  <pre><code>import fs from 'fs-extra';
  </code></pre>
  <p><a href="https://i.stack.imgur.com/8Qe59.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Qe59.png" alt="enter image description here" /></a></p>
  <p>[Edit: added the preload in webPreferences]</p>