You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Of course, that is impossible because comments are not allowed in JSON.
What is the feature you are proposing to solve the problem?
If Node could accept a file called package.js that contained a JS object with the same information as package.json, JS functionality like code comments could be leveraged. (This would also open a lot of possibilities to enable dynamic generation of the object.)
What alternatives have you considered?
I can't really think of an alternative that would be as good or better. The rest of Node.js is written in JS, making a .js file uniquely convenient.
The text was updated successfully, but these errors were encountered:
Kind of a duplicate of #41927. I think the same conclusion applies: if you want something like that to happen, it would need to have interest from the rest of the ecosystem, Node.js cannot decide unilaterally something like that.
Worth noting that reading a JSON file is much easier than executing a JS file (you don't need a JS runtime to parse JSON), JSON5 would probably be more reasonable – but would also come with its challenges.
This would also open a lot of possibilities to enable dynamic generation of the object.
You say that as it would be a good thing, but that sounds quite scary to me 😅
If Node could accept a file called package.js that contained a JS object with the same information as package.json, JS functionality like code comments could be leveraged
You give the example of devDependencies in the OP, FYI Node.js does not read this field at all: that's used by your package manager (npm, Yarn, pnpm, etc.), so they would need to support this new file format. Node.js itself has a very limited use of package.json files, see the docs for more info: https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions
I understand the desire here, but I don't think this is ever likely to happen, and certainly not any time in the next several years. I'm going to close this, but if anyone thinks that's too hasty and wants to discuss more, please comment or re-open.
What is the problem this feature will solve?
Without comments, dependencies are difficult to understand using a JSON structure.
For example, I have this set of
devDependencies
:By itself, it is difficult to understand the purpose of each package, and how the packages relate to one another.
It would be clearer if I could add comments to the file. Something like this:
Of course, that is impossible because comments are not allowed in JSON.
What is the feature you are proposing to solve the problem?
If Node could accept a file called
package.js
that contained a JS object with the same information aspackage.json
, JS functionality like code comments could be leveraged. (This would also open a lot of possibilities to enable dynamic generation of the object.)What alternatives have you considered?
I can't really think of an alternative that would be as good or better. The rest of Node.js is written in JS, making a .js file uniquely convenient.
The text was updated successfully, but these errors were encountered: