-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Resolve fails on MacOS and Windows, works on linux #22
Comments
Can you reduce this. What values are being passed. Which things exist on disk? I am on mac, it works.
The types here are not wrong? Your |
This sounds quite likely to be the problem too. The algorithm here is based on how Node/npm work. Yarn intentionally does things differently. Perhaps you can see things posted already in its issue tracker |
My first thought was indeed around an issue with cwd, I first changed the code to use Regarding the "dummy.js", my understanding is that they (it's not my code) want to resolve a peer dependency, so they concatenate the current directory with a fictitious filename so the resolver thinks it is working for an actual file. In the end it passes a path like |
I know it behave differently, though it works on my Linux VM, plus when I change the code to use |
It’s not my code either 😉. Showing which results are generated for macos/windows/linux, and which files exist in those 3 cases, will help.
It’s because
I believe there are specific things that yarn does for pnp to hook into |
Okay I thought changing this specific call was a clear enough indicator that the code performed differently on different environments, if you don't feel like looking into it, I'll see if I have some time to create a more "isolated" reproducer. |
See also #10 |
We have a SvelteKit project (which uses your library in version 4.0.0) which runs fine on my Debian VM but fails to resolve a dependency both on a Mac and a Windows machine when using Yarn pnp linker (it works everywhere with Yarn node-modules liker though).
After clearing out any other reason (fresh branch checkout on all machines, no changes...) I had to trace the code, and I ended up looking into SvelteKit code and figured the following line didn't behave the same between platforms:
const resolved = await imr.resolve(dependency, pathToFileURL(process.cwd() + '/dummy.js'));
On my linux VM I get a path, on the other machine an exception. On this line
imr
is being imported from your library with:import * as imr from 'import-meta-resolve';
.Since I use Node 20, I tried changing the line to:
const resolved = import.meta.resolve(dependency, pathToFileURL(process.cwd() + '/dummy.js'));
And everything works on all machines.
For reference, this is the location of the call in the SvelteKit project: https://github.com/sveltejs/kit/blob/a6333a5d0833781c6572098a6240976e84fb5150/packages/kit/src/exports/vite/index.js#L134
I must admit I don't have a clue as to what causes the issue, in particular we have no space in the paths and they are reasonable in length (48 to 65 characters depending on platform).
Don't hesitate to let me know if there a place where I could look for more details to help solve this.
The text was updated successfully, but these errors were encountered: