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

Add prop to optionally disable lazy loading language modes #132

Merged
merged 1 commit into from
Aug 11, 2021

Conversation

nickgirardo
Copy link
Contributor

Hey, thanks for the hard work maintaining this project, it's been super helpful to me so far!

In my set up it doesn't make sense to dynamically load the language resources (modes) at runtime. I want to have a complete bundle that can be delivered without the need for further network requests.

For this I've added an optional prop, lazyLoadMode. This prop is true by default, and if it is true nothing changes. If the prop is false, the language resources will not be automatically downloaded and need to be downloaded manually.

The heart of the change is in src/index.js line 47.

-      if (mode && mode.mode) {
+      if (lazyLoadMode && mode && mode.mode) {

Just to reiterate, since this prop is true by default, this is not a breaking change!

I've updated the types to add this prop, and I've updated the readme to give a quick example of how it can be used.

If there is anything else which needs to be done or anything I can do to assist the project, please feel free to let me know! Thanks for checking this out

  • Nick

@jaywcjlove jaywcjlove merged commit fb5526f into uiwjs:master Aug 11, 2021
@jaywcjlove
Copy link
Member

@nickgirardo Upgrade @uiw/[email protected]

@nickgirardo
Copy link
Contributor Author

Thanks for the quick merge, I'm updated and doing great

nickgirardo added a commit to nickgirardo/personal-site that referenced this pull request Aug 11, 2021
codemirror-react's default behavior is to automatically load language
resource files when it is created.  This doesn't work for me as I need
to have my entire bundle prepared ahead of time.

I created a pr to add the ability to disable this behavior
uiwjs/react-codemirror#132

The maintainer was pretty quick to merge my change, so I can statically
load resource files now
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