esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

Glob pattern /**/ ignores symlinked directories

Open adelespinasse opened this issue 6 months ago • 1 comments

When using a /**/ glob pattern for entry points, symlinked directories seem to be completely ignored.

This is true with or without --preserve-symlinks. The included example uses --preserve-symlinks because it seems more correct: my understanding is it means "treat symlinks as if they were files or directories in the location of the symlink". Without --preserve-symlinks, I'm not sure where the corresponding directory would be created or what its name would be.

Instead, esbuild seems to act as if the symlink is not there. The corresponding directory is not created.

To reproduce

I created a minimal reproduction at https://github.com/adelespinasse/esbuild-glob-symlinks.

npm clone https://github.com/adelespinasse/esbuild-glob-symlinks
cd esbuild-glob-symlinks
npm install
npm run build

The build command will create a new directory called dist/.

Expected behavior

I expected the dist/ directory to have this structure:

  • dist/
    • index.js
    • nested/
      • nested.js
    • linked/
      • linked.js

Actual behavior

Directory dist/linked/ is not created, so the entire directory is:

  • dist/
    • index.js
    • nested/
      • nested.js

adelespinasse avatar Jul 03 '25 17:07 adelespinasse

Thanks for the report. I haven't thought about this case before.

I'm wondering if this should be how it works or not. I can see why this could be useful. However, my shell (zsh) does not follow symlinks when expanding ** glob. It looks like zsh uses *** vs. ** to specify whether to expand symlinks (***) or not (**). Maybe that's how glob within esbuild should work as well.

evanw avatar Aug 25 '25 21:08 evanw