Gajus
Gajus

Reputation: 73888

Disable .babelrc inheritance

How do I force babel NOT to look at the parent directory for .babelrc?

I have tried setting ./a/example/.babelrc to:

{
    "stage": 0,
    "plugins": []
}

However, running babel in ./a/example path still uses "lodash" plugin.

$ pwd
/a/example
$ cat ./.babelrc
{
    "stage": 0,
    "plugins": []
}
$ cat ./../.babelrc
{
    "stage": 0,
    "plugins": [
        "lodash"
    ]
}
$ babel ./src/
Error: ENOENT: no such file or directory, scandir '/a/node_modules/babel-plugin-lodash/node_modules/lodash'
    [..]
$ babel --babelrc ./.babelrc ./src/
Error: ENOENT: no such file or directory, scandir '/a/node_modules/babel-plugin-lodash/node_modules/lodash'
    [..]

Upvotes: 8

Views: 2770

Answers (1)

Gajus
Gajus

Reputation: 73888

There is an undocumented property called breakConfig. Set breakConfig to true to disable config inheritance.

This behaviour is going to change in 6.x. In 6.x Babel will break on the first .babelrc it finds. extends property is going to be used to explicitly name other .babelrc files to inherit from.

Upvotes: 12

Related Questions