filipesilva / angular-quickstart-lib

MIT License
305 stars 75 forks source link

Build allows non AOT compliant code #56

Open adamlubek opened 7 years ago

adamlubek commented 7 years ago

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?

franzbecker commented 7 years ago

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.

adamlubek commented 7 years ago

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).