Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kalcow opened this issue Sep 15, 2023 · 1 comment
Open

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

kalcow opened this issue Sep 15, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@kalcow
Copy link

kalcow commented Sep 15, 2023

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 kalcow added the bug Something isn't working label Sep 15, 2023
@hiteshjoshi
Copy link

#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants