angular-quickstart-lib icon indicating copy to clipboard operation
angular-quickstart-lib copied to clipboard

Build allows non AOT compliant code

Open adamlubek opened this issue 7 years ago • 2 comments

this code in module.ts, once imported into Angular CLI based app works fine:

export class LibService {}
export function libProvider() { return LibService; }

@NgModule({
  imports: [
    CommonModule
  ],
  providers: [
    { provide: LibService, useFactory: libProvider() }
  ]
})
export class FeatureModule { }

but this one:

export class LibService {}
export const libProvider = () => LibService;

@NgModule({
  imports: [
    CommonModule
  ],
  providers: [
    { provide: LibService, useFactory: libProvider() }
  ]
})
export class FeatureModule { }

breaks on ng start with:

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function

My understanding is that second snippet, using "export const libProvider = () => LibService;", is not AOT compliant. However, both snippets build fine with angular-quickstart-lib. Questions is, can build of angular-quickstart-lib be setup in a way to break for code that is not AOT compliant?

adamlubek avatar Aug 29 '17 14:08 adamlubek

It seems to me like you didn't execute the integration tests. You should include those in your build pipeline and only publish the library once they pass. Running those on your example yields the same message you encountered.

franzbecker avatar Sep 21 '17 14:09 franzbecker

Integration tests in my company are maintained by separate team and are run against application that uses library instead of library level. I'd like to have library build though, which fails for non AOT compliant code (without developers maintaining integration tests).

adamlubek avatar Sep 21 '17 15:09 adamlubek