-
Notifications
You must be signed in to change notification settings - Fork 73
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
feat: better support yarn PnP #839
Conversation
@danieltroger I published a prerelease for you test these changes out on your project, |
// Iterate on each workspace | ||
for (const locator of pnp.getDependencyTreeRoots()) { | ||
const foundSomething = traverseDependencyTree(locator) | ||
if (foundSomething) return foundSomething | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I referenced with
If there are multiple versions of the plugin that's trying to be found, the wrong one might be selected (root is ignored)
In #806
And I'm not sure if the issue is fixed?
Suppose that someone has two workspaces and they each contain a different version of the oclif plugin, this wouldn't necessarily take the oclif plugin in the correct workspace, but rather the first one found. This might lead to frustrating issues where someone updates their plugin version (in the workspace they have that oclif version installed in) but it doesn't do anything because oclif picks a workspace that has another version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danieltroger This might be a scenario where I prefer to wait until someone actually has this issue. Also I see this code path as a fallback for when people do not specify a main
or exports
, which is something we strongly advise against because it's much more performant to do a require.resolve
than it is to traverse the dependency tree for a matching plugin.
So if someone were to have such an issue, I would first suggest that they define main
or exports
in their package.json.
@mdonnalley Thanks a lot for following up on my issue report and working on support for yarn PnP! I removed my patch and tried to get the new version by running And now my
|
Ok I tracked down the config.plugins.map issue, it comes from this package: https://www.npmjs.com/package/@shopify/cli-kit And the required change is to change Before (crashes) After (works)
EDIT: this patch is wrong, don't use it. Correct one here: #839 (comment)
Add this to your package.json
|
Hmm, while the change I described above worked when doing it on the
|
@mdonnalley BTW, I think this is oclif code. It ate up the stack trace, which is highly annoying. I had to proxy console.error (which didn't really work because nodejs uses console.error inside of console.trace) and get a debugger to get the stack trace in the comment above, this is what it originally printed to the console |
Sorry for the insane spam. It was all my fault. I forgot This would be the correct patch:
|
Niiice, it works! @mdonnalley in summary:
|
@danieltroger Thanks for the feedback! I'll definitely take a look at the stack trace issue you mentioned. Other than that, that would you consider this ready to merge? |
Perfect. Yes, please merge! Thanks a lot for all the effort. Would appreciate if you could let shopify know once there's a release ready: Shopify/cli#3004 (comment) |
@danieltroger we just published 3.6.0 with this fix. Thanks again for your help on this! |
main
orexport
defined in their package.json.findRoot
related functionality into its own file for cleanliness purposesHuge thanks to @danieltroger for figuring out the implementation for this!
Fixes #806
@W-14331357@