Skip to content
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

fix: warn about merge config resolution cases #1674

Merged
merged 10 commits into from
Jul 21, 2020

Conversation

anshumanv
Copy link
Member

What kind of change does this PR introduce?

fix

Did you add tests for your changes?
Yes

If relevant, did you update the documentation?
NA

Summary

  • Right now if merge config is absent, no feedback is given to user when it's absent or when we fallback to default merge config, fix it

Does this PR introduce a breaking change?
No

Other information

@anshumanv anshumanv requested a review from a team as a code owner July 8, 2020 03:55
@anshumanv anshumanv changed the title fix: wanr about merge config resolution cases fix: warn about merge config resolution cases Jul 8, 2020
Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Looks good, but I think we should discuss about configuration files. We have webpack.config.development.js, we have webpack.base.js, we have configurations from .webpack directory. It can be very misleading for developers.

We should provide clear and logical hierarchy structure.

Maybe we should not fallback to webpack.base.js here. Just throw an error what we don't find the configuration, because it can be misleading for developers too

@anshumanv
Copy link
Member Author

Maybe we should not fallback to webpack.base.js here. Just throw an error what we don't find the configuration, because it can be misleading for developers too

Agree, but .base is usually used to keep shared config for prod and dev env, which is eventually merged with the respective config hence this fallback was added in past I think, we're already notifying user in case we fallback, what do you think? @evilebottnawi

@alexander-akait
Copy link
Member

@anshumanv Do we have this logic for v3?

@anshumanv
Copy link
Member Author

@anshumanv Do we have this logic for v3?

No, we don't. Should we remove fallback?

@rishabh3112
Copy link
Member

I think we shouldn't fallback as well, Developer never intends to use .base config as a standalone configuration.

@alexander-akait
Copy link
Member

@anshumanv Let's discuss about it. What configuration files do we have and how are they inherited and them priorities? Maybe we can do simple drawing/picture?

@anshumanv
Copy link
Member Author

Developer never intends to use .base config as a standalone configuration.

Using as standalone is out of the picture

@anshumanv
Copy link
Member Author

@anshumanv Let's discuss about it. What configuration files do we have and how are they inherited and them priorities? Maybe we can do simple drawing/picture?

Yep we can, I'll come up with it in a while 👍

@anshumanv
Copy link
Member Author

[
    'webpack.config',
    'webpack.config.dev',
    'webpack.config.development',
    'webpack.config.prod',
    'webpack.config.production',
    '.webpack/webpack.config',
    '.webpack/webpack.config.none',
    '.webpack/webpack.config.dev',
    '.webpack/webpack.config.development',
    '.webpack/webpack.config.prod',
    '.webpack/webpack.config.production',
    '.webpack/webpackfile',
]

@evilebottnawi this the order of priority of files, in increasing order of priority.

eg if webpack.config.* is present and .webpack/webpackfile.* are present, then webpackfile will be resolved during config lookup as it has max priority while webpack.config.* has least priority in this list

We do not resolve for .base while config lookup, hence I think that was added as a fallback file for merge strategy when the supplied config in the merge flag doesn't exist.

@anshumanv
Copy link
Member Author

Also, should we document it somewhere for future reference, it's present in code only for now.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

I think we should change logic for this, it is the interesting case, when I use

webpack --config' './1.js', '--config' './2.js

I would think that we want to run both configurations, like multi compiler mode.

But, if i write

webpack --merge --config' './1.js', '--config' './2.js

I want to merge configurations.

I think this logic is simpler and clearer.

If configuration doesn't exists in --config we should always throw an error.

Also provide --config options disable auto resolving configurations, because I have clearly indicated that I want to use.

And yes we should documented configurations and their priority

@anshumanv
Copy link
Member Author

I think we should change logic for this, it is the interesting case, when I use

webpack --config' './1.js', '--config' './2.js
I would think that we want to run both configurations, like multi compiler mode.

But, if i write

webpack --merge --config' './1.js', '--config' './2.js
I want to merge configurations.

I think this logic is simpler and clearer.

If configuration doesn't exists in --config we should always throw an error.

Also provide --config options disable auto resolving configurations, because I have clearly indicated that I want to use.

And yes we should documented configurations and their priority

@evilebottnawi that makes sense, there are a several steps involved to achieve that, let's do them bit by bit.

I'll start by removing the fallback to base config from here, just the error message that the merge config is not found should be good for now.

@anshumanv
Copy link
Member Author

@evilebottnawi are there any cases when the user only wants to merge to one config and use another as is?

Eg - webpack --config webpack1.config.js --config webpack2.config.js --merge webpack.base.js

In this case the user only intends to merge base config with webpack2.config.js, are such cases possible?

@alexander-akait
Copy link
Member

Eg - webpack --config webpack1.config.js --config webpack2.config.js --merge webpack.base.js

I don't think we should support is, because it is misleading, if you want to more three configuration, you can use

webpack --config webpack1.config.js --config webpack2.config.js --config webpack.base.js --merge

If you want to run 3 configuration:

webpack --config webpack1.config.js --config webpack2.config.js --config webpack.base.js --merge

If you want to merge first and second configurations, use code for this, no need handle very complex logic

@anshumanv
Copy link
Member Author

anshumanv commented Jul 13, 2020

If you want to merge first and second configurations, use code for this, no need handle very complex logic

Seems fair @evilebottnawi , I've dropped the support for fallback to default config in merge here, will add support for multi config after this. 👍

expect(stats.isFile()).toBe(true);
done();
});
});
Copy link
Member

@alexander-akait alexander-akait Jul 21, 2020

Choose a reason for hiding this comment

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

Let's override the other option, for example filename, too

Copy link
Member Author

Choose a reason for hiding this comment

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

added 1fdf2ae 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants