From 4c5e708977df23a252239ae8ad4ad10296e6ef6a Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Thu, 22 Feb 2024 07:39:46 -0800 Subject: [PATCH] Desktop: Beta editor plugin API: Fix plugins unable to require nodeJS modules (#9968) --- packages/editor/CodeMirror/pluginApi/codeMirrorRequire.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/editor/CodeMirror/pluginApi/codeMirrorRequire.ts b/packages/editor/CodeMirror/pluginApi/codeMirrorRequire.ts index c9fb1c71f..319cc89d5 100644 --- a/packages/editor/CodeMirror/pluginApi/codeMirrorRequire.ts +++ b/packages/editor/CodeMirror/pluginApi/codeMirrorRequire.ts @@ -42,6 +42,12 @@ const codeMirrorRequire = (library: string) => { return libraryNameToPackage[library]; } + // Although window.require doesn't work on mobile, some desktop-only plugins + // originally developed for CodeMirror 5 rely on it. + if (typeof window.require === 'function') { + return window.require(library); + } + throw new Error(`Cannot find library ${library}`); };