In an extglob, !(.min) can match everything but .min (and anything that contains a /); that includes the empty string!
When you test foo/bar/baz/test.min.js with the glob foo/bar/**/*!(.min).js you get a hit because:
- foo/bar/matches- foo/bar/
- **/matches- bar/
- *matches- test.min
- !(.min)matches the empty string
- .jsmatches- .js
The meaning that you want from !(.min) is in fact "anything that doesn't end with .min", which is the negation of *.min, so use !(*.min) to fix the issue:
foo/bar/**/!(*.min).js