-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(pnp): resolve the virtual path of the pnpapi instead of the issuer #1851
Conversation
47e6452
to
6e30a6e
Compare
I feel like it's still a problem, because it makes a double lookup for virtual paths - so if the portal'd project is a PnP project, it'll have a PnP file, and thus Instead, it seems like the ideal would be to only run the lookup based on the virtual path. I think the |
Only if the target isn't a PnP project
It would find the external one anyways
I agree, reading over the original issue (#1524 (comment)) it seems the conclusion @bgotink came to was that we needed to resolve the virtual path of the pnpapi we find, not the path we search, making that change fixes the issue i'm having with portals and prevents double searches |
6e30a6e
to
a432101
Compare
a432101
to
f459167
Compare
I have been thinking about this for some time. The merged solution is better than nothing but I have some concerns/comments. (It is totally possible that I misunderstood some things and if so please point them out) Problem statementFirst of all, let's define the problem we are trying to fix with this PR. Let's say we need to find the PnP API for the virtual path
The behavior before this PR was that path would be resolved to As far as I can see, the correct behavior would be attempting to find a PnP API at all of these paths (among others), in high to low precedence order:
For most common cases, this PR does solve this problem. But I have 2 concerns. CachingThe search algorithm caches any path it has searched before. The merged solution sometimes ignores the cache. In particular, say
These two virtual paths point to the same location on the actual fs, so they should be and was cached under the same key. However, the merged solution breaks that. Edge casesAll of the above assumes the
in which case there is no way for the PnP API search to recover the paths of project2 and project1. I think the configurability of ConclusionGiven that I don't think a robust solution can be implemented without removing the |
@merceyz Btw, I just noticed that the PR didn't add a test - I think it's something that should be covered, as we already regressed once. Do you have a small testcase we could add to |
What's the problem this PR addresses?
findApiPathFor
passes the search path throughVirtualFS.resolveVirtual
instead of the.pnp.*
file which causes it to not find thepnpapi
when using theportal:
protocol into non-pnp projects and when using the global cache.Fixing this will allow me to add a e2e test to gridsome/gridsome#1313
How did you fix it?
Pass the found
.pnp.*
path throughVirtualFS.resolveVirtual
instead of the search path.Checklist