title: How can I list source folder contents in React or create-react-app?
body: <p>I'm writing a React app using <code>create-react-app</code>.</p>
  
  <p>Since I can do:</p>
  
  <pre><code>import LocalClass from "./localfolder/LocalClass.js"
  </code></pre>
  
  <p>and even (using <a href="https://tc39.es/proposal-dynamic-import/#sec-import-calls" rel="nofollow noreferrer">dynamic import</a>):</p>
  
  <pre><code>import('./localfolder/LocalClass.js').then((module) =&gt; { /* ... */ })
  </code></pre>
  
  <p>is there a way to list <code>localfolder</code> contents, so I can dynamically import the contained files?</p>
  
  <p>The listing should happen at compile or bundling time, not at runtime (I'm thinking about an automatic menu creation feature).</p>
  
  <p>The folder may contain plain classes too (i.e. not React components); I guess this is a matter of the bundler, but I'm not sure.</p>