
Your Angular Module is a SCAM!

Does it deserve a new NgModule? Will we re-use it soon? Who cares, we will refactor that when needed anyway. Yeah ! But even with a great IDE, how straightforward is the refactoring?
TL;DR
yarn add @wishtack/schematics
yarn ng g @wishtack/schematics/scam hello-world
Where It All Started
NgModule
Refactoring Hell
NgModule
NgModule
@NgModule({
declarations: [
SandwichFormComponent,
SandwichPreviewComponent
],
imports: [
MatButtonModule,
MatCardModule,
ReactiveFormsModule
]
})
export class CuteLittleSandwichModule {}
SandwichFormComponent
MatButtonModule
MatCardModule
SCAM ! ! !
SCAM stands for Single Component Angular Module
yarn add @wishtack/schematics
yarn ng g @wishtack/schematics:scam sandwich/sandwich-preview
app/
sandwich/
sandwich-preview/
sandwich-preview.component.ts|html|...
sandwich
SandwichPreviewModule
sandwich-preview.component.ts
🧹 Say bye to .module.ts
.module.ts
NgModule
.component.ts
.module.ts
The component’s directory will be less cluttered. It should naturally discourage us from adding anything else to the module. Using IVy, when importing the component we will also trigger the build of the module without having to explicitly import it.