Git Product home page Git Product logo

Comments (31)

aldendaniels avatar aldendaniels commented on May 28, 2024 78

@ArnaudRinquin - Ran into this same issue. It's a gulp issue I think. There's a good explanation in gulpjs/gulp#259. The following worked for me:

  return gulp.src('webclient/index.js')
    .pipe(gulpWebpack(webpackConfig, webpack))
    .on('error', function handleError() {
      this.emit('end'); // Recover from errors
    })
    .pipe(gulp.dest('webclient-dist/static'));

from webpack-stream.

shama avatar shama commented on May 28, 2024 20

I'm not sure. I don't use plumber or the watch option with webpack.

from webpack-stream.

alexbassy avatar alexbassy commented on May 28, 2024 17

I have the same problem as @krzysieki

-> Save, webpack compiles fine
-> Save with a syntax error, webpack outputs error, "Cannot find module" error in browser
-> Fix error, save, webpack says it's compiled fine, but file is not updated and missing module error persists

So basically the watch works fine as long as I never save with an error. If I do, I have to relaunch the gulp script.

from webpack-stream.

aldendaniels avatar aldendaniels commented on May 28, 2024 8

@shama - You might want to consider re-opening this as a documentation issue. Anyone using the watch option will need an .on('error', ...) handler.

from webpack-stream.

B3none avatar B3none commented on May 28, 2024 7
return gulp.src(paths.scripts.src, {sourcemaps: true})
    .pipe(
      webpack(webpackConfig)
        .on('error', (err) => {
          console.log(err.message);
          this.emit('end'); // Recover from errors
        })
    );

from webpack-stream.

TSMMark avatar TSMMark commented on May 28, 2024 6

#126 did not help me. Exact same problem: files are never written after an error.

from webpack-stream.

CezaryDanielNowak avatar CezaryDanielNowak commented on May 28, 2024 5

I fixed it by changing:

  gulp.src('app.js')
  .pipe(webpack(webpackConfig, webpackSync, webpackCallback))
  .on('error', (err) => {
    gutil.log('WEBPACK ERROR', err);
  })
  .pipe(gulp.dest('dest/'));

into:

  gulp.src('app.js')
  .pipe(
    webpack(webpackConfig, webpackSync, webpackCallback)
    .on('error', (err) => {
      gutil.log('WEBPACK ERROR', err);
    })
  )
  .pipe(gulp.dest('dest/'));

from webpack-stream.

gregorskii avatar gregorskii commented on May 28, 2024 5

+1 to @CezaryDanielNowak using .on right after the webpack-stream will allow the error to trigger but resume the watch process. Just make sure you emit and end from the catch:

gulp.task('webpack', () => {

    return gulp.src(config.webpack.paths)
        .pipe(plugins.vinylNamed())
        .pipe(plugins.webpackStream(webpackConfig))
        .on('error', function(error) {
            plugins.util.log(plugins.util.colors.red(error.message));
            this.emit('end');
        })       
        .pipe(gulp.dest(config.dist + '/scripts'))
    ;
});

note the use of a normal function there, its to keep scope on this when running this.emit('end') using an arrow function in the .on('error') callback will break the scope of this due to lexical scoping.

from webpack-stream.

jeffijoe avatar jeffijoe commented on May 28, 2024 4

I have the same problem.

from webpack-stream.

nidu avatar nidu commented on May 28, 2024 4

@aldendaniels is everything ok after recovering? For me gulp is recovering well, watches and compiles files (judging by logs) but doesn't overwrite result files.

from webpack-stream.

shama avatar shama commented on May 28, 2024 3

Closing as I don't think this is an issue with this task. If it is, let me know when an example that reproduces. Thanks!

from webpack-stream.

shama avatar shama commented on May 28, 2024 2

If it is, let me know when an example that reproduces. Thanks!

from webpack-stream.

krzysieki avatar krzysieki commented on May 28, 2024 1

Really annoying issue. I knew that some time ago there was no such a problem and after some research found that in [email protected] it is working correctly.

So for me downgrading resolved issue and [email protected] compiles typescript and does not crash on errors, but it is sad that newer versions cant handle errors correctly

from webpack-stream.

jeffijoe avatar jeffijoe commented on May 28, 2024

I found that I had bail:true, setting it to false fixed it. Atleast for syntax errors.

from webpack-stream.

aldendaniels avatar aldendaniels commented on May 28, 2024

@nidu - sorry for not getting back. I'm no longer using webpack-stream, but as I recall everything worked well so long as an .on('error', ...) handler was specified.

from webpack-stream.

gkiely avatar gkiely commented on May 28, 2024

For anyone looking at patching this, the issue seems to be on line:117 in index.js

Replacing
self.emit('error', new gutil.PluginError('webpack-stream', errorMessage));
with
console.error(errorMessage, "\x07");

Seems to fix it but i'm sure there is a better approach.

from webpack-stream.

kmck avatar kmck commented on May 28, 2024

I'm having this problem as well. Working around it with .on(error, function() { ... }) for now, but out-of-the-box compatibility with plumber would be way nicer.

from webpack-stream.

krzysieki avatar krzysieki commented on May 28, 2024

After some debugging it seems that, in my setup, problem is not caused by #115 but it occurs because webpack-stream calls:

self.emit('error', new gutil.PluginError ...

two times.

After changing second "self.emit('error', new ..... " to simple log(errorMessage) everything works ok.

I suppose that error should be emitted once.

from webpack-stream.

TomaszScisloGS avatar TomaszScisloGS commented on May 28, 2024

I'm facing the same issue. Is there any other solution than downgrade to 2.1.1?

from webpack-stream.

zaqqaz avatar zaqqaz commented on May 28, 2024

Also had problem with this. (#18 (comment))

Think, not necessary emit error in watch mode.

Code below NOT working in my case, watch stiil work ok, webpack also, but pipes below(like uglify and dest) not.

.pipe(plugins.webpackStream(webpackConfig))
 .on('error', function(error) {
            plugins.util.log(plugins.util.colors.red(error.message));
            this.emit('end');
        })       

from webpack-stream.

headfire94 avatar headfire94 commented on May 28, 2024

I'm facing the same issue

from webpack-stream.

girishla avatar girishla commented on May 28, 2024

Same issue here

from webpack-stream.

nicholasrq avatar nicholasrq commented on May 28, 2024

@gregorskii works like a charm for me

from webpack-stream.

krzysieki avatar krzysieki commented on May 28, 2024

On my setup @gregorskii 's code is still not working.

@nicholasrq:

  • try to write some code with error
  • browser refreshes and in console we have our error
  • try to fix that error
  • browser refreshes, but wait - error still exists, code was not refreshed

So webpack-stream didnt crash but it didnt refresh code too

from webpack-stream.

DmitryMasley avatar DmitryMasley commented on May 28, 2024

@krzysieki the same problem for me.

from webpack-stream.

Munsen avatar Munsen commented on May 28, 2024

I have same problem
I solved this problem like this:

webpack-stream/index.js:131

    var compiler = webpack(config, function (err, stats) {
      if (err) {
        if (this.watcher) this.watcher.close();
        self.emit('error', new gutil.PluginError('webpack-stream', err));
      }
      var jsonStats = stats.toJson() || {};
      var errors = jsonStats.errors || [];

gulpfiles.js

function webpackError() {
  this.emit('end');
}

var stream = webpackStream(webpackConfig);
gulp.task('webpack', (f) => {
  return gulp.src(assets_path)
    .pipe(named((f) => {
      var match = /(.+)\.(.+)$/.exec(f.relative);
      return match[1];
    }))
    .pipe(stream)
    .on('error', webpackError)
    .pipe(gulp.dest(assets_output));
});

gulp.watch(assets_path, ['webpack']);

It just stop watch and rerun pipe if it broken.

I think webpack-stream should be not break pipe in watch mode. so above code is temporary solution.

from webpack-stream.

ennovum avatar ennovum commented on May 28, 2024

+1

from webpack-stream.

jeroennoten avatar jeroennoten commented on May 28, 2024

With a little help of @gkiely's comment, I found the root of the problem:

To solve this issue, webpack-stream should not emit an error event on compilation error. At least not when watching. PR #126 should solve this.

from webpack-stream.

kmck avatar kmck commented on May 28, 2024

I just tested the patch in #126 and it takes care of the issue while running the watcher nicely!

@shama could you please merge it and update the npm package?

from webpack-stream.

justinmchase avatar justinmchase commented on May 28, 2024

@TSMMark How could the files be written if there was an error? You have to have a successful parse to be able to emit a file.

What you want is for the watch to not be broken when you have a parse error, but to instead see the error in console output. Then you fix the error, and the following compilation will be successful and the file will be written.

from webpack-stream.

TSMMark avatar TSMMark commented on May 28, 2024

I meant subsequent builds in my watch task. If it errored one time I would have to terminate the watch and start it over.

To fix use "webpack-stream": "github:jeroennoten/webpack-stream#patch-1"

from webpack-stream.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.