title: How do I manually parse NodeJS and discern required files
body: <p>What would I use to find which resources are required by a NodeJS file?</p>
  
  <p>For example, if I had a file called "file.js" containing this:</p>
  
  <pre><code>import x from './x';
  const y = require('./y');
  
  // Some more code
  </code></pre>
  
  <p>How do I parse that file and extract './x' and './y'?</p>
  
  <p><strong>Why would you do this?</strong></p>
  
  <p>I'm playing with the idea of an architectural tool. To do this, I want to know which files are being required by the targeted source code.</p>
  
  <p>I know that Webpack follows this information when it creates bundles, so that it can stack the required files in an appropriate order in a single concatenated (well, minified) file.</p>
  
  <p>I don't need to do the concatenation, but I want to find which files would be used.</p>
  
  <p>When I find out which files are being used by which files, I plan to assist a user in organising them in an orderly manner (e.g. by pointing out circular dependencies).</p>