Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable --watch Debounce #1061

Open
ObliviousHarmony opened this issue Feb 23, 2024 · 3 comments
Open

Configurable --watch Debounce #1061

ObliviousHarmony opened this issue Feb 23, 2024 · 3 comments

Comments

@ObliviousHarmony
Copy link
Contributor

When using something like webpack --watch in a service it can cause conflicts with Wireit's --watch option. The build tool progressively outputs and can trigger multiple rebuilds successively in downstream packages. We're currently implementing this by using nodemon but that feels like an unnecessary extra step when we have watch support already in wireit.

I noticed that there's currently a debounce implemented in the watcher already with a value of 0 and it would be great if we could set this to a configurable value. Since --watch itself is not a configuration option but is rather an option I think it makes sense to also make this an option. --watch --delay <ms> seems appropriate. Having delay in the package.json doesn't feel like it makes sense since it only applies to --watch.

@deebloo
Copy link

deebloo commented Mar 7, 2024

Isn't this solved by setting cascade to false?

@ObliviousHarmony
Copy link
Contributor Author

ObliviousHarmony commented Mar 7, 2024

In our case, we're using pnpm for task orchestration and wireit for caching. This is preferable to using wireit for both for us as it provides developers with a consistent syntax for running commands via pnpm --filter=<project-name>.

As an example, let's take a look at this configuration in two projects:

project-a/package.json
{
	"wireit": {
		"copy-assets": {
			"command": "rm -rf assets/client && cp -r node_modules/project-b/build assets/client",
			"allowUsuallyExcludedPaths": true,
			"files": [
				"node_modules/project-b/build"
			]
		}
	}
}
project-b/package.json
{
	"wireit": {
		"watch": {
			"command": "webpack --watch",
			"service": true
		}
	}
}

You would also see the same problem with the above configs if you opened two separate terminals and ran npm run watch in one and npm run copy-assets --watch in the other. Due to the debouce of 0 and webpack progressively outputting files, the copy-assets command is triggered multiple times. If we bumped the debounce it would let webpack finish and only run copy-assets once.

@deebloo
Copy link

deebloo commented Mar 8, 2024

Ah ok that makes sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants