jscheid / prettier.el

Prettier code formatting for Emacs.
GNU General Public License v3.0
164 stars 11 forks source link

Can't find prettier with PnP in workspace child #46

Closed jscheid closed 3 years ago

jscheid commented 3 years ago

With the following setup:

workspace/package.json          # Workspace root with `"workspaces": ["child"]`
workspace/.pnp.js               # Dependency modules live at workspace root
workspace/child/package.json    # Workspace child with `"dependencies": { "prettier": "..." }`

getYarnPnpifyedLocalPrettier fails to find prettier because when it runs with directory workspace/child the checks for .pnp.js fail, because the .pnp.js file lives in the workspace root. It then tries the parent directory (workspace root), but there's no prettier dependency at that level, causing the following error:

Error: Your application tried to access prettier, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

@asbish since you wrote the PnP code, do you have any thoughts on how to best fix this? One idea is to check for package.json instead of .pnp.js and if found, run yarn config get pnpMode to decide whether PnP is enabled, wdyt?

asbish commented 3 years ago

Sorry I can't decide what is the best way now. I think yarn config get pnpMode is supported by yarn version 2.0.0-rc.30 and in the lower versions the command returns error(Usage Error: Couldn't find a configuration settings named "pnpMode").