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: Prefer package.yaml
(or .json5
) to package.json
when both are present
#5541
Comments
Pryvit i dobroho ranku, @zkochan! Please, let me create a YAML file with a |
FWIW, we're migrating to pnpm specifically for JSON5 support, but this issue prevents us from even using workarounds of compiling package.json for everything that needs it. We're holding off on our migration until then. |
Dobryi den', @zkochan! Any news about this choice of YAML over JSON? |
@bmulholland, what other tools are you using that already support it? |
When both files (
So preferring Are you're worrying about performance for the extra |
@rlidwka We have a package.json5 that is really only used by us, developers. I wrote a short script that compiled the JSON5 to package.json. That's the only tool that really uses or touches it. It adds a step to any change we make to our package.json(5), but it's well worth it -- the whole thing is probably 25% comments and they're all so useful. FYI: It also means that we can't really use version pinning in our package.json, at least if we use Dependabot upgrades, which goes against the grain of the JS community. That's alright with us, we set version pins to "latest," which is IMHO what all applications (i.e. not packages others depends on) should use. Different discussion, point is that it works for us but has blockers for most people following more standard conventions. Here's our
I think this also makes the point about why comments in these files are useful! |
Describe the user story
pnpm supports
package.yaml
andpackage.json5
since #1799. But, there are a bunch of npm packages that directly readpackage.json
file, hence cannot be used without additionalpackage.json
file.I think, as an end user, the best way to handle this issue is using some monitoring tools and/or converters to automatically convert
package.yaml
topackage.json
in order to allow some packages to find it (and we'd probably want to addpackage.json
in.gitignore
). In my opinion, it's barely possible to hope every single packages there to support alternative manifest files because of its little popularity (and the presence of YAML haters).However, this workaround is currently not very doable in the real life because pnpm tries to read and write
package.json
file when it's found, regardlesspackage.yaml
is at the same place or not. It makes an additional json-to-yaml converter to be required and makes the workaround very complicate.Describe the solution you'd like
Make @pnpm/read-importer-manifest and @pnpm/write-importer-manifest to find
package.yaml
andpackage.json5
beforepackage.json
, so that this alternative manifest files are prefered topackage.json
, which meanspackage.json
would be only read by some packages andpackage.yaml
would be modified and read most of the time.Describe the drawbacks of your solution
I think most of the project which has both of
package.yaml
andpackage.json
would eventually benefit by this change, but it can introduce breaking change and unexpected behavior.Describe alternatives you've considered
Adding
--manifest-ext (json|yaml|json5)
option to pnpm CLI: It'd be inconvenient because it probably should be followed to every pnpm commands.Adding
manifestExt
option topnpm-workspace.yaml
: Seems not bad at least for me, but I'm not sure if this is proper config file to have this kind of option.The text was updated successfully, but these errors were encountered: