2

I have a couple of components which are part of a template which I dont use but don't what to physically delete.

I have commented out every import statement and reference to the component class but I'm still getting the error when running

ng build --prod

Cannot determine the module for class OrganizationComponent

Is there a way to explicitly tell angular to ignore them? As far as I know the aot should ignore it on default...

Han Che
  • 8,239
  • 19
  • 70
  • 116
  • I've added an answer which might help, but if you could post the code somewhere it would allow us a better chance of helping you. Can you cut it down to a minimal example and post it somewhere? – Mark Hughes Jul 20 '18 at 10:39

2 Answers2

1

The error posted implies that something is trying to instantiate that component but it is not referenced in any of the loaded modules.

This suggests that you have correctly removed it from the imports and the modules, but I would guess that perhaps you are still referencing the component's tag in a template of another component which is included?

Mark Hughes
  • 7,264
  • 1
  • 33
  • 37
0

Tree shaking is a step in a build process that removes unused code from a code base.

Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module syntax, i.e. import and export.

For more Info: https://coryrylan.com/blog/tree-shakeable-providers-and-services-in-angular

Chellappan வ
  • 23,645
  • 3
  • 29
  • 60