Watchpack followSymlinks option always resolves the directory / file paths to final link target. This can create unwanted side-effects if the target is outside of the watched directory and/or if ignored filters.
It would be great to have an option that would transparently follow symlinks without resolving to the target path.
What is the expected behavior?
I would expect the below to work:
Example 1
Create a directory structure like below
./ app
file1.js
./ src
file2.js
app -> ../app
Watch the ./src directory
Trigger changes on both ./src/file2.js and ./src/app/file1.js
Observe that only files in src are monitored, but not files in src/app as Watchpack resolves it to ./app/file1.js.
Changing the watch directory to the project root ./ fixes this, but is not always an option.
Example 2
A similar example can be presented for the ignore filter.
Create a directory structure like below
./ app
file1.js
./ src
file2.js
app -> ../app
Watch the ./ directory and set an ignore filter to ignore everything except files / folders starting with the path ./src
Trigger changes on both ./src/file2.js and ./src/app/file1.js
Observe that only files in src are monitored, but not files in src/app as the Watchpack 'ignored' filter exposes the pathname as the resolved path of ./app/file1.js instead of ./src/app/file1.js
What is motivation or use case for adding/changing the behavior?
Users should be able to use watchpack with symlinks without having to depend on detailed knownledge of the final symlink resolve path.
Feature request
Watchpack
followSymlinks
option always resolves the directory / file paths to final link target. This can create unwanted side-effects if the target is outside of the watched directory and/or ifignored
filters.It would be great to have an option that would transparently follow symlinks without resolving to the target path.
What is the expected behavior?
I would expect the below to work:
Example 1
./src
directory./src/file2.js
and./src/app/file1.js
Observe that only files in
src
are monitored, but not files insrc/app
as Watchpack resolves it to./app/file1.js
.Changing the watch directory to the project root
./
fixes this, but is not always an option.Example 2
A similar example can be presented for the
ignore
filter../
directory and set an ignore filter to ignore everything except files / folders starting with the path./src
./src/file2.js
and./src/app/file1.js
Observe that only files in
src
are monitored, but not files insrc/app
as the Watchpack 'ignored' filter exposes thepathname
as the resolved path of./app/file1.js
instead of./src/app/file1.js
What is motivation or use case for adding/changing the behavior?
Users should be able to use watchpack with symlinks without having to depend on detailed knownledge of the final symlink resolve path.
How should this be implemented in your opinion?
A potential non-breaking direction is to providing an new option
followSymlinksPreservePath
that would not use theLinkResolver
but instead changesfs.lstat
tofs.stat
inDirectoryWatcher.js
to transparently resolve symlinks and watch nested files without changing the paths: https://github.com/webpack/watchpack/blob/dc690bbaea140820f1d9c7c2ec4dff8902798ff9/lib/DirectoryWatcher.js#L395Are you willing to work on this yourself?
yes