Skip to content

Commit

Permalink
feat(core): allow configureWebpack to return undefined (#6784)
Browse files Browse the repository at this point in the history
* plugin: not acquire configureWebpack to return

* type fix

* add test

* remove type

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
  • Loading branch information
yorkie and Josh-Cena authored Mar 22, 2022
1 parent 1777fc4 commit 6b3d94a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/docusaurus/src/webpack/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
8 changes: 2 additions & 6 deletions packages/docusaurus/src/webpack/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 6b3d94a

Please sign in to comment.