-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
DX for what can be imported in nitro vs vue context #13920
Comments
Thanks for the summary @danielroe 💚 I think case for (1), is the most urgent to resolve by adding Regarding environment safely, I belive we need to somehow merge two instances of unimport (nuxt and nitro) to be aware of each other and generate proper error or a mock that throws error when using auto imports with the wrong file context (/cc @antfu can we please have an issue for this) Having greater typescript safely for filtering |
I think we can try two possible solutions here:
|
In a Nuxt app, there are two different contexts:
What is available in these two different contexts is dramatically different, although in some cases utilities can be imported in both places, or shared between them:
createError
in the Vue portion of the app in feat(nuxt): improve error dx for users framework#4539, for example.useRuntimeConfig()
has a same name and DX but is a different utility in Nitro and Vue.defineEventHandler
ordefineComponent
.useCookie
.For 1 and 2, we don't have an issue. But for 3 and 4, we have the problem that users may use the 'wrong' import, either because it isn't provided via auto-imports in the context in which they are using it, or because it won't work in that context. Even worse, they may import directly from
#app
in a server context, or try to import from nitro in a Vue context.There are a number of potential ways to resolve this and this issue exists for discussion of these and other potential solutions. They are not mutually exclusive.
defineServerCookie
).Other ideas are welcome!
Related: #13713
cc: @pi0, @atinux, @antfu
The text was updated successfully, but these errors were encountered: