evanw / esbuild

An extremely fast bundler for the web
https://esbuild.github.io/
MIT License
38.22k stars 1.16k forks source link

glob ** not matching all sub paths #3967

Closed jseparovic closed 2 weeks ago

jseparovic commented 2 weeks ago

On version 0.24.0 I noticed that glob matches aren't working for all subpaths when using /**/

I have to run this instead:

esbuild src/*.ts src/**/*.ts src/**/**/*.ts src/**/**/**/*.ts src/**/**/**/**/*.ts src/**/**/**/**/**/*.ts src/**/**/**/**/**/**/*.ts  --outdir=dist/tsc --format=esm --platform=node
lydell commented 2 weeks ago

It seems like you have run into a thing that is explained in the docs:

https://esbuild.github.io/api/#glob-style-entry-points

If you are using esbuild via the CLI, keep in mind that if you do not quote arguments that contain shell metacharacters before you pass them to esbuild, your shell will likely expand them before esbuild sees them. So if you run esbuild "*.js" (with quotes) then esbuild will see an entry point of *.js and the glob-style entry point rules described above will apply. But if you run esbuild *.js (without quotes) then esbuild will see whatever your current shell decided to expand *.js into (which may include seeing nothing at all if your shell expanded it into nothing). Using esbuild's built-in glob pattern support can be a convenient way to ensure cross-platform consistency by avoiding shell-specific behavior, but it requires you to quote your arguments correctly so that your shell doesn't interpret them.

Your shell probably does not support ** globs (or isn’t configured to), so it treats ** as two * (which only match one level) in a row.

jseparovic commented 2 weeks ago

Yep that was the problem. Thank you. Cheers