mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-20 11:37:52 +02:00
refactor(v2): avoid synchronous/ blocking operation when possible (#1957)
* perf(v2): avoid synchronous/ blocking operation when possible * save variable
This commit is contained in:
parent
5e445a0011
commit
1235fc9f7e
6 changed files with 85 additions and 76 deletions
|
@ -5,7 +5,6 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import importFresh from 'import-fresh';
|
||||
import {
|
||||
SidebarItemCategory,
|
||||
|
@ -105,7 +104,7 @@ function normalizeSidebar(sidebars: SidebarRaw): Sidebar {
|
|||
export default function loadSidebars(sidebarPath: string): Sidebar {
|
||||
// We don't want sidebars to be cached because of hotreloading.
|
||||
let allSidebars: SidebarRaw = {};
|
||||
if (sidebarPath && fs.existsSync(sidebarPath)) {
|
||||
if (sidebarPath) {
|
||||
allSidebars = importFresh(sidebarPath) as SidebarRaw;
|
||||
}
|
||||
return normalizeSidebar(allSidebars);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue