externalVue : does not send vue/server-renderer/index.js to .output
See original GitHub issueEnvironment
- 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 .
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:
- Created a year ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top GitHub Comments
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 vianitro.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 😊
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.