我如何强制nrwl nx遵守标签更新?

问题描述 投票:0回答:2

[当我更新nx.json中的项目标签时,TSLint似乎不知道标签已更改,即使违反了依赖关系,它也会掉线并构建项目。

示例

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

{
  "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包括:

"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时,按预期通过了棉绒。

但是,如果我在nx.json中编辑标签,则短绒不会显示任何错误。例如,如果我修改nx.json使其看起来像这样(从库中删除标签),它仍然会掉线并构建而没有任何错误。

{
  "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中的规则时,lint确实会抛出错误,但我希望它也确认对nx.json的更改。

有没有一种方法可以使短绒猫在nx.json中的标签更新时显示错误?

tslint nrwl nrwl-nx
2个回答
1
投票

也可能是VS Code的缓存导致问题

在更改tslint.json或tsconfig.json文件之前,您可能需要重新启动Typescript服务。

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


0
投票

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

您可以简单地删除此文件以立即查看对nx.json的更改。

© www.soinside.com 2019 - 2024. All rights reserved.