tschaub / gulp-newer

Pass through newer source files only
https://npmjs.org/package/gulp-newer
226 stars 24 forks source link

When using gulp-requirejs, getting error "Expected a source file with stats" #29

Open Sawtaytoes opened 8 years ago

Sawtaytoes commented 8 years ago

When I am using gulp-requirejs as my src instead of gulp.src(), I get the error "Expected a source file with stats". Originally thought this is because the file didn't exist, but it looks like it might be something weird about how gulp-requirejs() puts files through the stream.

package.json

"gulp-requirejs": "^0.1.3",

gulpfile.js

rjs({
    baseUrl: baseDir,
    name: moduleMain,
    out: outputFile,
    paths: {'Scripts': 'empty:'},
    insertRequire: views,
    include: views,
    inlineText: true,
    excludeShallow: ['text']
})
.pipe(newer(baseDir + moduleMain + '/' + outputFile))
.pipe(gulp.dest(outputDir))
AntonioRedondo commented 7 years ago

The same issue happens when using Browserify:

gulp.task('buildJs', () => {
    return browserify({
        entries: `${SRC}/react/index.jsx`
    }).bundle()
        .pipe(newer(`${DEST}/bundle.js`))
        .pipe(vinylSource('bundle.js'))
        .pipe(gulp.dest(DEST));
});

If I remove .pipe(newer(`${DEST}/bundle.js`)) the Gulp task works as usual.

AntonioRedondo commented 7 years ago

OK, I just saw this: https://github.com/tschaub/gulp-newer/issues/42. For those who want to use newer with Browserify newer's author recommends to use Watchify instead.

matteusbarbosa commented 5 years ago

Guys for me the case ended with a different approach

install node latest version *install the updated node-sass (if you use it) install gulp-changed and discard gulp-newer for the moment

after doing these 3 steps I got my tasks working again