-
Notifications
You must be signed in to change notification settings - Fork 62
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
feat: migrate to Shikiji #109
Conversation
✅ Deploy Preview for rehype-pretty-code ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I’ll try to take a look this week if I can help |
Would love if this gets merged. Right now Shiki is not compatible with Next.js 14 or Turbopack or SWC... And using Shikiji would def solve many problems 🙇 |
493e255
to
4f3a918
Compare
Think I managed to get this working. There are some API changes so it's partially breaking but most things are the same still |
I found a really weird bug with the If the
Ensuring if (langsToLoad.has('md')) {
langsToLoad.delete('md');
langsToLoad.add('md');
} I need to see how this also works on the client. |
|
Perfect! Closed my PR, thank you! |
Thanks! I'm going to keep the I think this is mostly ready, but I've published |
@@ -1,4 +1,10 @@ | |||
import type { Highlighter, IShikiTheme } from 'shiki'; | |||
import type { |
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.
Just curious, why do you manually declare types? And don’t generate them based on src/index.ts file?
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.
It should be generated yeah :) Originally, the source was in plain JavaScript but I didn't update the way types were generated when I converted the codebase to TypeScript.
lang as Parameters<typeof highlighter.loadLanguage>[0], | ||
); | ||
} catch (e) { | ||
return Promise.reject(e); |
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.
This try catch block can be completely removed (with keeping code from try
block) since you just re throw error in catch
block?
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.
It's needed because if one of the languages throws then it should still continue with the rest
"rome": "12.1.3", | ||
"shiki": "^0.14.0", | ||
"rollup": "^4.6.1", | ||
"shikiji-transformers": "^0.7.6", | ||
"ts-jest": "^29.1.0", | ||
"typescript": "^4.9.5", | ||
"vite": "^4.3.9", | ||
"vitest": "^0.32.2" | ||
}, | ||
"dependencies": { | ||
"@types/hast": "^3.0.3", |
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.
Should be in dev dependencies?
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'm not really sure if Shikiji itself should be a peer (locked to minor version though) - but this was just for testing purposes. The user would need to install it themselves (but again, might be a problem with versions)
Co-authored-by: Dimitri POSTOLOV <en3m@ya.ru>
Closes #107