title: How to import ES6 modules in content script for Chrome Extension
body: <p>In <strong>Chrome 61</strong>, support for modules in JavaScript was added. Right now I am running Chrome 63.</p>
  
  <p>I am trying to use <code>import</code>/<code>export</code> syntax in Chrome extension content script to use modules.</p>
  
  <p>In <strong><code>manifest.json</code></strong>:</p>
  
  <pre><code>"content_scripts": [
      {
          "js": [
              "content.js"
          ],
      }
  ]
  </code></pre>
  
  <p>In <strong><code>my-script.js</code></strong> (same directory as <strong><code>content.js</code></strong>):</p>
  
  <pre><code>'use strict';
  
  const injectFunction = () =&gt; window.alert('hello world');
  
  export default injectFunction;
  </code></pre>
  
  <p>In <strong><code>content.js</code></strong>:</p>
  
  <pre><code>'use strict';
  
  import injectFunction from './my-script.js';
  injectFunction();
  </code></pre>
  
  <p>I receive this error: <strong><code>Uncaught SyntaxError: Unexpected identifier</code></strong></p>
  
  <p>If I change the import syntax to <code>import {injectFunction} from './my-script.js';</code> I get this error: <strong><code>Uncaught SyntaxError: Unexpected token {</code></strong></p>
  
  <p>Is there some issue with using this syntax in <strong><code>content.js</code></strong> in Chrome extension (since in HTML you have to use <code>&lt;script type="module" src="script.js"&gt;</code> syntax), or am I doing something wrong? It seems strange that Google would ignore support for extensions.</p>