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.

externalVue : does not send vue/server-renderer/index.js to .output

See original GitHub issue

Environment


  • Operating System: Windows_NT
  • Node Version: v16.11.1
  • Nuxt Version: 3.0.0-rc.9
  • Package Manager: yarn@3.2.3
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/nuxt/framework/pull/4762 https://github.com/nuxt/framework/pull/4762/commits/45eac5f165b4c0e3b2dd3a766d1152d4ea6de370

Describe the bug

Hi 👋 this is a VERY strange issue that happens when having externalVue set to true. Vue use require() to require vue/server-renderer but the index.js file is missing in .output\server\node_modules\vue\server-renderer , the mjs version is present .

image

However, nuxt does not crash and still manage to render the page with the dynamic template (when it should crash since it cannot import vue/server-renderer ) as if it successfully imported vue/server-renderer. There’s even a log in console due to https://github.com/unjs/nitro/blob/2a05d1e414deb6afbb8d11f376d5cd1403fae886/src/runtime/entries/node-server.ts#L30 (the if statement is duplicated ?) --> [nitro] [dev] [unhandledRejection] Error: Cannot find module 'D:\GIT\nuxt-3\playground\.output\server\node_modules\vue\server-renderer\index.js'

Additional context

Thank you for this amazing framework ❤️

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
danielroecommented, Sep 6, 2022

The issue is that the vue runtime compiler is generating code:

https://github.com/vuejs/vue-next/blob/cd395559ce34bdcc77cf3cff6e5c062fc6d89d90/packages/compiler-core/src/codegen.ts#L361-L368

That code is referring to vue/server-renderer which is only really an alias for @vue/server-renderer. Because it’s never used (in a CJS context) in the build we can’t trace it properly. You can force include it via nitro.externals.traceInclude, but note that I have opened a PR to nitro which will have to be merged first (https://github.com/unjs/nitro/pull/475).

Let’s keep chatting in your PR 😊

0reactions
huang-juliencommented, Sep 6, 2022

https://stackblitz.com/edit/nuxt-starter-ejmipr?file=app.vue,nuxt.config.ts Is stackblitz considered as outside of the PR (even if i change a lot of configuration) ? I’m not sure how to resolve this in the PR except by disabling externalVue. I don’t have the issue if i copy the missing file from the root node_module into the .output node_modules.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue 3 Server Side Rendering with Vuex and Router
I have tried changing the server entry file (src/main.server.js) to the following, but this does not work either. import App from './ ...
Read more >
Server-Side Rendering (SSR) - Vue.js
By default, Vue components produce and manipulate DOM in the browser as output. However, it is also possible to render the same components...
Read more >
Basic Server Side Rendering with Vue.js and Express
Learn how to implement rudimentary server-side for your Vue.js apps.
Read more >
Server-Side Rendering - Vite
If you are looking for integration with traditional server-side frameworks, ... The index.html will need to reference entry-client.js and include a ...
Read more >
SSR with Vue and webpack from scratch (2/3) | by Lachlan Miller
We have a problem. output.library and output.libraryTarget. We need to set some output options in config/server.js ...
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