-
Notifications
You must be signed in to change notification settings - Fork 110
Watching reliability, async build support, npm start #95
Conversation
parallelize gulp build step
'./', relative to the process root, and with backslashes converted to forward slashes. This works around some limitations in gulp.watch(). Detect new and deleted files as well. Make the reload functions use callbacks, as their tasks were sometimes not completing. Organize and report file watching groups to promote user confidence in the intent of the watcher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Geoff - check out my comments. Are you seeing this on a Mac?
package.json
Outdated
@@ -24,6 +25,7 @@ | |||
"bugs": "https://github.com/pattern-lab/edition-node-gulp/issues", | |||
"author": "Brian Muenzenmeyer", | |||
"scripts": { | |||
"start": "node_modules/gulp/bin/gulp.js patternlab:serve", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm start
nor npm run start
is not working for me
$ npm run start
> edition-node-gulp@1.3.4 start C:\src\edition-node-gulp
> node_modules/gulp/bin/gulp.js patternlab:serve
'node_modules' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"
npm ERR! node v4.6.2
npm ERR! npm v2.15.11
npm ERR! code ELIFECYCLE
npm ERR! edition-node-gulp@1.3.4 start: `node_modules/gulp/bin/gulp.js patternlab:serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the edition-node-gulp@1.3.4 start script 'node_modules/gulp/bin/gulp.js patternlab:serve'.
npm ERR! This is most likely a problem with the edition-node-gulp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node_modules/gulp/bin/gulp.js patternlab:serve
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs edition-node-gulp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls edition-node-gulp
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\src\edition-node-gulp\npm-debug.log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just learned that NPM creates aliases for all project-local executables in node_modules/.bin, and puts that in the the PATH environment variable when you run NPM scripts. Therefore, I think we don't need the full path to the local executable, which is what I think is breaking this on Windows.
gulpfile.js
Outdated
]; | ||
|
||
for (const watcher of watchers) { | ||
console.log('\n' + chalk.bold('Watching ' + watcher.name + ':')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be emitting a couple times for css
...
[05:17:00] Finished 'build' after 8.54 s
[05:17:00] Finished 'patternlab:build' after 9.18 s
[05:17:00] Starting 'patternlab:connect'...
[05:17:00] Starting '<anonymous>'...
[BS] Access URLs:
--------------------------------------
Local: http://localhost:3000
External: http://192.168.0.108:3000
--------------------------------------
UI: http://localhost:3001
UI External: http://192.168.0.108:3001
--------------------------------------
[BS] Serving files from: public
[05:17:01] Finished '<anonymous>' after 973 ms
[05:17:01] Finished 'patternlab:connect' after 974 ms
[05:17:01] Starting 'watch'...
Watching CSS:
source/css/**/*.css
Watching CSS:
source/css/**/*.css
Watching CSS:
source/css/**/*.css
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note...
gulp patternlab:serve
does work beautifully, however
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is bizarre. I don't see any of this on the Mac. I'll look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @bmuenzenmeyer -- what Node version are you running?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha! I have been misled as to the Node 4 compatibility of for...of
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd have to look at my home rig again, but i thought it was at least 6?
@bmuenzenmeyer I have potential fixes for both issues. Thanks for the testing! |
@geoffp Do you know why for..of broke on v4? |
Likely that the console.log inside broke it … nodejs/node#5720 |
Oh wow...that's a good find @raphaelokon. I had no idea why it was behaving so strangely, I just naively switched to Node 4 to test, saw breakage and with some disappointment, backed out of using for...of. |
Cheers. I was curious why it did break because I used |
working! |
This adds support for the ongoing async build work in the PL / Node core, and should fix #82. Includes changes from #92.
I also recently ran into some major file watching reliability issues on Mac and Linux during a deployment of a fresh Pattern Lab instance. In one case, the reload() tasks would never complete, leaving the watcher dead after the first reload. In all cases, new and deleted files were not detected. So I decided to fix up file watching and see if I could get it rock solid.
In research, I discovered that gulp.watch() is (or has been historically) sensitive to paths beginning with
./
, and may not work with absolute paths! I tried normalizing all paths to relative before feeding them into the watchers, and now they seem much happier. Just using the watcher callback, instead of catching the 'change' event on the stream also picks up new and deleted files.With this change set, we have:
node_modules/gulp/bin/gulp.js patternlab:serve
, making global gulp-cli optionalThis seems to work very reliably for on Linux with Node 6.9. I'm going to test on Mac OS tomorrow. It could use a review and a Windows test as well.
Feedback is welcome as always, and I apologize if I've stepped on any toes.