size-limit icon indicating copy to clipboard operation
size-limit copied to clipboard

size-limit --watch

Open ai opened this issue 5 years ago • 15 comments
trafficstars

Option to re-run script on any file changes in the project

ai avatar Feb 13 '20 04:02 ai

I started hacking this issue, but I have a question: when user has multiple files for checking is it needed to check the size of the only file/files that have been changed? I have a solution now, but size-limit will always check all files in watch mode. I found hard to make size-limit checking individual files when they have been changed

Windrushfarer avatar Feb 19 '20 06:02 Windrushfarer

is it needed to check the size of the only file/files that have been changed?

It is OK to check all

ai avatar Feb 19 '20 07:02 ai

@ai, is it worth using third party packages like chokidar that enhance fs.watch from standart library or it's preferable to provide zero dependency solution?

terdenan avatar Feb 19 '20 19:02 terdenan

What is the difference?

ai avatar Feb 19 '20 21:02 ai

We either get +1 dependency and don't reinvent workarounds that eliminate fs.watch's problems or do it by our own and don't add extra dependencies to the project.

terdenan avatar Feb 20 '20 06:02 terdenan

What fs.watch problems do we have?

ai avatar Feb 20 '20 06:02 ai

According to docs fs.watch doesn't support recursive watch on Linux (didn't check myself). Some events might be fired multiple times (simply being solved using debounce).

terdenan avatar Feb 20 '20 07:02 terdenan

What is recursive watch?

ai avatar Feb 20 '20 07:02 ai

fs.watch has option recursive, which indicates whether all subdirectories should be watched, or only the current directory

terdenan avatar Feb 20 '20 07:02 terdenan

Yeap, we need recursive watch and Linux support.

What third party libraries do we have and what is the difference between them?

ai avatar Feb 20 '20 07:02 ai

I've briefly examined only 2. I can take a closer look a little bit later. chokidar and watchpack (which webpack uses under the hood). chokidar seems to have more flexibility in terms of configuring performance of the tool: recursion depth and awaitWriteFinish when large files are being written to filesystem watchpack in turn has less dependencies :)

terdenan avatar Feb 20 '20 08:02 terdenan

I think we need more investigating.

ai avatar Feb 20 '20 08:02 ai

https://github.com/inotify-tools/inotify-tools/wiki

iegik avatar Mar 08 '20 10:03 iegik

I've implemented this. Please check https://github.com/jayhoney/size-limit/tree/feature/watch-mode

KisyaLisya avatar Mar 13 '20 18:03 KisyaLisya

@jaydenseric great! Looks good.

Can you send pull request? it has better UI for code review.

ai avatar Mar 13 '20 18:03 ai