Fix watching relative dirs in @swc/cli
due to change in chokidar@v4
#82
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.
When watching on
--out-dir
,@swc/cli
would compile the sources when a relative path was passed, but watching would immediately exit instead of watch for changes.Chokidar version 4.x removes globbing support, which means that it does not recursively watch unresolved relative paths with either globbing or cwd. The documentation recommends resolving the glob(s) before passing to
watch
, and has some examples.Weighing the options, it appeared to be more ergonomic to use
globSources
to resolve the files to watch rather than create a new method of globbing or directly glob the files. This pull request makes a very small change to the parameters ofwatchSources
, as I could not cause the error to occur on individual files and wanted to leave that signature alone. However, when watching on--out-dir
, watching would immediately exit as a relative file did not exist and was not being resolved via globbing anymore.This restores the ability to pass relative paths and globs to the
swc
command of@swc/cli
and successfully watch for changes of the source files.