pi0 / nuxt-shiki

🎨 Nuxt + Shiki syntax highlighter
79 stars 2 forks source link

Build fails on latest Vite version #41

Open ExEr7um opened 1 month ago

ExEr7um commented 1 month ago

When I'm trying to build my project on latest version of Vite build fails with error:

Nuxt Build Error: [vite:wasm-fallback] Could not load /home/projects/nuxt-starter-syikls/node_modules/shiki/dist/onig.wasm (imported by node_modules/nuxt-shiki/dist/runtime/shiki.mjs): "ESM integration proposal for Wasm" is not supported currently. Use vite-plugin-wasm or other community plugins to handle this. Alternatively, you can use .wasm?init or .wasm?url. See https://vitejs.dev/guide/features.html#webassembly for more details.

For me it started to happen when I upgraded some dependencies. I traced it to this upgrades:

- vite "^5.4.3"
- vite-node "^2.0.5"
- vite-plugin-checker "^0.7.2"
+ vite "^5.4.5"
+ vite-node "^2.1.1"
+ vite-plugin-checker "^0.8.0"

Minimal reproduction

https://stackblitz.com/edit/nuxt-starter-syikls

You need to run npm run build in terminal.

navinpeiris commented 1 month ago

Workaround: configure vite to use the @rollup/plugin-wasm plugin:

npm install --save-dev @rollup/plugin-wasm

Then update your nuxt config to:

import wasm from "@rollup/plugin-wasm";

export default defineNuxtConfig({
  // ....
  vite: {
    plugins: [wasm()],
  },
});