title: Use ES6 library in Ember-cli project
body: <p>I have a small EmberJS application that uses Ember-Cli. My application has a private ES6 library that is a bower dependency. Basically, what I want is to import the library and use it wherever I want.</p>
  
  <p>If I'm not wrong, I should transpile the library in my <code>brocfile.js</code> and use it afterwards. Unfortunately, I cannot provide too much concrete information but I'll try my best to be the clearer possible. </p>
  
  <p>My external library is named <code>main-lib</code> and is structured the following way (it is working in another project):</p>
  
  <ul>
  <li>bower_components
  <ul>
  <li>main-lib
  <ul>
  <li>api.js</li>
  <li>main.js</li>
  <li>message.js</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>In the main.js file, I have the following:</p>
  
  <pre><code>import Api from 'main/api';
  import Message from 'main/message';
  
  var main = {};
  
  main.api = Api;
  main.message = Message;
  
  export default main;
  </code></pre>
  
  <p>So, what I want to do, is, in my application, to import <code>main</code> and use the different functions it contains.</p>
  
  <p>Example, in a certain emberjs controller:</p>
  
  <pre><code>import Main from 'main';
  
  //use Main here
  </code></pre>
  
  <p>To do so, I thought of doing the following in my brocfile.js</p>
  
  <pre><code>var tree = 'bower_components/main-lib';
  var ES6Modules = require('broccoli-es6modules');
  var amdFiles = new ES6Modules(tree, {
    format: 'amd',
    bundleOptions: {
      entry: 'main.js',
      name: 'mainLib'
    }
  });
  </code></pre>
  
  <p>However, this does nothing. Basically, I want the transpiled files to be included in <code>vendor.js</code> or somewhere where I would be able to use the library by importing it. </p>
  
  <p>There's something I'm missing here but I can't pinpoint it.</p>
  
  <p><strong>Edit1:</strong> After adding these lines at the end of my brocfile.js:</p>
  
  <pre><code>mergeTrees = require('broccoli-merge-trees')
  
  module.exports = mergeTrees([app.toTree(), amdFiles]);
  </code></pre>
  
  <p>I can get an ES5 that looks like this:</p>
  
  <pre><code>define(['main/api', 'main/message'], function(api, message) {
  
      var main = {};
  
      main.api = Api;
      main.message = Message;
  
      var _main = main;
      return _main;
  });
  </code></pre>
  
  <p>The problem is that it does not import <code>main/api</code> and <code>main/message</code> as well. Do I have to repeat the code for each file that I want ?</p>
  
  <p>Also, the file is not concatenated in <code>vendor.js</code> but simply but at the root of <code>/dist</code></p>