Skip to content
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

Import the Monaco API without initializing the editor #26

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

haines
Copy link
Contributor

@haines haines commented Jul 31, 2024

Currently, y-monaco is importing the entire monaco-editor package, rather than just the API that it uses. This means all languages are registered and all features are loaded, which is a pain if you're trying to only use a subset of Monaco functionality to keep bundle sizes down.

This PR changes the import to only pull in the bit of monaco-editor that y-monaco needs.

@dmonad
Copy link
Member

dmonad commented Jul 31, 2024

Is this the recommended way to import only part of the editor? Is this even supported by monaco?

It is uncommon for projects to import specific javascript files from packages. I want to ensure that this approach works in the future and doesn't break with the next monaco release.

@haines
Copy link
Contributor Author

haines commented Jul 31, 2024

Hi @dmonad, yes, this is the recommended approach. For example, it's referenced in the Monaco docs here, and they do this in their sample project that demonstrates how to bundle a subset of features.

@dmonad
Copy link
Member

dmonad commented Jul 31, 2024

Great, thank you!

I didn't know that you could only import the API. That really is preferable.

I will make a release later today.

@dmonad dmonad merged commit 668fddb into yjs:master Jul 31, 2024
@haines haines deleted the only-import-editor-api branch July 31, 2024 12:27
@haines
Copy link
Contributor Author

haines commented Jul 31, 2024

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants