Comments (31)
@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.
I'm not sure. I don't use plumber
or the watch
option with webpack.
from webpack-stream.
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.
@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.
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.
#126 did not help me. Exact same problem: files are never written after an error.
from webpack-stream.
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.
+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.
I have the same problem.
from webpack-stream.
@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.
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.
If it is, let me know when an example that reproduces. Thanks!
from webpack-stream.
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.
I found that I had bail:true
, setting it to false fixed it. Atleast for syntax errors.
from webpack-stream.
@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.
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.
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.
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.
I'm facing the same issue. Is there any other solution than downgrade to 2.1.1?
from webpack-stream.
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.
I'm facing the same issue
from webpack-stream.
Same issue here
from webpack-stream.
@gregorskii works like a charm for me
from webpack-stream.
On my setup @gregorskii 's code is still not working.
- 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.
@krzysieki the same problem for me.
from webpack-stream.
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.
+1
from webpack-stream.
With a little help of @gkiely's comment, I found the root of the problem:
- When a compilation error occurs,
webpack-stream
emits anerror
event.- Node listens for stream
error
events - and removes the
ondata
handler. - Therefore, it stops writing data to the destination after an
error
event has occurred.
To solve this issue, webpack-stream
should not emit an error
event on compilation error. At least not when watch
ing. PR #126 should solve this.
from webpack-stream.
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.
@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.
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)
- DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead HOT 5
- DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead HOT 1
- Support webpack version 5 HOT 2
- Webpack 5 HOT 3
- Using webpack 5 as described in README produces empty output files HOT 1
- Webpack 5 warns about a deprecation in watch mode HOT 4
- Error: Rule can only have one resource source when using webpack-stream HOT 4
- webpack.config entry import syntax support HOT 1
- Slowdown after upgrade to 6.x.x. HOT 4
- Using webpack-5 results in no output files HOT 4
- Question about multiple entry points
- DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH HOT 2
- MODULE_NOT_FOUND error while using version 7.0.0 HOT 2
- [Error] Invalid left-hand side expression in prefix operation HOT 4
- webpack-stream 7.0.0 throws an error: Cannot find module webpack/lib/ProgressPlugin HOT 6
- Did you forget to signal async completion... HOT 5
- Remove the need to manually filter out source map files HOT 4
- Callback in being ignored in the multicompication case
- Webpack 5 Stream won't compile HOT 1
- Webpack stream w/ Gulp — errors when using aliases in webpack config HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpack-stream.