suren-atoyan / monaco-loader

The utility to easy setup monaco-editor into your browser
MIT License
177 stars 37 forks source link

loader.config({monaco}) still stuck on 'loading...' #21

Closed tarngerine closed 2 years ago

tarngerine commented 2 years ago

Describe the bug Following the instructions on the README for loading monaco-editor as an npm module (not using CDN) in Vite, it does not work. https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package

It used to work! I am not sure when this stopped working - sometime in the last few weeks. I was using 4.4.1 locally before, and had recently updated to React 18. I created a fresh sandbox repro.

To Reproduce

  1. Run the example: https://stackblitz.com/edit/vitejs-vite-tf4tif?file=src/App.tsx
  2. Observe that the editor never gets past loading
  3. If you comment out line 36 (loader.config({monaco})) it works fine

Expected behavior It should load and show "HELLO" in the monaco editor

Screenshots Broken:

image

Comment out 9-40 (loader code) works fine:

image
miaawong commented 2 years ago

having the same issue here

imguolao commented 2 years ago

Having the same issue

suren-atoyan commented 2 years ago

Please check this snippet. I removed React.StrictMode and commented loader.init line. Somehow it stucks after trying to be initialized a second time.

I'll examine it tomorrow.

suren-atoyan commented 2 years ago

okay, I see what's the problem, will solve this in the next version

tarngerine commented 2 years ago

thanks for taking a look! looking forward to the fix <3

i thought that calling .init() was required for the config to actually apply to the loader — is that correct?

suren-atoyan commented 2 years ago

it's not required. Editor component will call loader.init the first time it renders

suren-atoyan commented 2 years ago

@tarngerine @imguolao @miaawong could you please check the latest version?

imguolao commented 2 years ago

@tarngerine @imguolao @miaawong could you please check the latest version?

Yes, it is working. Great! (:

tarngerine commented 2 years ago

Amazing, it's working! thank you