Skip to content

Conversation

@davidfirst
Copy link
Member

When webpack-dev-server's static directory watcher is enabled but the directory doesn't exist (which is typically the case), Chokidar recursively walks up the directory tree to find an existing parent to watch. This causes it to watch the entire workspace root directory, triggering unnecessary file system events on every file change.

Investigation findings:

  • Static directories like preview/teambit.harmony/node/public don't exist
  • When watching non-existent paths, Chokidar adds parent directories recursively
  • This results in watching the entire workspace root (/tmp/workspace)
  • Every file change in the workspace triggers the static watcher callback

Changes:

  • Disable watch: true in both webpack dev configs (webpack/config/webpack.dev.config.ts and ui-foundation/ui/webpack/webpack.dev.config.ts)

Static files rarely change during development, and if they do, a server restart is acceptable.

…tire workspace

When Chokidar watches a non-existent path, it recursively walks up the directory tree
to find an existing parent directory to watch. Since the static public directories
typically don't exist, this causes Chokidar to watch the entire workspace root,
triggering unnecessary file system events on every file change.
Copilot AI review requested due to automatic review settings December 5, 2025 21:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a performance issue where webpack-dev-server's static directory watcher would inadvertently watch the entire workspace root when the configured static directory doesn't exist, causing unnecessary file system events and resource waste.

  • Disables static directory watching in webpack dev server configurations
  • Adds clear documentation explaining the rationale for the change
  • Prevents Chokidar from recursively watching parent directories when target paths don't exist

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
scopes/webpack/webpack/config/webpack.dev.config.ts Disabled static directory watching and added explanatory comment about the Chokidar behavior
scopes/ui-foundation/ui/webpack/webpack.dev.config.ts Disabled static directory watching and added explanatory comment about the Chokidar behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@davidfirst davidfirst merged commit c8eea20 into master Dec 11, 2025
12 checks passed
@davidfirst davidfirst deleted the fix/disable-static-watcher branch December 11, 2025 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants