monaco-editor-auto-typings icon indicating copy to clipboard operation
monaco-editor-auto-typings copied to clipboard

[BUG] TypeError: path.dirname is not a function

Open kalcow opened this issue 2 years ago • 1 comments

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 Screenshot 2023-09-14 at 10 55 13 PM

Environment:

  • OS: MacOS
  • Browser Version: 116.0.5845.187 (Official Build) (arm64)
  • monaco-editor-auto-typings Version: "^0.4.4",
  • monaco-editor Version: "^0.43.0",

kalcow avatar Sep 15 '23 05:09 kalcow

https://github.com/lukasbach/monaco-editor-auto-typings/issues/25

hiteshjoshi avatar Dec 21 '23 14:12 hiteshjoshi