feat(compiler): improve file watching architecture and add external d…#6279
Merged
christian-bromann merged 3 commits intomainfrom Jun 10, 2025
Merged
feat(compiler): improve file watching architecture and add external d…#6279christian-bromann merged 3 commits intomainfrom
christian-bromann merged 3 commits intomainfrom
Conversation
…irectory support - Consolidate watchSrcDirectory and watchRootFiles into a single watchFiles function - Add support for watching external directories via new watchExternalDirs config option - Extract file/directory exclusion patterns into reusable constants (EXCLUDE_DIRS, EXCLUDE_EXTENSIONS) - Improve code documentation and comments for better maintainability - Refactor isWatchIgnorePath function for better readability with early returns - Use Promise.all for concurrent file watching setup to improve performance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
fixes: #3151
Currently, the file watching system in Stencil uses separate functions (
watchSrcDirectoryandwatchRootFiles) to handle watching different types of directories. The system only watches the source directory and root directory, with hardcoded exclusion patterns scattered throughout the code. The watch setup is also sequential, which can impact startup performance.What is the new behavior?
This PR refactors the file watching architecture to:
watchSrcDirectoryandwatchRootFileswith a single, more flexiblewatchFilesfunctionwatchExternalDirsconfig option that allows users to specify additional directories to watch (e.g.,node_modulesfor development workflows)EXCLUDE_DIRS,EXCLUDE_EXTENSIONS)Promise.allto set up file watchers concurrently instead of sequentiallyisWatchIgnorePathfunction with early returns for better readabilityDocumentation
The new
watchExternalDirsconfiguration option is documented in the TypeScript interface with JSDoc comments.Does this introduce a breaking change?
This is a non-breaking change. All existing functionality is preserved, and the new
watchExternalDirsoption is optional with a sensible default (empty array).Testing
watchExternalDirsconfiguration option by adding external directoriesOther information
This refactoring lays the groundwork for more flexible file watching configurations and improved developer experience. The new
watchExternalDirsoption will be particularly useful for development workflows that need to watch dependencies or other external directories for changes.A dev build is available at
@stencil/core@4.33.1-dev.1749248891.8108e9b