babel / babel/babel

Files passed to `--ignore` are also watched

Open
#9,565 6 comments 0 reactions 0 assignees View on GitHub
claimed help wanted pkg: cli
Dominant language
TypeScript
Stars
44k
Forks
6k
Avg merge
5d 15h
Merged PRs (30d)
23

Description

## Bug Report

**Current Behavior**
I was hitting an error message of "System limit for number of file watchers reached", and it turns out that this was because I was doing something like:

```
npx babel . --out-dir=../es5 --watch --ignore="node_modules"
```

But, since `--ignore` was not getting passed to `chokidar`, it was trying to watch the entire `node_modules` directory—hence the error!

**Expected behavior/code**
I would expect `--watch` to *also* respect the `--ignore` option.

**Babel Configuration (.babelrc, package.json, cli command)**

```js
module.exports = {
presets: ["@babel/env"],
sourceType: "script"
};
```

**Environment**
- Babel version(s): 7.3.3
- Node/npm version: 10.15.1/6.8.0
- OS: CentOS 7.5
- Monorepo: no
- How you are using Babel: `cli`

**Possible Solution**
I attempted but failed in a patch: https://github.com/babel/babel/pull/9559 This failed as `chokidar` uses globs for their `--ignored` flag and Babel uses RegExp.

Is there another way to avoid the issue? I recognize it is more usual to run `babel` against a `src` directory or the like…but one doesn't always have that luxury on legacy code.

Thanks!

Contributor guide

Open the contributing guide

Research direction

Start by tracing Babel's CLI handling of --watch and --ignore, then inspect how those values are passed to chokidar's ignored option. Review the attempted approach in PR #9559, especially the RegExp-versus-glob mismatch. Done means ignored paths are not watched when using --watch, avoiding watcher-limit failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, typescript
Domain
cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.