Adam S
07/20/2023, 11:08 AMdeclare namespace monaco.editor {
export function create(domElement: HTMLElement, options?: IStandaloneEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor;
}
I’ve written some Kotlin/JS external code to try and access this function:
@file:JsModule("monaco-editor")
@file:JsNonModule
@file:JsQualifier("monaco.editor")
@file:Suppress("ConvertObjectToDataObject")
import org.w3c.dom.HTMLElement
@JsName("create")
external fun createMonacoEditor(
domElement: HTMLElement,
options: IStandaloneEditorConstructionOptions = definedExternally,
override: IEditorOverrideServices = definedExternally,
): IStandaloneCodeEditor
However, I get an error.
Uncaught TypeError: Cannot read properties of undefined (reading 'editor')
Am I using @JsModule
, @JsNonModule
, and @JsQualifier
correctly?Adam S
07/20/2023, 11:15 AMvar __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
(function(root, factory) {
if (true)
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, __webpack_require__(/*! monaco-editor */
"../../node_modules/monaco-editor/esm/vs/editor/editor.main.js")],
__WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
else {}
}(this, function(_, $module$monaco_editor_si6jz9) {
'use strict';
//region block: imports
var create = $module$monaco_editor_si6jz9.monaco.editor.create; // ERROR Uncaught TypeError: Cannot read properties of undefined (reading 'editor')
// ...
turansky
07/20/2023, 2:19 PMSergei Grishchenko
07/24/2023, 9:25 AMmain
nor exports
block in their package json, so I think webpack can't figure out what file to take. I tried to explore examples in their repo , and I saw that vite or parsel examples use direct link to file. Maybe import * as monaco from 'monaco-editor'
works only with their webpack plugin.
Also @file:JsQualifier("monaco.editor")
is path inside your module, but in examples whole content of 'monaco-editor'
is imported as monaco
and monaco.editor.create(...
is used to get editor
object. So I propose to use @file:JsQualifier("editor")
, maybe it will work more correct.Piotr Krzemiński
07/24/2023, 10:04 AMSergei Grishchenko
07/24/2023, 10:09 AMAdam S
07/24/2023, 10:11 AMAdam S
07/24/2023, 10:12 AMSergei Grishchenko
07/24/2023, 10:16 AMCodeMirror
, it is more relevant for JB now (my project is fully open source, but I do it during work time partially, so I respect JB needs)Adam S
07/24/2023, 12:18 PM@file:JsQualifier("monaco.editor")
to @file:JsQualifier("editor")
, plus hacking around with Webpack, seems to have done the trick (mostly - there’s still something janky with the sizing). Thanks @Sergei Grishchenko!Dylan Meadows
08/31/2023, 8:23 PMAdam S
09/01/2023, 11:53 AMmanoj s
03/27/2024, 5:00 PM