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

Vue-demi not working with prerendering (nuxi generate) #13834

Closed
tobiasdiez opened this issue Apr 26, 2022 · 6 comments
Closed

Vue-demi not working with prerendering (nuxi generate) #13834

tobiasdiez opened this issue Apr 26, 2022 · 6 comments

Comments

@tobiasdiez
Copy link
Contributor

Environment

  • Operating System: Linux
  • Node Version: v16.13.0
  • Nuxt Version: 3.0.0-rc.1
  • Package Manager: yarn@1.22.17
  • Builder: vite
  • User Config: target, bridge, vite, alias, nitro, ssr, meta, css, tailwindcss, modules, watch, runtimeConfig, build, storybook
  • Runtime Modules: @nuxtjs/tailwindcss@5.0.2, @pinia/nuxt@0.1.8
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-5qjawv?file=nuxt.config.ts (not sure if this really reproduces the error, I'm currently on a low-memory machine and nuxi generate on stackblitz fails with out of memory).
JabRef/JabRefOnline#1009

Describe the bug

  1. Set ssr: true and target: 'static' in the nuxt config.
  2. Use a library that relies on vue-demi. In the reproduction, this is apollo-composables.
  3. nuxi generate results in the following error:
....
✔ Server built in 1756ms                                                           10:50:50
✔ Generated public .output/public                                            nitro 10:50:51
ℹ Initializing prerenderer                                                   nitro 10:50:51
ℹ Prerendering 1 initial routes with crawler                                 nitro 10:51:19

 ERROR  (0 , import_vue_demi5.getCurrentInstance) is not a function                10:51:19

  at useQueryImpl (.nuxt/prerender/chunks/app/server.mjs:337:54)
  at Object.useQuery (.nuxt/prerender/chunks/app/server.mjs:333:10)
  at setup (.nuxt/prerender/chunks/app/server.mjs:30969:40)
  at _sfc_main$e.setup (.nuxt/prerender/chunks/app/server.mjs:31114:25)
  at callWithErrorHandling (.nuxt/prerender/chunks/index.mjs:1986:22)
  at setupStatefulComponent (.nuxt/prerender/chunks/index.mjs:7580:29)
  at setupComponent (.nuxt/prerender/chunks/index.mjs:7561:11)
  at renderComponentVNode (.nuxt/prerender/chunks/index.mjs:9920:17)
  at Object.ssrRenderComponent (.nuxt/prerender/chunks/index.mjs:10351:12)
  at _sfc_ssrRender$7 (.nuxt/prerender/chunks/app/server.mjs:31672:32)


 ERROR  (0 , import_vue_demi.getCurrentInstance) is not a function                 10:51:19

  at Object.useApolloClient (.nuxt/prerender/chunks/app/server.mjs:136:47)
  at setup (.nuxt/prerender/chunks/app/server.mjs:31120:38)
  at _sfc_main$d.setup (.nuxt/prerender/chunks/app/server.mjs:31238:25)
  at callWithErrorHandling (.nuxt/prerender/chunks/index.mjs:1986:22)
  at setupStatefulComponent (.nuxt/prerender/chunks/index.mjs:7580:29)
  at setupComponent (.nuxt/prerender/chunks/index.mjs:7561:11)
  at renderComponentVNode (.nuxt/prerender/chunks/index.mjs:9920:17)
  at Object.ssrRenderComponent (.nuxt/prerender/chunks/index.mjs:10351:12)
  at _sfc_ssrRender$7 (.nuxt/prerender/chunks/app/server.mjs:31674:32)
  at renderComponentSubTree (.nuxt/prerender/chunks/index.mjs:9991:13)


 ERROR  [nuxt] [request error] (0 , import_vue_demi5.getCurrentInstance) is not a function
  at useQueryImpl (./.nuxt/prerender/chunks/app/server.mjs:337:54)  
  at Object.useQuery (./.nuxt/prerender/chunks/app/server.mjs:333:10)  
  at setup (./.nuxt/prerender/chunks/app/server.mjs:30969:40)  
  at _sfc_main$e.setup (./.nuxt/prerender/chunks/app/server.mjs:31114:25)  
  at callWithErrorHandling (./.nuxt/prerender/chunks/index.mjs:1986:22)  
  at setupStatefulComponent (./.nuxt/prerender/chunks/index.mjs:7580:29)  
  at setupComponent (./.nuxt/prerender/chunks/index.mjs:7561:11)  
  at renderComponentVNode (./.nuxt/prerender/chunks/index.mjs:9920:17)  
  at Object.ssrRenderComponent (./.nuxt/prerender/chunks/index.mjs:10351:12)  
  at _sfc_ssrRender$7 (./.nuxt/prerender/chunks/app/server.mjs:31672:32)

Additional context

The relevant part of .nuxt/prerender/chunks/app/server.mjs shows that vue demi is indeed missing many things from vue

const vueDemi = /*#__PURE__*/Object.freeze({
  __proto__: null,
  Vue2: Vue2,
  isVue2: isVue2,
  isVue3: isVue3,
  install: install$1,
  set: set,
  del: del
});

const require$$0$1 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(vueDemi);

Logs

No response

@tobiasdiez tobiasdiez changed the title Nuxi Vue-demi not working with prerendering (nuxi generate) Apr 26, 2022
@antfu antfu self-assigned this Apr 26, 2022
@Der-Alex
Copy link

The same error occurs with nuxt 3 rc3 and nuxt build / nuxt preview. So I guess it is not only a "nuxi generate / nuxt generate" specific issue.

@danielroe
Copy link
Member

I can't reproduce this issue on the reproduction above (I get another one about ts-invariant). Would you be able to check if the issue persists and, if so, provide one?

@Der-Alex
Copy link

Hi @danielroe I updated my dependencies and now it seems to work.

@antfu
Copy link
Member

antfu commented Jun 21, 2022

Closing this for now. If the issue still occurs, please open a new issue with reproduction. Thanks.

@antfu antfu closed this as completed Jun 21, 2022
@Der-Alex
Copy link

I forgot to mention, that I added apollo-composable to the transpile option in nuxt.config.js:

transpile: [
  '@apollo/client/core',
  '@vue/apollo-composable'
],`

@GitarMan
Copy link

I forgot to mention, that I added apollo-composable to the transpile option in nuxt.config.js:

transpile: [
  '@apollo/client/core',
  '@vue/apollo-composable'
],`

I was also experiencing this same issue. Adding @Der-Alex 's transpile settings seems to have helped to fix.

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants