const gulp = require('gulp')
const rollupEach = require('../lib')
const rollupBabel = require('rollup-plugin-babel')
const rollupResolve = require('rollup-plugin-node-resolve')
const rollupCommon = require('rollup-plugin-commonjs')
const sourcemaps = require('gulp-sourcemaps')

gulp.task('rollup', () => {
  return gulp.src([
      'src/**/*.js',
      '!src/**/modules/*.js'
    ])
    .pipe(sourcemaps.init())
    .pipe(rollupEach({
      isCache: true,
      plugins: [
        rollupBabel(),
        rollupResolve({
          jsnext: true,
          main: true
        }),
        rollupCommon()
      ]
    }, {
      format: 'iife'
    }))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('dist'))
})

gulp.task('watch', () => gulp.watch('src/**/*.js', ['rollup']))
gulp.task('default', ['rollup'])

@@ -276,35 +276,29 @@
 ')%0A%0A
-gulp.task('rollup', () =%3E %7B
+function scripts() %7B%0A
 %0A  r
@@ -314,18 +314,16 @@
 p.src(%5B%0A
-  
     'src
@@ -337,18 +337,16 @@
 s',%0A    
-  
 '!src/**
@@ -366,23 +366,21 @@
 '%0A  
- 
- 
 %5D)
-%0A    
 .pipe(
+%0A    
 sour
@@ -392,28 +392,31 @@
 s.init()
-)
 %0A  
-  
+)
 .pipe(
+%0A    
 rollupEa
@@ -629,28 +629,31 @@
 '%0A    %7D)
-)
 %0A  
-  
+)
 .pipe(
+%0A    
 sourcema
@@ -666,20 +666,23 @@
 te()
-)
 %0A  
-  
+)
 .pipe(
+%0A    
 gulp
@@ -698,38 +698,38 @@
 st')
-)%0A%7D)%0A%0Agulp.task('
+%0A  )%0A%0A%7D%0A%0Afunction 
 watch
-',
  () 
-=%3E
+%7B%0A 
  gul
@@ -751,27 +751,81 @@
 /*.js', 
-%5B'rollup'%5D)
+scripts)%0A%7D%0A%0Agulp.task('rollup', scripts)%0Agulp.task('watch', watch
 )%0Agulp.t
@@ -843,16 +843,27 @@
 t', 
-%5B
+gulp.series(
 'rollup'
 %5D)%0A
@@ -859,11 +859,11 @@
 'rollup'
-%5D
+)
 )%0A

upgrade to Gulp 4