jonkemp / gulp-useref

Parse build blocks in HTML files to replace references to non-optimized scripts or stylesheets.
MIT License
705 stars 93 forks source link

TypeError: _end is not a function #214

Closed angusfretwell closed 7 years ago

angusfretwell commented 7 years ago

Hi, just started getting this after going from 3.1.0 to 3.1.1 (very confusing since I had it working locally then build failed on Heroku... that'll teach me for not shrinkwrapping). Tried on node v5.4.1 and v6.5.0.

/Users/angusfretwell/Sites/redacted/node_modules/gulp-useref/lib/end.js:14
            return _end();
                   ^

TypeError: _end is not a function
    at Object.fn (/Users/angusfretwell/Sites/redacted/node_modules/gulp-useref/lib/end.js:14:20)
    at DestroyableTransform.<anonymous> (/Users/angusfretwell/Sites/redacted/node_modules/gulp-useref/index.js:101:21)
    at emitNone (events.js:85:20)
    at DestroyableTransform.emit (events.js:179:7)
    at finishMaybe (/Users/angusfretwell/Sites/redacted/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:475:14)
    at endWritable (/Users/angusfretwell/Sites/redacted/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:485:3)
    at DestroyableTransform.Writable.end (/Users/angusfretwell/Sites/redacted/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:455:41)
    at DestroyableTransform.onend (/Users/angusfretwell/Sites/redacted/node_modules/gulp-concat/node_modules/readable-stream/lib/_stream_readable.js:523:10)
    at DestroyableTransform.g (events.js:273:16)
    at emitNone (events.js:85:20)
    at DestroyableTransform.emit (events.js:179:7)
    at /Users/angusfretwell/Sites/redacted/node_modules/gulp-concat/node_modules/readable-stream/lib/_stream_readable.js:965:16
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

The part of my Gulpfile using this is (the .twig files are essentially HTML, was working fine previously):

gulp.task('html', ['styles', 'scripts'], () =>
  gulp.src('app/templates/**/*.twig')
    .pipe(useref({ searchPath: ['public'], base: 'public' }))
    .pipe(gulpif('*.js', uglify()))
    .pipe(gulpif('*.css', cssnano()))
    .pipe(gulp.dest('public/templates'))
);

Please let me know if you can't reproduce and I'll put something together.

jonkemp commented 7 years ago

Yep. I am aware of the issue. My apologies. The workaround for now is go back to 3.1.0 See below.

jonkemp commented 7 years ago

Fixed with version 3.1.2. Apologies for breaking things.

angusfretwell commented 7 years ago

@jonkemp Thanks for fixing this up so quickly! No worries about breaking things, easy workaround.

Thanks for this plugin by the way, I use it heaps!

jonkemp commented 7 years ago

Yeah, I've had these changes in the repo for a few months but not published to npm. I guess because the tests weren't passing! Well, I tested this on a VM before publishing today and everything was good. I didn't realize that it had Node version 4.x! So right after I published it, I happened to test against 5 and 6 on two other machines and saw that it was actually broken. I was able to quickly fix the issue, so hopefully it didn't affect too many people.

Glad it helps you! Thanks!