Skip to content

Commit 91aecfc

Browse files
committed
Handle syntax importing failure
1 parent 3742661 commit 91aecfc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/lib/CodeMirror.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ const dispatchModeLoad = debounce(() => {
2424
}, 300)
2525

2626
export async function requireMode(mode: string) {
27-
await import(`codemirror/mode/${mode}/${mode}.js`)
28-
dispatchModeLoad()
27+
try {
28+
await import(`codemirror/mode/${mode}/${mode}.js`)
29+
dispatchModeLoad()
30+
} catch (error) {
31+
console.warn(error)
32+
}
2933
}
3034

3135
export function getCodeMirrorTheme(theme?: string) {

0 commit comments

Comments
 (0)