Replies: 8 comments 4 replies
|
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! |
|
We tried to switch from package.json to package.json5, and we found this issue with Can we force pnpm to use json5? Any thoughts? |
|
I would also like to the support for this to improved. As it currently is, pnpm has support for I don't think it would be a good idea to change the preference order. That would be a breaking change that seems likely to just cause confusion for anyone who attempts this, also given different versions of pnpm involved (what version is reading the manifest file to resolve which version of pnpm to run for the actual commands, etc). I think it would be better with an explicit setting, naturally outside the manifest file itself. The @zkochan mentioned here that he's overall "not happy about all this different package.json file formats bloat", and I totally understand that position. Big fan of keeping things simple myself. As I expanded on there, I still think it's worth it to have a manifest format that allows comments – that's the main thing for me. Having two alternative formats seems especially a bit over the top. I'd be in favor of deprecating one of them. If it were completely up to me, I'd keep JSON5 – it just seems a much better fit for tooling in the Javascript ecosystem – but since YAML is already used in several places in pnpm, I'd see the argument for choosing that one. As JSON5 is still a supported format, however, I'd love to help out improving the support for it – see also this PR, which I think is ready to be reviewed. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Describe the user story
pnpm supports
package.yamlandpackage.json5since #1799. But, there are a bunch of npm packages that directly readpackage.jsonfile, hence cannot be used without additionalpackage.jsonfile.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.yamltopackage.jsonin order to allow some packages to find it (and we'd probably want to addpackage.jsonin.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.jsonfile when it's found, regardlesspackage.yamlis 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.yamlandpackage.json5beforepackage.json, so that this alternative manifest files are prefered topackage.json, which meanspackage.jsonwould be only read by some packages andpackage.yamlwould 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.yamlandpackage.jsonwould 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
manifestExtoption 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.All reactions