-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix downloading monaco twice per load #267
Conversation
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.
I'd like to clarify one of the comments, as I think people may be lost who haven't discussed the problem the way you and I have recently.
I will take you at your word about specifying the CDN URL, but is it really necessary to do so?
const widgetPosition = { | ||
position: { lineNumber: 1, column: 1 }, | ||
preference: [monacoInstance.editor.ContentWidgetPositionPreference.EXACT], | ||
}; |
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.
Seems like this ought to be const
-able, but the linter doesn't like it. Probably doesn't matter anyway...
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 I follow what you mean by const-able in this context?
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.
I mean annotated as as const
, since its members don't seem to be able to be changed anywhere in the code. But that conflicts with the looser typing further down.
(The larger context was me wondering if it should be memoized, before realizing this was already in a useEffect
hook, so it doesn't matter.)
(Noting that Monaco still loads in this version, and is noticeably faster to do so...) |
Specifying the URL is necessary if you want control over the version. So far we have (unknowingly!) always been using monaco-loader's default version, which is 0.46 |
...weird. Wonder why they're so far behind... |
From what I can tell, historically, requests for them to bump their default version are met with people being told just to use the config like this. I think they want to avoid doing an npm release every time monaco does one |
Co-authored-by: Jeff Soules <[email protected]>
What must their release schedule be like, that that would be an actual problem greater than everybody by default using a version from 2023 |
Well, we were using a version from 2023 and didn't notice... ;P |
I noticed some slow loading during a dev environment that made me inspect the network tab and realize monaco was not loading from
localhost
, but from a CDN.After some digging, it turns out
@monaco-editor/react
uses a package called@monaco-editor/loader
that has this behavior. I was unsuccessful in getting it to use our bundled monaco, so instead I went the other way and made it so we don't have to bundlemonaco-editor
ourselves at all.The bundle size is much happier now, here's yarn build: