禁用 .babelrc 继承

Disable .babelrc inheritance

如何强制 babel 不查看 .babelrc 的父目录?

我试过将 ./a/example/.babelrc 设置为:

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

但是,运行 babel./a/example 路径中仍然使用 "lodash" 插件。

$ 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'
    [..]

有一个名为 breakConfig 的未记录的 属性。将 breakConfig 设置为 true 以禁用配置继承。

此行为将在 6.x 中改变。在 6.x 中,Babel 将在它找到的第一个 .babelrc 处中断。 extends 属性 将用于明确命名要继承的其他 .babelrc 文件。