porsager / wright

🚀 Work Fast Work Wright
Do What The F*ck You Want To Public License
180 stars 15 forks source link

Option to not using Chokidar watcher and awake on signal #33

Closed jussiarpalahti closed 5 years ago

jussiarpalahti commented 6 years ago

I have been having some issues with file system watchers. On some build systems Wright works just fine, but with Reason's Bucklescript tracking changes fail.

I was wondering if Wright could be signaled to perform reload by sending message or triggering full page reload? This way it would be up to user to set up a way to perform notification with other change trackers.

I realize that this is probably something that could be fixed on Chokidar's side. Unfortunately file system watching is a tricky thing and these sort of bugs keep cropping up. If Wright would support a variety of methods to direct its reload behavior it could help with all sorts of issues.

Thank you for this awesome tool, by the way!

porsager commented 6 years ago

Hi @jussiarpalahti

That seems like a good idea. Are you using the JS API, or command line? It would be easy and make sense to expose the refresh call in the JS API, and perhaps make a config option autoWatch which can be set to false?

jussiarpalahti commented 6 years ago

For my Reason project I went with CLI option. Using JS API would probably be more natural for this.

autoWatch option sounds good.

porsager commented 6 years ago

ok :)

I realize I haven't documented the -e parameter for wright in the general readme yet, which might be just what you need.

It takes a command and a watch glob. So let's say your reason files are inside /src you can do

wright -e "bsb -make-world;src/**/*" index.html

How does your command to start wright currently look?

jussiarpalahti commented 6 years ago

I did actually look at the bin/Readme. I tried to use -w explicitly for all affected files (in this case index.html and one JS file) and without.

One attempt was like this: wright index.html--debug 1 -n foo

Sometimes Wright could see changes and sometimes not. It did report finding the dependencies correctly when debug mode was on. When it worked it worked well. Then it mysteriously didn't see any changes even after restarting all the tools.

The -e switch uses watcher to react on changes and starts the build then, I see. Wouldn't it then run into same kind of trouble with watching files?

porsager commented 6 years ago

That's very odd. I haven't had issues with that on any platform yet.. Only that some are slower to pick up changes than other. What platform were you experiencing these issues on?

jussiarpalahti commented 6 years ago

I'm on MacOS High Sierra, relatively recent install and on its new file system APFS. I haven't had these issues before.

I added fswatch to keep track of the same folder so it might see if anything strange happens. Sometimes files aren't updated but replaced using renames by extra secure editors, and this confuses some watchers. This is a stranger one that it worked, then the machine was sleeping for some time and when I got back to the code it didn't notice changes anymore. Not even after restarts and everything.

Also, my project now has four separate file watchers (plus Fswatch over them all), so I'm contemplating how to get them to react from one only. Bsb checks for Reason code changes, TypeScript does the same for ts files, Webpack is watching JS files for bundling which in turn is served by Wright.

porsager commented 5 years ago

Hi @jussiarpalahti ... Sorry for following up on this issue so late. Would you mind giving wright@next a shot to see how it works? There has been quite a few changes in how wright handles watching.

jussiarpalahti commented 5 years ago

I've been using next release intermittently and haven't seen watcher related problems. I'll go ahead and close this since I can't replicate it anymore.