babel/babel

Files passed to `--ignore` are also watched

Open

#9565 opened on Feb 22, 2019

View on GitHub
 (5 comments) (0 reactions) (0 assignees)TypeScript (43,894 stars) (5,826 forks)batch import
claimedhelp wantedpkg: cli

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)

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