A .bazelignore pattern such as
only ignores the node_modules folder at the root level where the .bazelignore file is. This means that in nodejs projects, every single node_modules folder needs to be explicitly listed in .bazelignore.
Not ignoring a node_modules folder can lead to unexpected build errors as these folders contain downloaded npm dependencies that may contain BUILD files that should be ignored. node_modules folders are almost always all untracked and ignored in .gitignore so there are often left around in subdirectories when changing git branches and these are not easily noticed as they are ignored by git.
Have .bazelignore patterns that don't start with / match in any directory. This would match the behavior of .gitignore. For example:
# ignore root /node_modules folder
/node_modules
# ignore all folders named node_modules in the root directory or in subdirectories
node_modules
OSX
bazel info release?release 0.24.0
For reference:
@alexeagle This issue will be a problem for rules_nodejs users after https://github.com/bazelbuild/rules_nodejs/pull/704 lands since every yarn_install & npm_install rule will create a node_modules folder somewhere in the user's WORKSPACE that will be ignored by git by default but not by bazel.
Indeed, this is a problem.
Expected behavior, from working with other tools that have a ".ignore" file, would be that node_modules ignores that dir anywhere in the tree, while /node_modules ignores it only adjacent to the .ignore file.
Most helpful comment
Indeed, this is a problem.
Expected behavior, from working with other tools that have a ".ignore" file, would be that
node_modulesignores that dir anywhere in the tree, while/node_modulesignores it only adjacent to the .ignore file.