title: Unexpected token import on Electron app
body: <p>I have built an app using GitHub's Electron.  I am using the recommended way of loading modules, the ES6 syntax of:</p>
  
  <p><code>import os from 'os'</code></p>
  
  <p>After downloading the <a href="https://github.com/szwacz/electron-boilerplate" rel="nofollow">boilerplate</a> the app is working fine.  I have been able to import scripts in the <code>background.js</code> file without issue.  Below is how I am loading my custom module:</p>
  
  <p><code>import { loadDb } from './assets/scripts/database.js';</code></p>
  
  <p>However, when I open a new browser window (<code>clipboard.html</code>) within Electron I am then loading a JavaScript file (<code>clipboard.js</code>) which in turn tries to <code>import</code> modules.  At this point I am getting an <code>Unexpected token import</code> error.</p>
  
  <p>My <code>clipboard.html</code>:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Electron Boilerplate&lt;/title&gt;
  
      &lt;link href="./stylesheets/main.css" rel="stylesheet" type="text/css"&gt;
  
      &lt;script&gt;
          window.$ = window.jQuery = require('./assets/scripts/jquery-1.12.1.min.js');
      &lt;/script&gt;
      &lt;script src="./assets/scripts/clipboard.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body class="clipboard"&gt;[...]&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>My <code>clipboard.js</code> file:</p>
  
  <pre><code>import { remote } from 'electron'; // native electron module
  import { loadDb } from './assets/scripts/database.js';
  
  const electron = require('electron');
  
  document.addEventListener('DOMContentLoaded', function () { 
      var db = loadDb();
      db.find({ type: 'text/plain' }, function (err, docs) {
          var docsjson = JSON.stringify(docs);
          console.log(docsjson);
      });
  });
  </code></pre>
  
  <p>Just to re-iterate, the same code is used within <code>app.html</code>, which is my app's main window, and this does not error.</p>
  
  <p>It feels like the main window is initialising something that my <code>clipboard.html</code> window isn't (perhaps 'Rollup'?), but there's nothing explicit within my app's code to suggest this.</p>