diff --git a/lib/constants.js b/lib/constants.js index 4fa25b9..2696675 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -908,8 +908,18 @@ const unfold = (f, seed) => { }` if (typeof window !== 'undefined' && typeof window.navigator !== 'undefined') { - require(`codemirror/mode/javascript/javascript`) - import('./modes') + const alreadyLoaded = new Set() + + LANGUAGES.filter(language => language.mode !== 'auto' && language.mode !== 'text').forEach( + language => { + if (language.mode && !alreadyLoaded.has(language.mode)) { + alreadyLoaded.add(language.mode) + language.custom + ? require(`./custom/modes/${language.mode}`) + : require(`codemirror/mode/${language.mode}/${language.mode}`) + } + } + ) } export const DEFAULT_SETTINGS = {