-
-
Notifications
You must be signed in to change notification settings - Fork 85
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: yarn3+ pnp support #316
Conversation
f5a5e10
to
9364c94
Compare
08d1720
to
cb55980
Compare
I'm just testing this PR locally and what exactly is the error you're seeing currently? It looks like there's an error when trying to import // repro.mjs
await import("file:///home/hiroshi/.yarn/berry/cache/vitest-npm-1.4.0-465b7cb84c-10c0.zip/node_modules/vitest/dist/node.js") yarn node repro.mjs$ yarn node repro.mjs
node:internal/process/esm_loader:34
internalBinding('errors').triggerUncaughtException(
^
Error: vitest tried to access pathe, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Required package: pathe (via "pathe/package.json")
Required by: vitest@npm:1.4.0 (via /home/hiroshi/.yarn/berry/cache/vitest-npm-1.4.0-465b7cb84c-10c0.zip/node_modules/vitest/dist/node.js)
at makeError (/home/hiroshi/code/others/vitest-vscode/samples/yarn-pnp/.pnp.cjs:7353:34)
at resolveToUnqualified (/home/hiroshi/code/others/vitest-vscode/samples/yarn-pnp/.pnp.cjs:9001:21)
at Object.resolveToUnqualified (/home/hiroshi/code/others/vitest-vscode/samples/yarn-pnp/.pnp.cjs:9181:26)
at resolve$1 (file:///home/hiroshi/code/others/vitest-vscode/samples/yarn-pnp/.pnp.loader.mjs:1993:31)
at nextResolve (node:internal/modules/esm/hooks:865:28)
at Hooks.resolve (node:internal/modules/esm/hooks:303:30)
at handleMessage (node:internal/modules/esm/worker:196:24)
at checkForMessages (node:internal/modules/esm/worker:138:28)
at process.<anonymous> (node:internal/modules/esm/worker:157:5)
at process.emit (node:events:518:28) So, I'm wondering if we can just use From my testing, it looks like it's working after replacing this Line 77 in dad5884
with if (process.versions.pnp) {
meta.vitestNodePath = "vitest/node";
}
await import(meta.vitestNodePath) Also, loader setup here is not necessary since Lines 113 to 114 in dad5884
|
This option is deprecated in the latest Node.js version:
If we use |
cb55980
to
8161ad1
Compare
@sheremet-va Should we push the first version as of now and create another PR for removing the deprecated option? The proposal by @hi-ogawa just worked. I am investigating one issue with workspaces where vitest is not detected for yarn. I can push it here as soon as I have fixed it. |
I don't see a reason why we shouldn't do it here |
@sheremet-va ok. I am checking the extension against another project I have, and it is not working. I will debug that first, and then I will get back to this case. One thing I just found is that |
8161ad1
to
b2104c6
Compare
Hi @hi-ogawa and @sheremet-va. I did not find time to work on this in the past few weeks, but I started looking into it today. Before I continue, I would like to check whether my understanding is correct below. Please also let me know if you have better suggestions. From now on, the main idea is to use However, I noticed that the extension is somewhat "coupled" to the Vitest instance. For example, That said, do you have any suggestions on how I should proceed? I welcome any ideas so I can provide a solution that is aligned with your project plans. Thanks in advance! |
The idea is not to use yarn to run tests, the idea is to use yarn exec to spawn the worker.js file, then the only thing you need to figure out is communication with that file. |
Support added in #456 |
Closes #285.