title: Import a function in a .mjs script
body: <p>Need some help with using a .mjs script and .js as well.</p>
  <p>I have one script.mjs file that looks like this. Simplifying here (the script needs to be .mjs file)</p>
  <pre><code>import test from './test.js';
  
   test();
  </code></pre>
  <p>and test.js looks like this. Again simplifying here but it needs to be .js file:</p>
  <pre><code>const fs = require('fs');
  const path = require('path');
  
  const root = path.join(__dirname, '../../');
  const statsPath = path.join(
      root,
      'somepath',
  );
  
  export function test() {
      const localBuildStat = JSON.parse(
          fs.readFileSync(statsPath, { encoding: 'utf8' }),
      );
  
      
      let assetSizes = {};
      
      const assets = localBuildStat.assets;
      assets.forEach((s) =&gt; {
         // do something here       
         }
      });
  }
  </code></pre>
  <p>when I try to run the script.mjs file, I get this error:</p>
  <p><a href="https://i.stack.imgur.com/oKyCM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oKyCM.png" alt="[![enter image description here][1]][1]
  [1]: https://i.stack.imgur.com/XVdSz.png" /></a></p>
  <p>How do you suggest I fix this to work?
  Thanks in advance</p>