title: Import and convert JS files using Gulp & Babel
body: <p>Consider the following files:</p>
  
  <pre><code>//foo.js
  (function(){
    console.log('working');
  })();
  
  //bar.js
  import 'foo.js';
  </code></pre>
  
  <p>Now I'm using gulp to compiled from ES6 to ES5. Here's the relevant task:</p>
  
  <pre><code>gulp.task('build-js', function() {
    return gulp.src('bar.js')
      .pipe(babel({
        presets: ['es2015']
      }))
      .pipe(gulp.dest('./dist'));
  });
  </code></pre>
  
  <p>My output file looks like this:</p>
  
  <pre><code>'use strict';
  require('foo.js');
  </code></pre>
  
  <p>The isn't the outcome I expected. I want all code to import into the single output file using the ES5 conversion. This way, the single JS file can be loaded in a browser and run correctly. What do I need to do for the desired outcome?</p>
  
  <p>Since <code>bar.js</code> only imports <code>foo.js</code>, the output file should look exactly like <code>foo.js</code>. Also, since <code>foo.js</code> contains only a self executing function, the output file should execute this immediately and log <code>working</code> to the console.</p>