pnpm / pnpm

Fast, disk space efficient package manager
https://pnpm.io
MIT License
29.75k stars 1.01k forks source link

Allow comments in package.json #8369

Open Bald-guy69 opened 3 months ago

Bald-guy69 commented 3 months ago

Contribution

Describe the user story

Sometimes I want to add some comments to my package.json, it is very helpful when handling a large project and monorepos.

Describe the solution you'd like

Simply allow comments in package.json. When pnpm uses package.json, automatically ignore all the comments in package.json.

Describe the drawbacks of your solution

This may make your project only work with pnpm, not with other package management tools. But I think it's cool, at least for me.

Describe alternatives you've considered

It's cool, and I think this is an optional function. Since if you want to use both pnpm and other package managment tool, you won't add any comments.

NotYoojun commented 3 months ago

It would be really helpful to me if this feature is available.

rlidwka commented 1 month ago

This is a duplicate of earlier issue: https://github.com/pnpm/pnpm/issues/2359. Right now, you can use package.json5 or package.yaml that allow comments, and it'll be transpiled to json as needed.

Take note that since April 2024, bun supports comments in package.json (I've just found it out while researching similar thing for deno).

Perhaps, this issue needs to be reconsidered now, since would be nice if all tools settled on a single way of commenting out dependencies (instead of pnpm using json5, bun using json but with comments, and npm sticking with their regular-json "//comment" keys).

zkochan commented 1 month ago

I am not sure this is up to npm or pnpm. Node.js should be able to read the package.json file for fields like "type". The best we can do is generate a traditional package.json file from a more advanced format.