Skip to content

Commit

Permalink
fix: load lazyLoadedDiagrams in initThrowsErrors
Browse files Browse the repository at this point in the history
Previously, calling initThrowsErrors would not
load any of the lazyLoadedDiagrams entries.
  • Loading branch information
aloisklink committed Oct 23, 2022
1 parent 9660b0e commit 4601c90
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/mermaid/src/mermaid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ const init = async function (
callback?: Function
) {
try {
const conf = mermaidAPI.getConfig();
if (conf?.lazyLoadedDiagrams && conf.lazyLoadedDiagrams.length > 0) {
// Load all lazy loaded diagrams in parallel
await Promise.allSettled(
conf.lazyLoadedDiagrams.map(async (diagram: string) => {
const { id, detector, loadDiagram } = await import(diagram);
addDetector(id, detector, loadDiagram);
})
);
}
await initThrowsErrors(config, nodes, callback);
} catch (e) {
log.warn('Syntax Error rendering');
Expand Down Expand Up @@ -82,6 +72,16 @@ const initThrowsErrors = async function (
mermaid.sequenceConfig = config;
}

if (conf?.lazyLoadedDiagrams && conf.lazyLoadedDiagrams.length > 0) {
// Load all lazy loaded diagrams in parallel
await Promise.allSettled(
conf.lazyLoadedDiagrams.map(async (diagram: string) => {
const { id, detector, loadDiagram } = await import(diagram);
addDetector(id, detector, loadDiagram);
})
);
}

// if last argument is a function this is the callback function
log.debug(`${!callback ? 'No ' : ''}Callback function found`);
let nodesToProcess: ArrayLike<HTMLElement>;
Expand Down

0 comments on commit 4601c90

Please sign in to comment.