Skip to content
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

docs: wasm configuration #165

Closed
wants to merge 1 commit into from

Conversation

adamdehaven
Copy link
Contributor

Add documentation around the wasm support needed for the default Shiki syntax highlighter.

```ts [nuxt.config.ts]
export default defineNuxtConfig({
modules: ['@nuxtjs/mdc'],
$production: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, I'd like to see if it's possible to leave the wasm enabled for $development as well?

See the errors when running this reproduction's dev server: https://github.com/adamdehaven/mdc-wasm-monorepo

nitro: {
// Enable the wasm feature in production for the Shiki syntax highlighter
experimental: {
wasm: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, mdc module already has built-in logic to add wasm related logic. it should not be required unless that current mdc logic is outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem to be handled properly (?) in a Nuxt project deployed to Cloudflare Pages without this setting.

If you check the reproduction deploys in this comment you'll see two things are missing:

  1. The nitropack version needed to be bumped to 2.9.x
  2. Without the nitro.experimental.wasm: true setting, the syntax highlighting is still not functional.

Let me know if you want me to update one of the reproduction repos/branches?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useWasmAssets: !nuxt.options.dev && !!nuxt.options.nitro.experimental?.wasm

The way I'm reading this line, I believe the setting is required? Feel free to correct me 😅

Copy link
Contributor Author

@adamdehaven adamdehaven Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pi0 I modified my local @nuxtjs/mdc build and changed the line referenced above to this (removing the check for the nitro.experimental.wasm: true setting):

useWasmAssets: !nuxt.options.dev

If I remove the line, I can then remove the nitro.experimental.wasm: true in my host project, and things work as expected as long as I list shiki/onig.wasm in the vite.build.rollupOptions.external array.

@farnabaz
Copy link
Collaborator

Closing in favor of #167

@farnabaz farnabaz closed this Mar 19, 2024
@adamdehaven adamdehaven deleted the docs/wasm branch March 19, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants