Description
I tried to use monaco-vim via the AMD approach exactly as described in the README, but the example does not work reliably in practice and throws runtime errors in the browser.
I’m not sure whether this is a documentation issue, a version compatibility problem with monaco-editor, or a limitation of the AMD build. I’m opening this issue to report the behavior and hopefully get guidance on the correct setup.
Steps to Reproduce
- Follow the AMD section in the README.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div
id="container"
style="width:800px;height:600px;border:1px solid grey"
></div>
<div id="status"></div>
<script src="https://unpkg.com/monaco-editor/min/vs/loader.js"></script>
<script>
require.config({
paths: {
vs: "https://unpkg.com/monaco-editor/min/vs",
"monaco-vim": "https://unpkg.com/monaco-vim@0.4.2/dist/monaco-vim.js",
},
});
require(["vs/editor/editor.main", "monaco-vim"], function (a, MonacoVim) {
var editor = monaco.editor.create(
document.getElementById("container"),
{
value: [
"function x() {",
'\tconsole.log("Hello world!");',
"}",
].join("\n"),
language: "javascript",
}
);
var statusNode = document.getElementById("status");
var vimMode = MonacoVim.initVimMode(editor, statusNode);
// remove vim mode by calling
// vimMode.dispose();
});
</script>
</body>
</html>
Observed Behavior
Case 1: Latest monaco-editor (from unpkg, no version pinned)
The example throws a runtime error and monaco-vim fails to initialize correctly (e.g. initVimMode is undefined or internal modules fail to resolve).
Case 2: Pinned monaco-editor@0.52.2
When I explicitly pin Monaco Editor to an older version:
<script src="https://unpkg.com/monaco-editor@0.52.2/min/vs/loader.js"></script>
<script>
require.config({
paths: {
vs: "https://unpkg.com/monaco-editor@0.52.2/min/vs",
"monaco-vim": "https://unpkg.com/monaco-vim@0.4.2/dist/monaco-vim.js",
},
});
</script>
I can use Vim mode successfully, and the editor behaves as expected.
However, the browser console still shows the following error during load:
Loading "vs/editor/common/commands/shiftCommand" failed
Despite this error, Vim keybindings continue to work.
Case 3: monaco-vim@0.4.4 (latest)
When switching to the latest version of monaco-vim (0.4.4) while still following the AMD example from the README, Vim mode does not work at all. This appears to be because the exported AMD module structure has changed in monaco-vim@0.4.4.
Expected Behavior
-
The AMD example in the README should either:
- work without runtime errors, or
- document which versions of
monaco-editor are compatible.
-
If certain internal Monaco modules (such as shiftCommand) are no longer available or intentionally private, this limitation should be clarified.
Description
I tried to use monaco-vim via the AMD approach exactly as described in the README, but the example does not work reliably in practice and throws runtime errors in the browser.
I’m not sure whether this is a documentation issue, a version compatibility problem with
monaco-editor, or a limitation of the AMD build. I’m opening this issue to report the behavior and hopefully get guidance on the correct setup.Steps to Reproduce
Observed Behavior
Case 1: Latest
monaco-editor(from unpkg, no version pinned)The example throws a runtime error and
monaco-vimfails to initialize correctly (e.g.initVimModeis undefined or internal modules fail to resolve).Case 2: Pinned
monaco-editor@0.52.2When I explicitly pin Monaco Editor to an older version:
I can use Vim mode successfully, and the editor behaves as expected.
However, the browser console still shows the following error during load:
Despite this error, Vim keybindings continue to work.
Case 3:
monaco-vim@0.4.4(latest)When switching to the latest version of
monaco-vim (0.4.4)while still following the AMD example from the README, Vim mode does not work at all. This appears to be because the exported AMD module structure has changed inmonaco-vim@0.4.4.Expected Behavior
The AMD example in the README should either:
monaco-editorare compatible.If certain internal Monaco modules (such as
shiftCommand) are no longer available or intentionally private, this limitation should be clarified.