rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

Add RFC: alternative format for package.json

Open Timmmm opened this issue 1 month ago • 4 comments

Draft RFC to add an alternative format for package.json that allows comments.

I need to look into the implementation, and I'm sure there will be bikeshedding over the actual format chosen.

Fixes #291

See also https://github.com/npm/cli/issues/8751

Timmmm avatar Nov 25 '25 20:11 Timmmm

As has been discussed elsewhere, if there's not a built-in way to node (or javascript) to work with a format, then it's going to be impractical for the entire ecosystem of tooling to work with it.

ljharb avatar Nov 25 '25 20:11 ljharb

The impact will be that if they want to support this optional format they need to install the json5 package (or whichever format we use). I don't understand how that is a significant issue.

Timmmm avatar Nov 25 '25 20:11 Timmmm

What npm supports, every tool effectively must support. Why force an additional package on the entire ecosystem? That's an incredibly high cost merely for slightly more ergonomic comments.

ljharb avatar Nov 25 '25 21:11 ljharb

What npm supports, every tool effectively must support.

This alternative format is optional. Third party tools can decide if they want to support it (potentially losing users) and users can decide if they want to use it (potentially losing third party tools).

Anyone that doesn't like it can happily continue using package.json as before.

slightly more ergonomic comments

It's not slightly more ergonomic comments. It's vastly more ergonomic comments for scripts and the top of the file, and it enables comments at all for dependencies which is where you really want them.

Timmmm avatar Nov 25 '25 21:11 Timmmm