From 8100090b17ae926e8d920bdec039e3953bc3a9e8 Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Sun, 27 Jan 2019 22:05:28 -0800 Subject: [PATCH] revert dynamic Codemirror mode import - Closes #653 --- lib/constants.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 = {