suren-atoyan / monaco-loader

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

inject monaco instance when init instead of cdn #15

Closed pakholeung37 closed 2 years ago

pakholeung37 commented 2 years ago

The community keeps asking how to load monaco from node_modules, here's the solution. Now you can inject the monaco instance to loader by giving an option to init.

import * as  monaco from 'monaco-editor'
loader.init({ monaco }).then(result => {
  console.log(monaco === result)
})

The first init will call out a promise, every init call behind will return that promise.

you can reload also

import * as  monaco from 'monaco-editor'
loader.init({ monaco }).then(result => {
  console.log(monaco === result) // true
})

// somewhere in code
loader.dispose()
loader.init().then((result) => {
  console.log(result) // monaco from default cdn
})

14

suren-atoyan/monaco-react#327 suren-atoyan/monaco-react#322

colmanhumphrey commented 2 years ago

Very cool - just for visibility for others on the issue, https://github.com/suren-atoyan/monaco-react/issues/217 has a good related discussion

pakholeung37 commented 2 years ago

@suren-atoyan Is there any problem I could help with?

ShivamJoker commented 2 years ago

Why this has not been merged yet @syumai

BrianMcBrayer commented 2 years ago

This would be really nice to have. Any reason to not merge? This project is great BTW

ShivamJoker commented 2 years ago

@suren-atoyan are you still around?

BrianMcBrayer commented 2 years ago

@suren-atoyan I'm sorry to bother you, but would it be possible to merge this?

Thank you for this project!

Sparkenstein commented 2 years ago

@suren-atoyan my project is stuck as well, would be cool if this gets merged please

suren-atoyan commented 2 years ago

Hi everyone 👋

Sorry, for the late answer. This will be ready this weekend 🙂

@pakholeung37 thank you for your support 💚 There are some inconsistency issues in the PR, plus I have other changes in other places, so, most probably I'll close your PR, but your suggested API will be shipped 🚢 🙌

suren-atoyan commented 2 years ago

hey everyone 👋 @Sparkenstein @BrianMcBrayer @ShivamJoker @pakholeung37 @ColmanHumphrey

The new version is released 🎉 v1.3.0 check this

Thanks everyone for support!