lukasbach / monaco-editor-auto-typings

Automatically load declaration files while typing in monaco editor instances
https://lukasbach.github.io/monaco-editor-auto-typings/
MIT License
181 stars 39 forks source link

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

Open ClintH opened 1 year ago

ClintH commented 1 year ago

I'm also having the error as #9, 'path.dirname is not a function'. I have tried importing from 'monaco-editor-auto-typings/custom-editor' and passing in a monaco instance.

I am using Lit, TS & Vite and the latest version of monaco-editor-auto-typings.

Uncaught (in promise) TypeError: path.dirname is not a function
at AutoTypingsCore2. (chunk-D6HROQ3V.js?v=c1a822df:1459:94)
at step (chunk-D6HROQ3V.js?v=c1a822df:1308:23)
at Object.next (chunk-D6HROQ3V.js?v=c1a822df:1255:18)
at chunk-D6HROQ3V.js?v=c1a822df:1241:71
at new Promise ()
at __awaiter (chunk-D6HROQ3V.js?v=c1a822df:1223:14)
at AutoTypingsCore2.resolveContents (chunk-D6HROQ3V.js?v=c1a822df:1442:16)
at new AutoTypingsCore2 (chunk-D6HROQ3V.js?v=c1a822df:1353:14)
at Function. (chunk-D6HROQ3V.js?v=c1a822df:1370:24)
at step (chunk-D6HROQ3V.js?v=c1a822df:1308:23)

Here's a minimal repro

I am not savvy when it comes to build processes, so maybe there is a Vite/Rollup setting I'm missing.

Any tips appreciated! :)

burtek commented 1 year ago

Honestly, not seeing that issue happen in the given repro. It seems to be working fine for me.

ClintH commented 1 year ago

Thanks for taking a look! You don't see the error in the DevTools console? I see it using Edge & Chrome browsers.

ClintH commented 1 year ago

Screen Shot 2022-11-08 at 17 14 33

burtek commented 1 year ago

Yeah, see it now. Had some wrong filters set in devtools console 🤦

miraries commented 1 year ago

Just ran into this, I'm using vite as well (with svelte kit). This works fine in the demo due to path-browserify, so fixed it by adding a similar polyfill for the path module using an esbuild plugin from this gist.

valerii15298 commented 1 year ago

Same problem for me :( Will be support for vite added??? Would be very much helpful...

valerii15298 commented 1 year ago

@miraries can you please share what exactly and how did you use from that gist? I am looking into it but there are so much stuff that I cannot understand what I should take from it...

miraries commented 1 year ago

@valerii15298 Do npm i @esbuild-plugins/node-modules-polyfill, then add the following resolve config in your vite.config.js :

export default defineConfig({
  resolve: {
    alias: {
      path: 'rollup-plugin-node-polyfills/polyfills/path'
    }
  }
});

this just adds a polyfill for the path module.

valerii15298 commented 1 year ago

@miraries thank you very much!!!

valerii15298 commented 1 year ago

@miraries btw, I made it work by installing only npm i rollup-plugin-node-polyfills and it seems to work too without @esbuild-plugins/node-modules-polyfill package