You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the current module needs to be transpiled, or it breaks in SSR mode. While transpiling indeed "fixes" the problem, this is a workaround with its own issues, not a proper fix.
I suspect that useAsyncData is not supposed to be used like this because it has compile-time magic (auto-generating data key) and should not bypass the Nuxt compiler.
I see the following ways we could truly address this:
trpc-nuxt could be converted into a "true" module (doing defineNuxtModule and injecting runtime code with addPlugin, addComposable, etc.)
If there are low-level counterparts to useAsyncData and useRequestHeaders, they should be used instead. nuxt/app should not be imported from third party code, it's only supposed to be imported from within a Nuxt app.
Simply revert Remove outdated transpilation requirement from setup docs #241, get back to using { transpile: ['trpc-nuxt'] }, but then ideally we should provide a recipe to avoid transpiling the underlying @trpc/client, or at the very least document the gotcha (being unable to use error instanceof TRPCClientError). Or, perhaps re-export the transpiled TRPCClientError?
Following #240, specifically this comment: #240 (comment),
the current module needs to be transpiled, or it breaks in SSR mode. While transpiling indeed "fixes" the problem, this is a workaround with its own issues, not a proper fix.
See discussion in nuxt/nuxt#34662.
From what I gathered, the problem is apparently that the module does this:
I suspect that
useAsyncDatais not supposed to be used like this because it has compile-time magic (auto-generating data key) and should not bypass the Nuxt compiler.I see the following ways we could truly address this:
trpc-nuxtcould be converted into a "true" module (doingdefineNuxtModuleand injecting runtime code withaddPlugin,addComposable, etc.)useAsyncDataanduseRequestHeaders, they should be used instead.nuxt/appshould not be imported from third party code, it's only supposed to be imported from within a Nuxt app.{ transpile: ['trpc-nuxt'] }, but then ideally we should provide a recipe to avoid transpiling the underlying@trpc/client, or at the very least document the gotcha (being unable to useerror instanceof TRPCClientError). Or, perhaps re-export the transpiledTRPCClientError?