title: Dynamic module import in Ember CLI
body: <p>I have a bunch of modules defined in an Ember CLI app and each starts with the same path. I would like to import the modules into a module in the app. For example, I could write:</p>
  
  <pre><code>import post1 from 'posts/1';
  import post2 from 'posts/2';
  import post3 from 'posts/3';
  
  export default Em.ObjectController.extend({
    posts: Em.A(post1, post2, post3),
  });
  </code></pre>
  
  <p>However, I do not know the module names because they are created/named on the fly by a precompiler. All I know is that the path always begins with the same string. In this case, <code>posts</code>.</p>
  
  <p>Is there a way to import all modules that begin with a particular path? For example, how can I do <em>something</em> like the following:</p>
  
  <pre><code>import posts from 'posts/*';
  
  // or
  
  registry['posts'].forEach(postId, i) {
    var path = 'posts/' + postId;
  
    import i from path;
  }
  </code></pre>
  
  <p>Each of the modules I want to find and import has exported an object.</p>
  
  <p>I have been through the <a href="https://github.com/esnext/es6-module-transpiler" rel="nofollow">ES6 module transpiler</a> docs but can't find much.</p>