-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
File url normalization #1498
File url normalization #1498
Conversation
|
@kittens I tried that approach too and it worked. The only weird thing was the original relative paths ended up in |
(Edit: was typing while previous comment appeared, anyway, it explains it as-well) @kittens to add on your comment: do you mean normalizing only the If so, I think it would show a side-issue (that this PR solves), that is: pattern names are a concatenation of dependency properties from the manifest. This would lead to successful install but a misleading Given this example,
Doing the normalization later on the While checking this out I noticed two small things (epic otherwise!):
|
I can't get it to work like that. It seems to work from the command line, but the unit test fails. I can't tell what's going on; it seems to run the |
I think the code that reads the manifest is caching it, so the same manifest is getting normalized by |
I could add a |
Made a quick implementation with your tests, based on the the manifest normalizing as in your PR, and had green tests, could it maybe be something small you missed? I made a Pull Request to my own fork so you can easily see the diff, and maybe find out what could have gone wrong? Hope it will help you on the way! |
Yes, that helped, thank you! Submitted for your approval, the PR now copies the manifest if and only if any of the paths were actually normalized. |
what is the status of this PR ? it fixes our local dependencies issues. we can't migrate to Thanks |
@bestander Any idea when this will be shipped? Some projects are blocked by this. |
@justin808 it is already in 0.18.0 |
Summary
When resolving dependencies against
file:
URLs that have relative paths, descendent modules'file:
URLs were resolving against the CWD instead of againstpackage.json
.I'm not claiming that depending on packages in other directories is a good idea, but this is a use case that npm seems to support but yarn doesn't. It seems like it should work but doesn't.
Test plan
Given a set of modules:
The dependencies go like this:
. -> sub-a -> root-b -> root-a
.Root calls
sub-a
file:sub/sub-a
.sub-a
callsroot-b
file:../../root-b
root-b
callsroot-a'
file:../root-a`Saying
yarn
correctly resolvessub-a
, but then looks up two directories from CWD to try to findroot-b
and fails:This pull requests attempts to fix that by normalizing the in-memory
package.json
to resolve allfile:
URLs upon reading apackage.json
and relativizing them against CWD. I'm not sure if this is the correct approach but it seems to work.Another approach I considered was attaching the current manifest to
PackageRequest
during resolution and retrieving that info inFileResolver
, using the base path of the manifest, if any, instead ofthis.config.cwd
.