-
-
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
[Bug] PnP error with virtual packages #1524
Comments
I've been looking into this a bit. TL;DR: I think we need to pass the found pnp API path through VirtualFS.resolveVirtual It appears to me that the issue lies in the part of the pnpapi that finds the pnpapi for the issuer.
The pnpapi starts looking for a pnpapi to load and it finds one at
and that's when stuff starts getting weird. That eslint plugin requires
When that file requires
-> issuer is the top-level workspace, which doesn't depend on I've hacked together a dirty dirty dirty solution: hacky hacky diffdiff --git a/.pnp.js b/.pnp.js
index eb20628..c1d3e60 100755
--- a/.pnp.js
+++ b/.pnp.js
@@ -20129,30 +20129,36 @@ function makeManager(pnpapi, opts) {
function findApiPathFor(modulePath) {
const start = sources_path/* ppath.resolve */.y1.resolve(sources_path/* npath.toPortablePath */.cS.toPortablePath(modulePath));
let curr;
let next = start;
do {
curr = next;
const cached = findApiPathCache.get(curr);
if (cached !== undefined) {
addToCache(start, curr, cached);
return cached;
}
+ const match = curr.match(/\/\$\$virtual\/[^/]+\/1\/?$/);
+ if (match != null) {
+ next = curr.slice(0, match.index);
+ continue;
+ }
+
const candidate = sources_path/* ppath.join */.y1.join(curr, `.pnp.js`);
if (xfs.existsSync(candidate) && xfs.statSync(candidate).isFile()) {
addToCache(start, curr, candidate);
return candidate;
}
const cjsCandidate = sources_path/* ppath.join */.y1.join(curr, `.pnp.cjs`);
if (xfs.existsSync(cjsCandidate) && xfs.statSync(cjsCandidate).isFile()) {
addToCache(start, curr, cjsCandidate);
return cjsCandidate;
}
next = sources_path/* ppath.dirname */.y1.dirname(curr); which is basically a simplified version of I've got a small test script that mocks the behaviour of eslint: test scriptconst {createRequire} = require('module');
const packages = [
'@scope/eslint-plugin',
'@typescript-eslint/parser',
'@typescript-eslint/typescript-estree',
];
let loc = __filename;
for (const pkg of packages) {
const require = createRequire(loc);
loc = require.resolve(pkg);
console.log(`${pkg} => ${loc}`);
console.log('');
} Without the hack above, this yields
with the hack it's
So, long story short: I think we need to pass the found pnp API path through VirtualFS.resolveVirtual |
Oh wow, that's a fun one 😅 Thanks for digging, I'll make a fix 👍 |
I'm sorry for the vague issue title, but I don't really get what's going wrong so…
Describe the bug
I've got a repo which contains, among other things, an eslint plugin that contains configuration that uses
@typescript-eslint
. The repo uses the plugin in its own configuration.Trying to run eslint results in an error
Everything worked fine when both the repo root and
pkg
only depend oneslint
and@typescript-eslint
, but adding dev dependencies on@angular/core
(which peer depends onrxjs
andzone.js
) suddenly leads to the error posted above.I don't see what's wrong on my end or in the
@typescript-eslint
packages: dependencies appear to be listed correctly.If it does turn out to be a mistake on my end / in one of the dependencies, the error message is quite confusing: the code in question is definitely not part of my root workspace.
To Reproduce
Clone https://github.com/bgotink/yarn-pnp-error-repro.git, run
yarn eslint pkg
.The text was updated successfully, but these errors were encountered: