-
Notifications
You must be signed in to change notification settings - Fork 239
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
package.json overrides option #39
Conversation
I like this for overriding these fields with unreserved +1:
I worry about updating the We should not allow overriding
I am wondering if we should allow overriding unspecified user fields as well. For example, it might be nice to be able to pass different configs to nyc or tap or babel based on node version. Of course, that means those tools would have to be aware of how overrides work, or use If we don't allow overriding user fields, then I think it's a good idea to explicitly limit exactly which fields are allowed in the overrides section, and raise an error if anything else is in there, to steer people away from footguns.
I agree. Since you can't override any of the fields used for filtering, it's unambiguous.
Yeah, I think we leave config and publishConfig out of it. So, the places where this needs to be implemented:
relation to other RFCsI was thinking that we'd need to call this something other than "overrides", since there is already an accepted RFC with that name, but as I think on this more, I kind of like this approach better than that one. I think a pretty good plan is maybe to ratify this, de-ratify the current overrides, and instead add a new RFC to implement yarn's resolutions with the same syntax and logic as yarn uses. Better to walk the existing cowpath than create another one. This is similar to #28, but much lighterweight and easier to implement. It is less powerful in the expression and filtering syntax, but I think that's a feature rather than a bug. |
For
One concern with allowing override of Although the same argument could be made about
Yes this would need to be clearly documented. Also I'm not sure if
I think npm should be agnostic on this for forward compatibility. If we raise an error on unknown/user fields it would be impossible to introduce new override-able fields in the future. A way to print warnings about unknown and user fields would be nice but I don't think an error would be good. Also I don't think it would be good to print those warnings by default. Especially
Probably a good idea at least to start. Maybe once overrides are a thing someone will give a good reason why it's needed. |
This should stipulate that overrides are a deep merge. Ie, if you have: {
"dependencies": {
"a": "1",
"b": "2"
},
"overrides": [
{
"engines": { "node": "<= 6" },
"dependencies": { "b": "1" }
}
]
} then on node v6, the Discussed in slack: how does this affect package-lock? Seems tricky, since it can lead to a combinatorial explosion if override filters aren't identical. Since |
A standard way to configure CI could be a solution to this. This would allow the CI environments and npm to have the same information. npm could use this information to generate a distinct list of My concern with only allowing semver-major for the overrides is that some authors will be pedantic. They might want to use |
Abandoned in favor of #72. |
Cross-posted to https://npm.community/t/package-json-overrides-option/9265