Skip to content

Commit ef14a7c

Browse files
authored
refactor: use base resolver to resolve config (#1858)
1 parent d7c6930 commit ef14a7c

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

packages/webpack-cli/lib/webpack-cli.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class WebpackCLI extends GroupHelper {
1818
constructor() {
1919
super();
2020
this.groupMap = new Map();
21-
this.args = {};
2221
this.compilation = new Compiler();
2322
this.compilerConfiguration = {};
2423
this.outputConfiguration = {};
@@ -60,21 +59,9 @@ class WebpackCLI extends GroupHelper {
6059
coreCliHelper.processArguments(coreCliArgs, this.compilerConfiguration, coreConfig);
6160
}
6261

63-
/**
64-
* Responsible for resolving config
65-
* @private\
66-
* @param {Object} processed args
67-
* @returns {void}
68-
*/
69-
async _handleConfig(parsedArgs) {
70-
const resolvedConfig = await handleConfigResolution(parsedArgs);
71-
this._mergeOptionsToConfiguration(resolvedConfig.options);
72-
this._mergeOptionsToOutputConfiguration(resolvedConfig.outputOptions);
73-
}
74-
75-
async _baseResolver(cb, parsedArgs, configOptions) {
76-
const resolvedConfig = cb(parsedArgs, configOptions);
77-
this._mergeOptionsToConfiguration(resolvedConfig.options);
62+
async _baseResolver(cb, parsedArgs, strategy) {
63+
const resolvedConfig = await cb(parsedArgs, this.compilerConfiguration);
64+
this._mergeOptionsToConfiguration(resolvedConfig.options, strategy);
7865
this._mergeOptionsToOutputConfiguration(resolvedConfig.outputOptions);
7966
}
8067

@@ -226,9 +213,9 @@ class WebpackCLI extends GroupHelper {
226213
async runOptionGroups(parsedArgs) {
227214
await Promise.resolve()
228215
.then(() => this._handleDefaultEntry())
229-
.then(() => this._handleConfig(parsedArgs))
230-
.then(() => this._baseResolver(resolveMode, parsedArgs, this.compilerConfiguration))
231-
.then(() => this._baseResolver(resolveOutput, parsedArgs, {}, outputStrategy))
216+
.then(() => this._baseResolver(handleConfigResolution, parsedArgs))
217+
.then(() => this._baseResolver(resolveMode, parsedArgs))
218+
.then(() => this._baseResolver(resolveOutput, parsedArgs, outputStrategy))
232219
.then(() => this._handleCoreFlags())
233220
.then(() => this._baseResolver(basicResolver, parsedArgs))
234221
.then(() => this._handleGroupHelper(this.advancedGroup))

0 commit comments

Comments
 (0)