monaco-editor-auto-typings
monaco-editor-auto-typings copied to clipboard
[BUG] TypeError: path.dirname is not a function
Describe the bug Simply trying to instantiate the extension with a Monaco Editor instance in Svelte. Following the instructions in the readme
To Reproduce
Paste the following code into any svelte file. If not using svelte you should be able to copy and paste the imports and contents of the onMount function into any ts file and run from there.
<script lang="ts">
import type monaco from 'monaco-editor';
import { onMount } from 'svelte';
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
import { AutoTypings } from 'monaco-editor-auto-typings';
let divEl: HTMLDivElement;
let editor: monaco.editor.IStandaloneCodeEditor;
let monaco;
onMount(async () => {
self.MonacoEnvironment = {
getWorker: function (_moduleId: any, label: string) {
if (label === 'typescript' || label === 'javascript') {
return new tsWorker();
}
return new editorWorker();
}
};
monaco = await import('monaco-editor');
const value = `import { onMount } from 'svelte'\nlet count = 0; \nfunction add() {\n\tcount++;\n\treturn count;\n}`;
editor = monaco.editor.create(divEl, {
model: monaco.editor.createModel(value, 'typescript')
});
const autoTypings = await AutoTypings.create(editor, {
// sourceCache: new LocalStorageCache()
});
return () => {
editor.dispose();
};
});
</script>
<div bind:this={divEl} />
Expected behavior I'm expecting it to work like the demo, but I might be missing something that is causing the error. I double checked with the docs but it seems like what I have should be what's needed.
Screenshots
Getting this error in Chrome Dev Tools
Environment:
- OS: MacOS
- Browser Version: 116.0.5845.187 (Official Build) (arm64)
monaco-editor-auto-typingsVersion: "^0.4.4",monaco-editorVersion: "^0.43.0",
https://github.com/lukasbach/monaco-editor-auto-typings/issues/25