@babel/node not recognizing ignores from babel.config.js when running babel-node
- Dominant language
- TypeScript
- Stars
- 44k
- Forks
- 6k
- Avg merge
- 5d 15h
- Merged PRs (30d)
- 23
Description
## Bug Report
**Current behavior**
It's possible it's a "feature", but seems like a bug.
So, I have a babel config that has an ignore function in it. Mostly because where I work we have a couple of internal node modules we publish that have some `dist` folders with `import` `export` statements.
The `babel.config.js` looks more or less like this...
```js
module.exports = (api) => {
api.cache(true);
return {
presets: ['@babel/env'],
ignore: [function(filepath) {
if (filepath.includes('my-npm-pkg')) {
return false;
}
return filepath.includes('node_modules');
}]
};
};
```
When I run the following...
```shell
babel-node ./index.js
```
I get the following error...

However, if I run it with an empty ignore, like this...
```shell
babel-node --ignore ' ' ./index.js
```
Everything works...

**Expected behavior**
I'd expect that the ignore should be taken from the `babel.config.js` even if I don't have an `--ignore` in the command line args.
**Environment**
I'm running on node 12.17.0.
```
"@babel/core": "^7.10.5",
"@babel/node": "^7.10.5",
"@babel/preset-env": "^7.10.4"
```
I also created an example repository here...
https://github.com/jcreamer898/babel-node-ignore
**Possible Solution**
I'm not entirely sure, but maybe it has something to do with https://github.com/babel/babel/blob/main/packages/babel-register/src/node.js#L140?
Does there need to be a check for the babel config's ignore here? It didn't _seem_ like that to me because when I console logged the options getting passed here, it didn't even seem to have the ignore from my `babel.config.js`.
https://github.com/babel/babel/blob/main/packages/babel-node/src/_babel-node.js#L94

So, my suspicion is that the `--ignore ' '` is just nuking the ignore option totally, and `babel.config.js` is firing on a file by file basis later on as they're processing individual files?
Contributor guide
Research direction
Start with the reproduction repository linked in the issue, then inspect packages/babel-node/src/_babel-node.js and packages/babel-register/src/node.js. Compare the options received with and without the --ignore argument, and verify that babel-node uses the ignore configuration from babel.config.js when no CLI ignore is supplied.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100