Comments (8)
We could add a couple of functions to the highlight
config:
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 revalidate
default in Lighter?
Also, isn't Next.js default to cache the fetch forever? Or does it need { next: { revalidate: false } }
?
from lighter.
can you give me a more concrete example of your first two points?
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.
For the Next.js case, would it make sense to add a good revalidate default in Lighter?
I'd advise strongly against that. revalidate
is a cost-incurring option, a library shouldn't make a default choice that incurs extra costs IMO.
Also, isn't Next.js default to cache the fetch forever?
That's correct, but this optimisation is skipped when setting export const revalidate = N
on the route segment - in this case the grammars and themes will be refetched every N
seconds - that's what was happening in code-hike/bright#21
from lighter.
If I add { next: { revalidate: false } }
to the fetchs in lighter, that shouldn't incur in extra costs, right?
from lighter.
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.
from lighter.
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 revalidate: false
on fetch override the revalidate: N
on the page? So when the page revalidates the fetch doesn't. That should fix code-hike/bright#21.
I'm just asking, I expect it to work like that but I have no idea.
from lighter.
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?
from lighter.
I found out while trying to present in front of a 1800 person conference that this package loads all the grammers from remote URLs 😆
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.
from lighter.
Wouldn't the revalidate: false on fetch override the revalidate: N on the page?
AFAIA no. The page value takes precedence.
from lighter.
Related Issues (20)
- fenchJSON must use external network HOT 3
- Add highlightSync
- Add getThemeColors HOT 2
- Update vscode-textmate and onigurama
- Possible to see if a language is available? HOT 2
- Edge support? HOT 8
- Annotations for languages without comment syntax HOT 2
- Use CSS classes instead of colors HOT 3
- Error with non extensible themes HOT 1
- JSX comment syntax and annotations HOT 1
- Escape annotations HOT 4
- Use ansi codes to highlight `terminal` code
- Support static builds in Next.js app directory HOT 1
- Support Gatsby Partial Hydration HOT 5
- Fix terminal out of memory HOT 1
- `from-css` themes don't work with `scopes: true` HOT 1
- build error on vite
- Regex containing `)` or `]` HOT 1
- crashes with Unknown language HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lighter.