Closed resistancecanyon closed 6 years ago
@vmasek Is this good ? I'll add test cases for the same.
I will look into this issue as I don't recall this happening in our projects. It would be better if we could solve it without additional config options
What is the ng version you are using?
Angular 5.2.9
I do think extra options are unnecessary, but if we add
imports: [ BrowserModule, ... APIClientModule.forRoot({ domain: 'http://localhost:10507', httpOptions: { headers: new HttpHeaders(xxx), withCredentials: true } }), SharedModule ],
It simply won't build with --prod flag causing the above mentioned error.
Maybe AoT was off for your projects like in ng4.
It is a blocker.
Is there any other way to pass the headers:
then also its fine.
After some tests, it would be best if the options we provide for params
and headers
will be {[key: string]: string}
object and not constructed class.
It will require to change some types and interfaces but it should be able to do it without breaking the outer API. I'll cover that in PR soon.
I do agree that, so AOT compilation will never break again.
And we can construct the classes from the
{[key: string]: string}
pairs inside the api constructor classes & thus instantiated only once.
the fix should be in master now, @resistancecanyon please try the latest version and see if there is everything resolved.
Running
$ ng build --prod
while the module is injected to the app. We get the following errorERROR in app/app.module.ts(14,21): Error during template compile of 'AppModule' Function calls are not supported in decorators but 'HttpHeaders' was called.
This might be due to the fact that simple assignments are only allowed during module declarations. and we're trying to pass
new HttpHeaders(...header String/objects)
into the module declaration.Possible Solution: