feat(core): allow configureWebpack to return undefined (#6784)

* plugin: not acquire configureWebpack to return

* type fix

* add test

* remove type

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
Yorkie Liu 2022-03-22 11:53:11 +08:00 committed by GitHub
parent 1777fc4d76
commit 6b3d94a155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -74,7 +74,7 @@ describe('extending generated webpack config', () => {
filename: 'new.bundle.js',
};
}
return {};
// Implicitly returning undefined to test null-safety
};
config = applyConfigureWebpack(configureWebpack, config, false, undefined, {

View File

@ -184,12 +184,8 @@ export function applyConfigureWebpack(
getJSLoader: getCustomizableJSLoader(jsLoader),
};
if (typeof configureWebpack === 'function') {
const {mergeStrategy, ...res} = configureWebpack(
config,
isServer,
utils,
content,
);
const {mergeStrategy, ...res} =
configureWebpack(config, isServer, utils, content) ?? {};
if (res && typeof res === 'object') {
const customizeRules = mergeStrategy ?? {};
return mergeWithCustomize({