You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I'm reading the code correctly, it looks like backfill will run and then exit, which is great for production builds.
One use case you might consider is to allow backfill to watch the package directory for changes if it serves up a cached build and then execute the build command so that it can be used with watch scripts. This allows people to use tools like wsrun to launch watchers for many packages in dev mode, but only actually spin up the watcher on either a cache miss or a local change.
I found this approach provided a good balance of performance and developer experience in a project where I wrote some one-off build caching scripts. On the other hand, this may be either a pathological use case or overly complicated.
The text was updated successfully, but these errors were encountered:
Sorry for not replying to your great suggestion! It popped up again in my inbox when you closed the issue.
I think this can be solved with a simple script using backfill APIs.
We've had a similar concern in the past. We didn't have backfill at the time, our concern was more about starting watch processes in 50+ packages at the same time (this was before TS project references). We created a simple tool called sleep-until which would cause the watch process to "sleep" until the package was out of date, by comparing the oldest lib output and comparing it with the newest src. Something like:
const[targetMtime,targetFilename]=findOldest(path.join(process.cwd(),target));constoutdatedSource=findNewer(source,targetMtime);if(outdatedSource){console.log(`Continuing: Found a source file (\`${path.relative(process.cwd(),outdatedSource)}\`) that's newer than the oldest target file \`${path.relative(process.cwd(),targetFilename)}\``);process.exit();}else{console.log(`Sleeping until changes in ${target}.`);fs.watch("src",(_event,filename)=>{console.log("Something changed. Continuing: ",filename);process.exit();});}
You could change the logic here to include a cache check through backfill and then start the watch process as soon as the package is out of date.
The watch script in package.json would be something like:
If I'm reading the code correctly, it looks like
backfill
will run and then exit, which is great for production builds.One use case you might consider is to allow
backfill
to watch the package directory for changes if it serves up a cached build and then execute the build command so that it can be used withwatch
scripts. This allows people to use tools like wsrun to launch watchers for many packages in dev mode, but only actually spin up the watcher on either a cache miss or a local change.I found this approach provided a good balance of performance and developer experience in a project where I wrote some one-off build caching scripts. On the other hand, this may be either a pathological use case or overly complicated.
The text was updated successfully, but these errors were encountered: