-
Notifications
You must be signed in to change notification settings - Fork 91
Optimize how external libs are handled and allow for custom languages #30
Optimize how external libs are handled and allow for custom languages #30
Conversation
* Adding/removing extra libs does not trigger a full worker refresh * Manual control over when the extra libs are sent to the worker * Adding a new lib with the same name replaces it inplace Also included, the capability to define custom languages
@alexandrudima, this PR resolved an important use case for our platform: supporting client-side and server-side JS at the same time where model symbols don't overlap between the two JS flavors. Any indication of the status of this PR? |
src/monaco.contribution.ts
Outdated
} | ||
|
||
function getLanguageDefaults(languageName: string): LanguageServiceDefaultsImpl { | ||
return languageDefaults[languageName]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this is assuming that properties don't get renamed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
languageDefaults
is an object literal defined with an interface
with non-string keys. The TypeScript compiler may rename the keys to something else so referencing the properties with string keys isn't safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
languageDefaults
is just a map we have full control over. Adding items to it is fully handled by the user, so i don't see how the compiler can interfere with that. See https://github.com/Microsoft/monaco-typescript/pull/30/files/292108c5ee680df61aa87a79319caf4713aa6e36#diff-e54df758d643734a71ab22c92c524518R243
👍 Thank you! I've only accepted a part of the PR. Please, in the future, open one PR per feature to avoid having to undo changes... Here are my changes:
|
@alexandrudima, thanks for accepting this!
I was interested in this PR to allow Monaco to differentiate between browser-style JS and server-side JS (i.e., NodeJs) for extra libraries and symbol sharing between models. This is a use case that I'm currently supporting in my usage of Monaco by having to dispose of all the extra libraries + models of the other JS flavor and then adding the correct extra libraries and recreating the correct models (with the restored view state but, unfortunately, losing the undo state as that is not restorable).
|
Currently, that is outside the scope of this project. My recommendation in these cases is to fork this project and then pick up directly This is relatively easy to do by editing the |
setEagerExtraLibSync
andsyncExtraLibs
. This enables the user to do bulk updates of libraries.Also included, the capability to define custom languages via
monaco.languages.typescript.setupNamedLanguage