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

Nuxt Image functionality causes auto-install of NuxtImage module even when NuxtImg is not used #234

Open
sebaguse opened this issue Jun 25, 2024 · 3 comments

Comments

@sebaguse
Copy link

sebaguse commented Jun 25, 2024

I have raised this issue with Nuxt main repo and been adviced this might be a problem with MDC module. The original issue is available here https://github.com/nuxt/nuxt/issues/27854

MDC triggers Nuxt to auto-install NuxtImage despite useNuxtImage being set to false. Daniel Roe suggested:

The way that code is written means it's possible NuxtImage could be used at runtime so it's not possible to tree shake from the bundle, which is why you are being prompted to install it.

@sebaguse sebaguse changed the title Disable using Nuxt Image functionality Nuxt Image functionality causes auto-install of NuxtImage module even when NuxtImg is not used Jul 1, 2024
@harlan-zw
Copy link

harlan-zw commented Jul 20, 2024

A simple solution to solve this would be to break the build-time plugin which transforms the resolveComponent into an explicit import.

// String() breaks the build-time transform because it's considered dynamic 
const imgComponent = useRuntimeConfig().public.mdc.useNuxtImage ? resolveComponent(String('NuxtImg')) : 'img'

But I'm not sure if this will break NuxtImg being resolved properly, so a solution is a build-time template that returns the image component instance.

I don't have the capacity to investigate further at the moment if anyone else wants to take this up.

@sebaguse
Copy link
Author

any update on this, please?

@timelytree
Copy link

CC @antfu @farnabaz, any ideas on what to do here? This is proving to be really annoying for DX, and I've got members of my team continuously accidentally installing NuxtImg, even though we don't use it.

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

No branches or pull requests

3 participants