Skip to content

NG0912 error after migrating (to 16) multiple components with no selector #50158

@alexaka1

Description

@alexaka1

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes

Description

Components generated with the CLI (pre 16.x or 16.x) using --skip-selector result in the browser displaying NG0912 error, claiming that multiple of my components have colliding selector ng-component, when using Angular 16. This error is not present in at least 13, 14, and 15.

The components in question all look like this:

import { Component } from '@angular/core';
@Component({
  templateUrl: './foo-with-no-selector.component.html',
  styleUrls: ['./foo-with-no-selector.component.scss'],
})
export class FooWithNoSelector{ ... some stuff }
@Component({
  templateUrl: './bar-with-no-selector.component.html',
  styleUrls: ['./bar-with-no-selector.component.scss'],
})
export class BarWithNoSelector{ ... some stuff }

These components are used only in Routing (or manually created as dialogs using material).
Afaik the convention for route only components was to omit selector. Is this change intentional or is it documented somewhere?

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

NG0912: Component ID generation collision detected. Components 'FooWithNoSelector' and 'BarWithNoSelector' with selector 'ng-component' generated the same component ID. To fix this, you can change the selector of one of those components or add an extra host attribute to force a different ID. Find more at https://angular.io/errors/NG0912

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 16.0.0
Node: 18.16.0
Package Manager: npm 9.6.4
OS: win32 x64

Angular: 16.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, material, material-luxon-adapter, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1600.0
@angular-devkit/build-angular   16.0.0
@angular-devkit/core            16.0.0
@angular-devkit/schematics      16.0.0
@schematics/angular             16.0.0
rxjs                            7.8.1
typescript                      4.9.5

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtime

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions