question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Production build + custom vue lib + ssr

See original GitHub issue

Environment

npx nuxi info:
------------------------------
- Operating System: `Darwin`
- Node Version:     `v16.13.1`
- Nuxt Version:     `3.0.0-27338323.1e98259`
- Package Manager:  `yarn@1.22.17`
- Bundler:          `Vite`
- User Config:      `-`
- Runtime Modules:  `-`
- Build Modules:    `-`
------------------------------

vue version 3.2.26 (same for nuxt project and vue lib)

Reproduction

https://github.com/Jamshoot66/nuxt3-ui-lib-example There are two projects:

  • nuxt-project - project to reproduce the bug commands to start project:

    • yarn
    • yarn build && yarn start
  • ui-lib - example of external lib. Also, it is published to npm as ui-lib-for-nuxt-slot-issue

Describe the bug

I’m working on vue3 ui library and trying to add SSR support. So, the problem is SSR fails after production build (yarn build && yarn start). There are 2 components in the example

  1. Simple hello world component HelloWorld
  2. Component with slot HelloSlot

Both of them leads to errors in production build: [Vue warn]: [@vue/server-renderer] Invalid VNode type: Symbol(Fragment) (symbol) Yes, it’s market as warn, but the component does not render on the server-side and it is an error to me.

Slotted component HelloSlot throws TypeError: Cannot read properties of null (reading 'isCE'), 'couse currentRenderingInstance is null

nuxt config:

export default defineNuxtConfig({
  vite: {
    resolve: {
      alias: {
        "@vue": path.resolve(__dirname, './node_modules/@vue'),
        "vue": path.resolve(__dirname, './node_modules/vue'),
      },

      // error when use dedupe:
      // "require is not defined in ES module scope, you can use import instead"
      // fixing server.mjs does not help with ssr issue
      // dedupe: ['vue', '@vue'],
      preserveSymlinks: false,
    }
  }
})

Additional context

Only production build

Logs

[Vue warn]: [@vue/server-renderer] Invalid VNode type: Symbol(Fragment) (symbol)
TypeError: Cannot read properties of null (reading 'isCE')
    at renderSlot (/Users/jamshoot/Documents/projects/__tests/nuxt3/nuxt3-ui-lib-example/nuxt-project/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5799:34)
    at Proxy.render (/Users/jamshoot/Documents/projects/__tests/nuxt3/nuxt3-ui-lib-example/nuxt-project/.output/server/node_modules/ui-lib-for-nuxt-slot-issue/dist/ui-lib-for-nuxt-slot-issue.common.js:245:301)
    at renderComponentRoot (file:///Users/jamshoot/Documents/projects/__tests/nuxt3/nuxt3-ui-lib-example/nuxt-project/.output/server/chunks/index.mjs:2019:44)
    at renderComponentSubTree (file:///Users/jamshoot/Documents/projects/__tests/nuxt3/nuxt3-ui-lib-example/nuxt-project/.output/server/chunks/index.mjs:9866:51)
    at renderComponentVNode (file:///Users/jamshoot/Documents/projects/__tests/nuxt3/nuxt3-ui-lib-example/nuxt-project/.output/server/chunks/index.mjs:9811:16)
    at Object.ssrRenderComponent (file:///Users/jamshoot/Documents/projects/__tests/nuxt3/nuxt3-ui-lib-example/nuxt-project/.output/server/chunks/index.mjs:10220:12)
    at _sfc_ssrRender (file:///Users/jamshoot/Documents/projects/__tests/nuxt3/nuxt3-ui-lib-example/nuxt-project/.output/server/chunks/app/server.mjs:3263:32)
    at renderComponentSubTree (file:///Users/jamshoot/Documents/projects/__tests/nuxt3/nuxt3-ui-lib-example/nuxt-project/.output/server/chunks/index.mjs:9860:13)
    at renderComponentVNode (file:///Users/jamshoot/Documents/projects/__tests/nuxt3/nuxt3-ui-lib-example/nuxt-project/.output/server/chunks/index.mjs:9811:16)
    at renderVNode (file:///Users/jamshoot/Documents/projects/__tests/nuxt3/nuxt3-ui-lib-example/nuxt-project/.output/server/chunks/index.mjs:9901:22)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:11
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
dergunovscommented, Jan 22, 2022

No, I switched to next.js.

1reaction
danielroecommented, Sep 6, 2022

This is no longer reproducible on latest Nuxt. We now enable vue as an external by default, and dedupe vue in the client build.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-Side Rendering (SSR) - Vue.js
Vue.js is a framework for building client-side applications. By default, Vue components produce and manipulate DOM in the browser as output.
Read more >
Vue-cli 3 component library to support SSR - Stack Overflow
I am creating a custom component library that i want to share across ... setup for production using "production": "vue-cli-service build ...
Read more >
Creating Server-side Rendered Vue.js Apps Using Nuxt.js
Nuxt.js is based off an implementation of SSR for the popular React library called Next. After seeing the advantages of this design, a...
Read more >
Custom Rendering (aka Bring Your Own View Library) - Vitedge
Vitedge provides renderers for Vue and React out of the box so you don't need to even care about how these libraries run...
Read more >
How to Create and Publish a Vue Component Library
Cool, let's build the library · Is this a single component or a library? Library · What is the npm name of your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found