ngx-quicklink icon indicating copy to clipboard operation
ngx-quicklink copied to clipboard

Incorrect loading of component by paths

Open BEGEMOT9I opened this issue 11 months ago • 0 comments

Hi! First of all, I would like to express my gratitude for creating such a project)

We are using this lib on a fairly large application and recently discovered two rather critical problems with preloading components. The first of them is loading unnecessary components. If there is at least one link with routerLink directive and QuicklinkModule on the page, then the preloading process for the routing config is launched and, due to an erroneous determination of the appropriate path, unnecessary components are loaded. The second problem is that the necessary components do not load. This is also due to the fact that the required paths are not matched correctly and they are skipped for preloading. Both of these problems arise due to the download necessity check utility (to be more precise, due to findPath util), which has two bugs:

  • one of them was already noticed by @Timebutt in #150 who tried to fix the functionality of constructing a set of parent segments (_loadedRoutes is always empty so we are not pushing child routes for traversing): https://github.com/mgechev/ngx-quicklink/blob/master/projects/ngx-quicklink/src/lib/quicklink-strategy.service.ts#L51
  • another bug is related to constructing a full path using parent segments if there are route objects with an empty path (there might be a path with several slashes /) https://github.com/mgechev/ngx-quicklink/blob/master/projects/ngx-quicklink/src/lib/quicklink-strategy.service.ts#L68

I've created a fork with an updated app so u can check a case when we don't load necessary chunks and load unnecessary (u should visit the /other-section and u will see that we are not loading a component for the /other-section/common-info path and loading script for the /other-section/:subSectionSlug/:pageSlug path) https://github.com/BEGEMOT9I/ngx-quicklink

BEGEMOT9I avatar Mar 07 '24 13:03 BEGEMOT9I