禁用.babelrc继承

Gaj*_*jus 8 babeljs

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

  • 我有两个.babelrc文件:./a/.babelrc./a/example/.babelrc.
  • babel./a/example路上奔跑.
  • ./a/.babelrc 定义了一个插件"lodash".
  • 我执行babel时不想使用这个插件 ./a/example

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

{
    "stage": 0,
    "plugins": []
}
Run Code Online (Sandbox Code Playgroud)

但是,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'
    [..]
Run Code Online (Sandbox Code Playgroud)

Gaj*_*jus 12

有一个名为的无证财产breakConfig.设置breakConfigtrue禁用配置继承.

这种行为将在6.x中发生变化.在6.x中,Babel将在.babelrc它找到的第一个中断.extendsproperty将用于显式命名.babelrc要继承的其他文件.