Totally confused by this example in react-codemirror2 which uses both import and require syntax;
[See https://github.com/scniro/react-codemirror2 in the section requiring codemirror resources]
import CodeMirror from 'react-codemirror2';
require('codemirror/mode/xml/xml');
require('codemirror/mode/javascript/javascript');
I know the require('codemirror/etc') stuff is referring to a plain JS library dependency (not React specific), but why does require even work without throwing an error?
Can the require be replaced by an import?
How to make the warning in VS Code editor go away?

The main idea of this part of the Docs is that you need to require by yourself CodeMirror modules that you needed (it means that if you need a javascript mode or autocomplete, you need to add these modules to your code).
react-codemirror2doc says that:In most cases, both
requireandimportwill do the same, so you can use the code that is given inreact-codemirror2docs:or use its analog with imports: