Search code examples
angularangular-cli

Prevent to import CommonModule while creating new component by Angular 17 CLI


How can I prevent CommonModule from being added to imports array in component generated by Angular 17 CLI? I can't find an option to add in angular.json to @schematics/angular:component.

@Component({
    selector: 'app-new-component',
    standalone: true,
    imports: [CommonModule], <---- I want this array to be empty while generate new component by "ng g c new-component"
    templateUrl: './new-component.component.html',
    styleUrl: './new-component.component.scss',
    changeDetection: ChangeDetectionStrategy.OnPush
})
export class NewComponentComponent {}

The lack of imports property satisfies me as well as empty imports array.


Solution

  • The change has already landed in CLI the repo and will be available in 17.1

    Until then, you can't do much beside doing the change yourself in the node_modules and use patch-package.