Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoking libraryGenerator from '@nx/angular/generators' may generate duplicate route file references #19012

Closed
1 of 4 tasks
Erbenos opened this issue Sep 5, 2023 · 2 comments · Fixed by #19326
Closed
1 of 4 tasks
Assignees
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@Erbenos
Copy link

Erbenos commented Sep 5, 2023

Current Behavior

Doing:

  await libraryGenerator(tree, {
    directory,
    unitTestRunner: UnitTestRunner.Jest,
    name,
    prefix: 'custom prefix',
    tags: `type:tag`,
    routing: true,
    strict: true,
    setParserOptionsProject: true
  });

(only other tasks invoked in the custom generator are formatFiles and installPackagesTask from '@nx/devkit')

May result in following files:

index.ts

export * from './lib/custom-app-feature-test-lib.module';
export * from './lib/lib.routes';

export * from './lib/lib.routes';

custom-app-feature-test-lib.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, RouterModule, Route } from '@angular/router';
import { customAppFeatureTestLibRoutes } from './lib.routes';

@NgModule({
  imports: [CommonModule, RouterModule.forChild(customAppFeatureTestLibRoutes), RouterModule]
})
export class CustomAppFeatureTestLibModule {}

See the duplicate router modules.

Expected Behavior

No duplicate references to lib.routes.ts in index.ts file.
No duplicate references to RouterModule in module ts file.

GitHub Repo

https://github.com/Erbenos/nx-duplicate-references-bug

Steps to Reproduce

  1. Clone the repo
  2. Run following command: "yarn nx generate @nx/angular:library --name=random-name --routing=true"
  3. Observe "Current behavior"

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 16.15.1
   OS     : darwin-arm64
   yarn   : 1.22.19
   
   nx                 : 16.7.0-rc.1
   @nx/js             : 16.7.0-rc.1
   @nx/jest           : 16.7.0-rc.1
   @nx/linter         : 16.7.0-rc.1
   @nx/workspace      : 16.7.0-rc.1
   @nx/angular        : 16.7.0-rc.1
   @nx/cypress        : 16.7.0-rc.1
   @nx/devkit         : 16.7.0-rc.1
   @nx/eslint-plugin  : 16.7.0-rc.1
   @nx/react          : 16.7.0-rc.1
   @nrwl/tao          : 16.7.0-rc.1
   @nx/web            : 16.7.0-rc.1
   @nx/webpack        : 16.7.0-rc.1
   nx-cloud           : 16.3.0
   typescript         : 5.1.3
   ---------------------------------------
   Community plugins:
   @ngrx/component-store : 16.0.0
   @ngrx/effects         : 16.0.0
   @ngrx/entity          : 16.0.0
   @ngrx/router-store    : 16.0.0
   @ngrx/store           : 16.0.0
   @ngrx/store-devtools  : 16.0.0

Failure Logs

None.

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@Erbenos
Copy link
Author

Erbenos commented Sep 5, 2023

Workaround is to use standalone: true as that does not have the duplicate reference issue.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
3 participants