【问题标题】:How to include specific modules in flow如何在流程中包含特定模块
【发布时间】:2017-04-14 05:53:01
【问题描述】:

我在node_modules 下有一个带有流类型注释的私有 npm 包。 我只想包含那个包,所以我不需要手动为其创建 libdef。

目录结构

node_modules/
  @my-company/private-module1
  public-module1
  public-module2
  .
  .
  .

我尝试了以下.flowconfig,但没有成功。

不起作用

[ignore]
.*/node_modules/.*
!./node_modules/@my-company/
[include]
[libs]
[options]

也不行

[ignore]
.*/node_modules/.*
[include]
./node_modules/@my-company/
[libs]
[options]

我怎样才能做到这一点? 我想我缺少一些基本的东西......

谢谢!

【问题讨论】:

    标签: javascript flowtype


    【解决方案1】:

    我没有很好的解决方案,因为看起来 ocaml 正则表达式不允许负前瞻。

    出于这个原因,我通常看到当一个项目需要忽略任何node_modules 时,[ignore] 被配置为包含大量列表的黑名单。

    由于您似乎希望忽略所有 node_modules,但您公司的范围包除外,您最好忽略所有公共 node_modules 和您不希望流爬取的任何范围 node_modules。

    [ignore]
    ; Ignore any public packages
    .*/node_modules/[a-zA-Z-]+/.*
    
    ; Ignore specific scoped packages
    .*/node_modules/@ignorescope/.*
    
    [include]
    
    [libs]
    
    [options]
    

    【讨论】:

    • 有效!我希望有更好的方法来做到这一点,但这对我们来说已经足够了。谢谢!
    猜你喜欢
    • 2021-12-31
    • 1970-01-01
    • 2013-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-24
    • 1970-01-01
    • 2020-08-16
    相关资源
    最近更新 更多