GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add support for watching symlinks that resolve to paths outside the watch folder · Issue #231 · webpack/watchpack

Add support for watching symlinks that resolve to paths outside the watch folder #231

New issue
Copy link
New issue
Copy link
Closed
Closed
Add support for watching symlinks that resolve to paths outside the watch folder#231
Copy link

Description

@bartvandenende-wm
bartvandenende-wm
opened on Dec 19, 2023
Issue body actions

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 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
  1. Create a directory structure like below
./ app
    file1.js
./ src 
    file2.js
    app -> ../app
  1. Watch the ./src directory
  2. 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.

  1. Create a directory structure like below
./ app
    file1.js
./ src 
    file2.js
    app -> ../app
  1. Watch the ./ directory and set an ignore filter to ignore everything except files / folders starting with the path ./src
  2. 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.

How should this be implemented in your opinion?

A potential non-breaking direction is to providing an new option followSymlinksPreservePath that would not use the LinkResolver but instead changes fs.lstat to fs.stat in DirectoryWatcher.js to transparently resolve symlinks and watch nested files without changing the paths:

watchpack/lib/DirectoryWatcher.js

Line 395 in dc690bb

fs.lstat(filePath, (err, stats) => {

Are you willing to work on this yourself?

yes

Reacted by Tee Ming, waynes-labs and Andy Ray

Activity

  1. bartvandenende-wm commented on Dec 19, 2023

    @bartvandenende-wm
    bartvandenende-wm
    on Dec 19, 2023
    Author
    More actions

    find a sample project to demonstrate the issue below:
    https://github.com/bartvandenende-wm/watchpack-directory-symlink-issue

  2. bartvandenende-wm
    changed the title [-]Watchpack does not monitor files within a symlink folder[/-] [+]Watchpack exposes resolved symlink paths on `ignored` option[/+] on Dec 19, 2023
  3. bartvandenende-wm
    changed the title [-]Watchpack exposes resolved symlink paths on `ignored` option[/-] [+]Add support for tracking non-resolved symlink paths[/+] on Dec 19, 2023
  4. bartvandenende-wm
    changed the title [-]Add support for tracking non-resolved symlink paths[/-] [+]Add support for watching symlinks that resolve to paths outside the watch folder[/+] on Dec 19, 2023
  5. bartvandenende-wm commented on Dec 19, 2023

    @bartvandenende-wm
    bartvandenende-wm
    on Dec 19, 2023
    Author
    More actions

    Related issue #190 (comment)

  6. alexander-akait commented on Dec 22, 2023

    @alexander-akait
    alexander-akait
    on Dec 22, 2023
    Member
    More actions

    @bartvandenende-wm Sounds good for me, do you want to send a PR?

  7. ArjhanToteck
    added 2 commits that reference this issue on Mar 7, 2024

    Follow symlinks

    1168d2a

    Follow symlinks

    409ef51
  8. AndrewRayCode
    added a commit that references this issue on May 18, 2025

    Follow symlinks

    26b32cb
  9. alexander-akait
    added 2 commits that reference this issue on Apr 27, 2026

    test: cover both scenarios from issue #231

    4a80231

    fix: guard against ancestor-pointing symlinks in followSymlinks descent

    75358f0
  10. alexander-akait commented on Apr 27, 2026

    @alexander-akait
    alexander-akait
    on Apr 27, 2026
    Member
    More actions

    Fixed

  11. alexander-akait
    closed this as completedon Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.