-
Notifications
You must be signed in to change notification settings - Fork 240
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
RFC for parent package.json #165
base: main
Are you sure you want to change the base?
Conversation
Some initial thoughts:
I'll look more into how Maven and Gradle do this, see if there's any inspiration we can draw there. I can certainly see the utility in projects using workspaces with a lot of repetition. (We have this ourselves in npm, where a bunch of our packages all have a lot of the same fields.) |
First of all, thank you very much for getting back to this. My kinda initial reaction, I will try to see what I can do on the weekend, but I do not know much about the inner workings of npm, so mistakes will be made along the way :) Also, I I know my idea is probably impossible as is, because I mostly just thought about what would be helpful, not reasonable.
Interesting idea. I will try to figure out how Maven handles this. I guess your objection is that this might spiral out of control right?
Could this be circumvented when resolving the parent package.json at install? Since then npm would try to get a published version from cache or the registry...
I see two options:
Although, the proposal goes in a different direction it might make sense to think about creating a specific format for parents. This would prevent extending from unsuspecting packages. This would also allow to add specific metadata, which might make resolution easier.
I am sorry, but I am not sure I understand what you mean here. Do you mean building a resolved package.json before publishing it to the registry?
Thanks. I will try to update the RFC this weekend. It is encouraging you can see the utility too, so I was not entirely on the wrong track. Thanks again and looking forward to shaping this out further. |
@isaacs I updated the proposal and hopefully addressed some of your points. |
As per the meeting conversation, a partial solution you might use with features that exist now is installing packages as relative paths to packages installed top level: https://docs.npmjs.com/files/package.json#local-paths |
I updated the RFC as discussed during the last meeting. It slimmed down tremendously, but also has a couple new facets. |
If we resolve parent packages at install time, it gets us into very brittle territory. I do not share your confidence that no one will be foolhardy enough to So, a package might be unpublished. That would be unfortunate, but could happen, and likely not much worse than a dependency going away. So, not a great user experience, but not particularly hazardous, as things go. It would mean that we'd have to start tracking I have two much larger concerns about this. The first is about resolving So, I have package Let's say our project depends on In fact, since a new version of an extended package could be installed at any point during the install process, you might even have two duplicated instances of the same package at the same version that are actually different. Nailing down any kind of consistency guarantee wouldn't be impossible, but it'd be quite a lot of complex moving parts to get exactly right, both on the registry and in the CLI. I wouldn't want to sign up for that, personally, and it'd take much more work to implement. If we instead say that extension only is allowed for the root project, and that the |
@isaacs I agree. I had already updated my RFC last weekend, because of what was discussed on Wednesday. I don't know, did I miss something when updating the PR? I do agree that the resolution should happen completely during The draft now basically says that resolving happens during One of the interesting cases I guess would be if you extend package |
So, I tried my best to incorporate as much of the feedback from today's meeting as possible. Here are the things I (hopefully) addressed:
I hope there's no feedback I have missed to incorporate. Otherwise, please let me know and I am terribly sorry. BTW: I just installed npm 7, it works great so far and it made me already close an RFC I wrote this afternoon. 👍 |
(as discussed in the RFC call today) Currently, package.json is static, which means that tools like https://github.com/browserify/resolve (which i maintain) are able to both synchronously and asynchronously make resolution decisions based on their contents. Even if npm were to provide a new API - both async and, scarily, sync - that provided the fully flattened package.json contents - it would be a significant burden on the JS ecosystem to have to adapt to this. An alternative that was suggested was having package.json remain static, but having a different file that npm uses, when needed, to generate a static, flat package.json. This would effectively sidestep almost any tooling impact, since the only tools that would have to change are ones that validate or write to package.json (where they'd possibly want to validate the source manifest, and where they'd definitely want to write to the source manifest). |
@ljharb I think I see what the problem is. Thanks for bringing that issue up. I will try to incorporate this into the RFC. |
@ljharb I have updated the RFC. This should mitigate tooling impact. It would be cool if you could give it a read and give me some feedback. One problem I see is what happens when a user edits |
@Christian24 do you mind if I pick this up? The npm team presented a roadmap for upcoming releases and this was not on it. I really think this one is great, and I would be happy to co-champion it with you or take it over completely depending on your availability and desires. |
Hey @Christian24, since I haven't heard back on this I am going to assume it is alright if I pick it up. I am not sure if I can re-use your existing PR (I will try), but I will for sure keep your commits if I have to open a new PR. |
Of course not! I am currently on vacation, so sorry for the late reply.
I would surely help if you need a helping hand.
…________________________________
Von: Wes Todd ***@***.***>
Gesendet: Dienstag, 14. Juni 2022, 01:53
An: npm/rfcs ***@***.***>
Cc: Christian24 ***@***.***>; Mention ***@***.***>
Betreff: Re: [npm/rfcs] RFC for parent package.json (#165)
@Christian24<https://github.com/Christian24> do you mind if I pick this up? The npm team presented a roadmap for upcoming releases and this was not on it. I really think this one is great, and I would be happy to co-champion it with you or take it over completely depending on your availability and desires.
—
Reply to this email directly, view it on GitHub<#165 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AASLR2YTCQB7MXO2OAYLLDDVO57SRANCNFSM4N4O4YSA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Even though the discussions on this repository seem to be more ore less dead I came here over an annoying default behaviour of |
What / Why
Adds an RFC for parent package.json which allows multiple packages to inherit fields/properties from a parent package.json similar to Maven or Gradle.
This is my first RFC. It's certainly not perfect, however I do hope it helps to kickstart the conversation on resolving some of the issues I mention in the RFC.
Feel free to make edits or give constructive feedback.
Looking forward to get into a conversation with all of you,
Christian
References