简体   繁体   English

如何避免使用 NRWL move 命令更改库的导入名称?

[英]How to avoid changing the import name of the Library using NRWL move command?

I am using the NRWL move command to move lib into the parent folder to achieve a well-organized project structure.我正在使用 NRWL move 命令将 lib 移动到父文件夹中,以实现组织良好的项目结构。

for example the command: nx g @nrwl/angular:move --project graphql core/graphql例如命令: nx g @nrwl/angular:move --project graphql core/graphql

It moves lib into the parent folder but it changes the name of the library too as You can see on the following output of the angular.json file.它将 lib 移动到父文件夹中,但它也更改了库的名称,如您在 angular.json 文件的以下 output 中所见。

 "graphql": {
      "projectType": "library",
      "root": "libs/graphql",
      "sourceRoot": "libs/graphql/src",

changes to:更改为:

  "core-graphql": { // I dont want to change this name only the path to module
      "projectType": "library",
      "root": "libs/core/graphql",
      "sourceRoot": "libs/core/graphql/src",

I have to find all occurrences of the new library name and change them back after each move command.我必须找到所有出现的新库名称,并在每次移动命令后将它们改回来。

Is possible to avoid this by some flag in command?是否可以通过命令中的某些标志来避免这种情况? I tried to use params that are mentioned in docs but without luck, the name is changed every time.我尝试使用文档中提到的参数,但没有运气,每次都会更改名称。

Thanks for any advice.感谢您的任何建议。

Project name and the project path stays in sync in nrwl workspace and hence it makes sense on why the project name is getting updated from graphql to core-graphql .项目名称和项目路径在 nrwl 工作区中保持同步,因此为什么项目名称从graphql更新为core-graphql是有意义的。

Also, the move command by default updates all occurrences of the import path of the moved project to the new location ( https://nx.dev/packages/angular/generators/move#updateimportpath ), so I don't think one would want the same project name even after moving it to a new location.此外,默认情况下,移动命令会将所有出现的已移动项目的导入路径更新到新位置( https://nx.dev/packages/angular/generators/move#updateimportpath ),所以我认为不会即使在将其移动到新位置后也想要相同的项目名称。 You can avoid the import path update by setting updateimportpath to false while running the command but that would only cause more confusion in the workspace.您可以通过在运行命令时将updateimportpath设置为 false 来避免导入路径更新,但这只会在工作区中造成更多混乱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从库中导入组件(在Angular中为nrwl / nx) - How to import a component from a library (in nrwl/nx with Angular) 如何在其他库 nx (nrwl) 中共享库 - singlerepo - How to share library within other library nx (nrwl) - singlerepo 指定生成器名称(例如,nx generate @nrwl/workspace:library)--Angular - Specify the generator name (e.g., nx generate @nrwl/workspace:library)--Angular 如何在一个工作区内将库中的库发布到 NPM (singlerepo) nx nrwl - How to publish a library inside library to NPM within one workspace (singlerepo) nx nrwl @schematics/angular:library VS @nrwl/angular:library - @schematics/angular:library VS @nrwl/angular:library 当构建器使用不同的选项时,如何在 nrwl nx 中使用单个受影响的构建命令 - how to use a single affected build command in nrwl nx when builders use different options 如何通过命令行在 cypress.json 文件中设置环境变量? (Angular CLI - nrwl nx) - How to set environment variables in cypress.json file through command line? (Angular CLI - nrwl nx) 在 Angular Nrwl Nx 中创建组件作为库 - Create component as a library in Angular Nrwl Nx 在 Nrwl Nx 库中导入 Angular Material 主题 - Import Angular Material theme in Nrwl Nx libs 找不到 nx 命令,全局安装了 nrwl - nx command not found, nrwl installed globally
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM