Open pi0 opened 5 months ago
I wrote it already in some Nuxt issues but I would love auto imports being fully disabled by default + all the docs updated for the reasons you stated. Personally I see no benefits of having auto imports, but a lots of downsides.
Right now it is not clear to developers what actually comes from H3, what from Nitro, what from Nuxt and what from Vue.
I failed multiple times disabling auto imports within a Nuxt app as well as in a Nitro app: https://github.com/unjs/nitro/issues/2305
Thanks for your feedback @MickL. This decision for Nuxt should happen within a Nuxt-related discussion. We might consider disabling it by default for Nitro core but probably in 1-2 more next major versions progressively.
Hoping to see auto imports disabled in v3 :)
This is gonna be fun down the line rewriting tons of projects and modules. ☠️
The history of auto import idea probably backs to Nuxt Components (an amazing initiative by @kevinmarrec) and then same time as Nuxt 3 development, thanks to @antfu, we adopted unimport.
Auto imports make the DX of writing any javascript code much more minimalistic by automatically injecting necessary import statements in the modules that need them which means full tree-shaking same as manually importing them.
However, over time, it also showed negative effects;
prepare
step to generate the types, and even after that, click to jump does not always go to the source, it goes to the intermediate file,node_modules
, and it implies module authors take additional care of explicitly importing from#imports
virtual module.I still love auto imports and like the ability to have them but also think we could depend less on them and keep it for advanced usage and users who already know what they are doing.
For Nitro 2.x auto import feature shall remain enabled an I think for the sake of backward compatibility, in Nitro 3.x, we might keep having
#imports
but deprecated. We might also think about making the auto import experience opt-in for direct nitro users. (subject to discussion, only an idea for now)