title: Polymer: Gulp build transpile + bundle
body: <p>I'm struggling to get a working custom build for Polymer using gulp. My goal is to get a Polymer 1 project written in es6 transpiled &amp; bundled. I followed this guide <a href="https://github.com/PolymerElements/generator-polymer-init-custom-build" rel="nofollow noreferrer">https://github.com/PolymerElements/generator-polymer-init-custom-build</a>.</p>
  
  <p>The transpilation works well for single files, but any bundled js code is untranspiled (as written in es6). Here is my gulp task :</p>
  
  <pre><code>function build() {
    return new Promise((resolve, reject) =&gt; { // eslint-disable-line no-unused-vars
      // Okay, so first thing we do is clear the build directory
      console.log(`Deleting ${buildDirectory} directory...`);
      del([buildDirectory])
        .then(() =&gt; {
          // Okay, now let's get your source files
          let sourcesStream = polymerProject.sources()
            // Here's how splitHtml &amp; gulpif work
            .pipe(polymerProject.splitHtml())
            // Transpile
            .pipe($.sourcemaps.init())
            .pipe($.if('*.js', $.babel({
              presets: ['es2015']
            })))
            .pipe($.sourcemaps.write())
            // Oh, well do you want to minify stuff? Go for it!
            .pipe(gulpif(/\.js$/, uglify()))
            .pipe(gulpif(/\.html$/, htmlMinifier()))
            .pipe(gulpif(/\.(png|gif|jpg|svg)$/, imagemin()))
            .pipe(polymerProject.rejoinHtml());
  
          // Okay, now let's do the same to your dependencies
          let dependenciesStream = polymerProject.dependencies()
            // .pipe(polymerProject.bundler)
            .pipe(polymerProject.splitHtml())
            .pipe(gulpif(/\.js$/, uglify()))
            .pipe(gulpif(/\.html$/, htmlMinifier()))
            .pipe(polymerProject.rejoinHtml());
  
          // Okay, now let's merge them into a single build stream
          let buildStream = mergeStream(sourcesStream, dependenciesStream)
            .once('data', () =&gt; {
              console.log('Analyzing build dependencies...');
            });
  
          // #PROBLEM# -&gt; All included sources won't be transpiled
          buildStream = buildStream.pipe(polymerProject.bundler);
  
          // Okay, time to pipe to the build directory
          buildStream = buildStream.pipe(gulp.dest(buildDirectory));
  
          // waitFor the buildStream to complete
          return waitFor(buildStream);
        })
        .then(() =&gt; {
          // Okay, now let's generate the Service Worker
          console.log('Generating the Service Worker...');
          return polymerBuild.addServiceWorker({
            project: polymerProject,
            buildRoot: buildDirectory,
            bundled: true,
            swPrecacheConfig: swPrecacheConfig
          });
        })
        .then(() =&gt; {
          // You did it!
          console.log('Build complete!');
          resolve();
        });
    });
  }
  
  gulp.task('build', build);
  </code></pre>
  
  <p>Thank you for your help.</p>