-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Improve plugin resolution (fixes pnpm compatibility) #13583
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
Conversation
status: 0, | ||
write: [], | ||
}); | ||
}); |
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.
I don't think these tests are correctly testing the added part. The plugin search logic always starts from Prettier cli, if we want test, we'll have to put Prettier into those dirs. I don't know how to do that.
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.
I could be misunderstanding the code, but I think in run-prettier.js
the cwd gets set properly in run()
. Either way, if I log autoLoadDir
, it is set to the expected directory, so it does seem prettier is starting from the right directory.
src/common/load-plugins.js
Outdated
@@ -113,6 +142,20 @@ async function findPluginsInNodeModules(nodeModulesDir) { | |||
return pluginPackageJsonPaths.map(path.dirname); | |||
} | |||
|
|||
async function findPluginDirsInPnpmVirtualStore(searchDirectory) { | |||
const pluginPackageJsonPaths = await fastGlob( | |||
["prettier-plugin-*", "@*/node_modules"], |
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.
Shouldn't plugins also stored like prettier-plugin-foo@1.0.0
? I don't know how the @*/plugin-*
stored, but are you sure these patterns correct?
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.
In the pnpm virtual store, the three possible types of plugins (@prettier/plugin-*
, and @<name>/prettier-plugin-*
, prettier-plugin-*
) are stored like this:
.pnpm/
├── @prettier+plugin-foo@<version>/
│ └── node_modules/
│ └── @prettier/
│ └── plugin-foo/
├── @<name>+prettier-plugin-bar@<version>/
│ └── node_modules/
│ └── @<name>/
│ └── prettier-plugin-bar/
└── prettier-plugin-baz@<version>/
└── node_modules/
└── prettier-plugin-baz/
I don't think the +package-name
part of the directory used to be there, but now that it is, I can just have the patterns be ["prettier-plugin-*", "@prettier+plugin-*", "@*+prettier-plugin-*"]
.
@fisker Any chance this will be included in next? |
We haven't decided yet. But we are planning to remove plugin auto-load. @thorn0 |
Continuation of #11248