Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Support Config.node false value #252

Closed
wants to merge 2 commits into from

Conversation

SuperOleg39
Copy link

Resolves #209.

Copy link
Contributor

@opl- opl- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem I have with this approach is that doing config.set('node', {}) will force the node property to never show up in the final config, which might end up being extremely confusing to a user who might not expect config.delete('node') to be the way to bring back the standard behavior. Similarly, using config.set('node', []) will cause even more weirdness to happen.

I see three potential solutions to this problem:

  • Ignore this and call it a feature,
  • Ignore any value other than false,
  • Override the config.set function and raise an error.

I'm not sure what the standard is in this library, so I'm just mentioning it and leaving any decisions up to the maintainers. If the first option is chosen, I'd recommend at least changing the documentation accordingly.

Comment on lines +845 to +846
You can set `node` option to object, or a `false` value.
`false` value always rewrite `config.node` object.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can set `node` option to object, or a `false` value.
`false` value always rewrite `config.node` object.
You can set the `node` option to an object, or a `false` value.
A `false` value always overrides the `config.node` chained map.

`false` value always rewrite `config.node` object.

```js
config.set('node', false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
config.set('node', false);
config.set('node', false);
// To use the value generated from `config.node` ChainedMap again
config.delete('node');

@@ -165,12 +166,21 @@ module.exports = class extends ChainedMap {
);
}

if (!omit.includes('node') && 'node' in obj) {
if (typeof obj.node === 'object') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true for obj.node == []. Though the input is unexpected it might cause issues.

@opl-
Copy link
Contributor

opl- commented Jun 8, 2020

I'd also like to mention the possibility of creating callable classes even though I feel it's rather hacky. Something like this could also be used for #222 (though that one could be resolved without weird hacks by introducing a breaking change and bumping the major).

@edmorley
Copy link
Member

edmorley commented Jul 1, 2020

@SuperOleg39 thank you for the PR and @opl- thank you for the really helpful review/thoughts. I don't use webpack day to day any more, so am reliant on suggestions as to what direction it should take longer term. I agree with @opl- 's thoughts about potentially confusing UX. What do you both think as the best option out of those that are proposed above?

@githoniel githoniel mentioned this pull request May 10, 2021
@edmorley
Copy link
Member

edmorley commented Feb 3, 2024

Closing since this project is no longer maintained:
#358

@edmorley edmorley closed this Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

Config.node is incorrectly assumed to always be an object
3 participants