Note: Can’t use Shiki (and likely other Wasm-based tools) in Next 13 server somponents
It seems Next 13 bundles server code using Webpack. This does not play well with Shiki which uses
require.resolve to locate a Wasm file in a sibling package and pull it in via
fs.readFileSync. I suspect many Wasm based packages end up needing to do something like this, since Node does not offer a first-class way to require binary Wasm code.
The error it throws is:
error - unhandledRejection: Error: ENOENT: no such file or directory, open
Update Nov. 14th 2014: It looks like GitHub user pengx17 has found a solution here for there blog: https://github.com/shikijs/shiki/pull/358#issuecomment-1294413167 the full stack of commits are here. I’m working on adapting this for my blog.