pi0/nuxt-shiki

Support loading aliases

atinux opened this issue · 3 comments

Example:

export default defineNuxtConfig({
  shiki: {
    langs: ['bash']
  }
})
[nitro 7:47:12 PM]  ERROR  Error: Could not load /Users/atinux/my-project/node_modules/.pnpm/shiki@1.1.5/node_modules/shiki/dist/langs/bash.mjs

It would be nice to detect that it is an alias and load the corresponding language: powershell (See https://github.com/shikijs/shiki/blob/b9c0fb5fcc0c86d0e994ac0a51d990a9270a73f3/packages/shiki/src/assets/langs-bundle-full.ts#L834-L841)

Any hint on how to do this @antfu ?

Here is how I did in mdc module:

https://github.com/nuxt-modules/mdc/blob/cf7d72a17f2c1a1cc2dec42ab1042dccb2b2d504/src/templates/mdc-highlighter.ts#L33-L52

I don't mind creating stub modules for alias to be directly imported - but that might not work for every alias as not all aliases a valid ansi filenames - I will try

shikijs/shiki#596 get merged - now this should just work if you upgrade shiki to 1.1.6

That was fast thank you @antfu !