首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何强制nrwl尊重标签更新?

如何强制nrwl尊重标签更新?
EN

Stack Overflow用户
提问于 2020-02-18 17:50:31
回答 3查看 1.6K关注 0票数 0

当我在nx.json中更新项目标记时,TSLint似乎不知道标签已经改变了,而lints和builds项目,即使违背了依赖关系。

示例

当前,我的nx.json文件看起来像

代码语言:javascript
复制
{
  "npmScope": "patient-engagement",
  "implicitDependencies": {
    "package.json": "*",
    "tsconfig.json": "*",
    "nx.json": "*"
  },
  "projects": {
    "hep": {
      "tags": ["scope:hep", "compatibility:ie10"],
      "implicitDependencies": []
    },
    "mb-ui": {
      "tags": ["scope:shared", "compatibility:ie10"],
      "implicitDependencies": []
    },
    "utils": {
      "tags": ["scope:shared", "compatibility:ie10"],
      "implicitDependencies": []
    }
  }
}

我的根tslint.json包括:

代码语言:javascript
复制
"nx-enforce-module-boundaries": [
      true,
      {
        "enforceBuildableLibDependency": true,
        "allow": [],
        "depConstraints": [
          {
            "sourceTag": "scope:hep",
            "onlyDependOnLibsWithTags": [
              "scope:hep",
              "scope:shared"
            ]
          },
          {
            "sourceTag": "compatibility:ie10",
            "onlyDependOnLibsWithTags": [
              "compatibility:ie10"
            ]
          },
          {
            "sourceTag": "scope:shared",
            "onlyDependOnLibsWithTags": [
              "scope:shared"
            ]
          }
        ]
      }
    ],

当我运行ng lint hep时,这会像预期的那样通过linting。

但是,如果我在nx.json中编辑标记,链接器就不会显示任何错误。例如,如果我将nx.json修改成如下所示(从库中删除标记),它仍然是lints和构建,没有任何错误。

代码语言:javascript
复制
{
  "npmScope": "patient-engagement",
  "implicitDependencies": {
    "package.json": "*",
    "tsconfig.json": "*",
    "nx.json": "*"
  },
  "projects": {
    "hep": {
      "tags": ["scope:hep", "compatibility:ie10"],
      "implicitDependencies": []
    },
    "mb-ui": {
      "tags": [],
      "implicitDependencies": []
    },
    "utils": {
      "tags": [],
      "implicitDependencies": []
    }
  }
}

如果有用的话,当我更新tslint.json中的规则时,linter确实会抛出错误,但我希望它也能确认对nx.json的更改。

在更新nx.json中的标记时,有什么方法可以让链接器显示错误呢?

EN

回答 3

Stack Overflow用户

发布于 2020-02-18 23:29:40

Nx缓存一堆有关生成文件中的依赖项的信息:/dist/nxdeps.json

您只需删除此文件即可立即看到对nx.json的更改。

票数 1
EN

Stack Overflow用户

发布于 2020-02-21 06:43:19

它也可能是VS代码的缓存,导致问题

在对tslint.json或tsconfig.json文件进行更改之前,您可能需要重新启动类型记录服务。

ctrl + shift + p and then Typescript: Restart TS Server

票数 1
EN

Stack Overflow用户

发布于 2021-12-15 14:04:07

在Webstorm中,重新启动类型记录服务没有帮助,但是重新启动IDE会有所帮助(类似于索引文件)。

在我的例子中,在编辑nx.json时,我正在执行这样的步骤:

删除dir node_modules/.cache/nx

  • Run nx lint (将生成新缓存)

  • 重新启动IDE
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60286775

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档