Comments (13)
You should use batching mode, because gulp-tsc start compiling on end
event, which is not emitted in stream mode.
from gulp-watch.
Thanks for getting back to me. I tried the following and its sort of working but not quite (I think this is what the docs has described as batching mode):
gulp.task('watch', [ '...', 'tscompile', '...' ], function() {
tsFiles()
.pipe(watch(function(files) {
return files
.pipe(plumberDefault())
.pipe(tscompileTask())
.pipe(livereload(server));
}));
// I also tried the below and it acted virtually the same
watch({ glob: config.app.ts, name: 'TypeScript' }, function(files) {
return files
.pipe(plumberDefault())
.pipe(tscompileTask())
.pipe(livereload(server));
});
});
Firstly, when the watch task runs, it executes whats in the watch method as if the files have changed. This isn't really expected as I already have the tscompile
as a dependent task.
Additionally, if a change that I make to the file "breaks" the watch(function() { ... })
, even though I'm using plumber
, it doesn't recover fully again. It just does the first part of the task again.
from gulp-watch.
@avanderhoorn look at the option passThrough
and emitOnGlob
for fixing launching at first run.
I don't really understand, what are those tasks in gulp.task('watch', [ '...', 'tscompile', '...' ], function() {
? Watch task (almost always) is main task and don't have dependencies, because they will not be re-executed when watch get file changes.
from gulp-watch.
@floatdrop Thanks again for helping out!
Adding the emitOnGlob
for the first run and I get what you mean about the watch
task having dependencies. I will look into that.
Unfortunately, I'm still having issues of the watcher not working after a failed step. Here is the current log:
//Make a simple change, all works well
[08:19:33] TypeScript saw test3.ts was changed
[08:19:34] Compiling TypeScript files using tsc version 1.0.1.0
[08:19:36] test3.js was reloaded.
[08:19:36] Live reload server listening on: 35729
//Cause error on purpose, stops after the linting
[08:19:46] TypeScript saw test3.ts was changed
(quotemark) test3.ts[4, 11]: " should be '
(semicolon) test3.ts[4, 38]: missing semicolon
(whitespace) test3.ts[5, 1]: missing whitespace
[08:19:46] ERROR: gulp-tslint - Failed to lint: test3.ts.
//Tried making a valid change, but doesn't compile
[08:19:54] TypeScript saw test3.ts was changed
//Tried again making a valid change, but doesn't compile
[08:20:05] TypeScript saw test3.ts was changed
As you can see, the system is detecting that the files have changed, but isn't getting beyond that.
from gulp-watch.
@avanderhoorn could you post your gulpfile as a gist?
from gulp-watch.
Yep its here - https://gist.github.com/avanderhoorn/180a96347bc139359433
from gulp-watch.
Okay. I cleared out gulpfile to contain only typescript compilation: https://gist.github.com/floatdrop/67ef2ea6c5cb291f458a
You are using lazypipe, which is appending its own onError handler, so gulp-plumber will not add another on top of existing one (see this issue), so after tscompileTask is throwing you got broken typescript building.
from gulp-watch.
HUGE thanks for this! So at least I'm not crazy. Have to see what happens with that issue.
from gulp-watch.
@avanderhoorn drop this line instead of gulp-plumber
, it should fix your problem.
from gulp-watch.
@floatdrop Not sure exactly what you mean?
from gulp-watch.
@avanderhoorn I mean you can attach on('error')
handler - https://gist.github.com/floatdrop/b9c7c850d3bc2e4d0a64#file-gulpfile-js-L138 and it will fix rebuilding typescript on exceptions from compiler.
from gulp-watch.
Cool, thanks!
from gulp-watch.
I've also found that if I remove the return this works:
watch({ glob: config.app.ts, emitOnGlob: false, name: 'TypeScript' }, function(files) {
files
.pipe(plumberDefault())
.pipe(tscompileTask())
.pipe(livereload(lrServer));
});
from gulp-watch.
Related Issues (20)
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath
- subfolders no longer updating the main style.scss file
- Watched unexpected filepath
- How to deal with changed files? HOT 2
- watch is not working correctly
- chokidar version 3 HOT 4
- Watched unexpected filepath
- Watched unexpected filepath HOT 1
- please publish the latest version to npm
- chokidar version is too low
- Watched unexpected filepath
- Watched unexpected filepath HOT 1
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath
- Watched unexpected filepath HOT 1
- Security Issue with Gulpwatch, fsevents and Request for Chokidar Version 3 and Fsevents Version 2 Installation 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 gulp-watch.