luckyseven / ngx-liquid-cache

A powerful, automatic and optimized Angular2/10+ cache system that fits everywhere!
MIT License
83 stars 3 forks source link

Place holders don't appear work on Angular 11.0.3 with Optimization set to true #17

Open lee-andrews-uk opened 3 years ago

lee-andrews-uk commented 3 years ago

We are using Angular 11.0.3 and making extensive use of placeholders which work when running locally with optimization set to false, however Liquid Cache does not work with optimization set to true. According to the documentation it implies that this should work for Angular versions 10+ can you confirm if it should work with V11 of Angular with optimization enabled please? It's not really option for us to run without optimization enabled on production.

luckyseven commented 3 years ago

Hi, thanks for your feedback. The library was tested on Angular 10+ versions, but i'll check asap (today) if there are issues.

Can you confirm that the cache system doesn't work in any case, or maybe it has issues only on particular methods/situations?

Thanks

lee-andrews-uk commented 3 years ago

Hi there, I've managed to re-produce the problem when running locally by using the configuration used to build and deploy to our development environment. Below is a copy of that Configurations section from angular.json file. If we use the angular defaults it works fine but if we use the following configuration I see no http client calls being made for the methods that have the @LiquidCache with placeholders added e.g. @LiquidCache('eventStatuses{language}') .

angular.json configuration: "configurations": { "dev": { "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.dev.ts" } ], "optimization": true, "outputHashing": "all", "sourceMap": true, "namedChunks": false, "aot": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true, "serviceWorker": false },

Here is an example of one of the methods that don't work, all methods with place holders are not working:

@LiquidCache('eventStatuses{language}') public getEventStatuses(language: string): Observable<EventStatus[]> { const apiUrl = ${environment.chronosWebApiEndpoint}/EventStatus?language=${language}; return this.http.get<EventStatus[]>(apiUrl); }

Optimization true and no place holders appears to work as expected e.g.

@LiquidCache('getEventsByCustomerAccount') public getEventsByCustomerAccount( customerAccountId: string, isArchived: boolean | null ): Observable<ListEventDto[]> { let apiUrl = ${environment.chronosWebApiEndpoint}/CustomerAccounts/${customerAccountId}/events; if (isArchived != null) { apiUrl += ?isArchived=${isArchived}; } return this.http.get<ListEventDto[]>(apiUrl); }

lee-andrews-uk commented 3 years ago

Hi, I've done some more testing and just changing "optimization": true, to "optimization": false,

in that dev configuration I sent you has made it work, so it looks like the issue is with optimisation. Hope this helps. Cheers

lee-andrews-uk commented 3 years ago

Hi there, Any update/news regarding this issue please?

Many thanks

gulfaraz commented 1 year ago

In Angular 14, placeholders don't work when "optimization": true.

I use "optimization": { "scripts": false } to get around this issue.