angularangular-aot

Angular Ahead-of-Time Compilation Problems


I'm trying to set my app up for AOT compilation in preparation for release. The code compiles just fine in JIT of course.

In AOT, I get a lot of errors that look like this:

ERROR in : Can't bind to 'lead' since it isn't a known property of 'app-output-edit'. 1. If 'app-output-edit' is an Angular component and it has 'lead' input, then verify that it is part of this module. 2. If 'app-output-edit' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

In my case Lead is a public @Input() property of my OutputEditComponent.

Most of the posts on this topic I've found on the net talk about making sure that the component is declared in your component or feature module. I'm not using a feature module. I have a root module (app.module.ts), and a routing module (app-routing.module.ts). Also, I have a mock module. All of my components are declarations in the root module.

I also get it with other bindings. Like Can't bind to 'formGroup' since it isn't a known property of 'div'

And I'm getting errors like "No provider for ControlContainer" and "No provider for NgControl".

Finally, I'm getting errors with 3rd-party components, like ng-bootstrap: "Can't bind to 'items' since it isn't a known property of ng-select". Oh, but it is...

UPDATE - I was able to resolve all the errors except that top 1: Can't bind to 'X' because it isn't a known property of 'Y'. Mostly we just had errors originating in the html markup: referring to private properties of the component, calling methods without all of the arguments etc. Still working on it.

Thanks.


Solution

  • So in my case, it turned out that my mock module was interfering with everything. We had set up a mock module for automated testing, probably incorrectly, and it was just sitting there, because we're not actually doing integration testing yet.

    BEWARE THE MOCK MODULE! IT IS MOCKING YOUR AOT!

    Peace and good coding.

    Aaron