-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Allow the user to control the process of loading grammars & themes #31
Comments
We could add a couple of functions to the type Config = {
loadRawGrammar: (lang: {...}) => Promise<IRawGrammar>
loadRawTheme: (name: string) => Promise<RawTheme>
}; But I'm not sure it will solve your use case, can you give me a more concrete example of your first two points? For the Next.js case, would it make sense to add a good Also, isn't Next.js default to cache the fetch forever? Or does it need |
Test environments are a common one, also deno without requiring permissions. In general syntax highlighting is a pure function, it's strange to me to require a network call without the ability to swap this out. Additionally this would allow for loading arbitrary themes and grammars not found in the standard set.
I'd advise strongly against that.
That's correct, but this optimisation is skipped when setting |
If I add |
Apologies I misread. As far as I'm aware that configuration is a complete no-op. It's equivalent to not passing revalidate to fetch at all. |
Wouldn't the I'm just asking, I expect it to work like that but I have no idea. |
I found out while trying to present in front of a 1800 person conference that this package loads all the grammers from remote URLs 😆 Lucky I just had to turn the wifi on and it fixed itself, but I would love to be able to load all these grammars locally. Or at least a web worker to cache them? |
Ups, sorry about that. How are you using it? (any bundler? framework? directly from the browser?) Lighter tries to load the grammars from the file system (node modules) first, and only goes to the network if that fails. |
AFAIA no. The page value takes precedence. |
The current behaviour is a good default as it mostly just works across all environments. However there are cases where I want to be in control of how/when the grammars and themes are loaded. In general: as a user I want to tightly control the IO operations of the library.
Consider the following use cases:
next: { revalidate: ... }
The text was updated successfully, but these errors were encountered: