vite-plugin-vue2 icon indicating copy to clipboard operation
vite-plugin-vue2 copied to clipboard

no corresponding SFC entry in the cache Error when importing a .vue file from node_modules

Open sharvilak11 opened this issue 3 years ago • 13 comments

Description

When in node_modules, we ship .vue files directly (without doing JS minification), and we try to import them in the app, it throws below error.

For clarity, I have few sub-components which are being imported into the main component inside my package in node_modules and then I'm importing the main component in my project.

Vite Version: 2.0.0-beta.19

In 2.0.0-beta.19 it's possible to import .vue files directly from node_modules. With vite-plugin-vue2 it's giving following error.

Logs:

6:23:26 PM [vite] Internal server error: vue_components/src/components/rich-text/IconButton.vue has no corresponding SFC entry in the cache. This is a vite-plugin-vue2 internal error, please open an issue.
  Error: vue_components/src/components/rich-text/IconButton.vue has no corresponding SFC entry in the cache. This is a vite-plugin-vue2 internal error, please open an issue.
      at Object.getDescriptor (/Users/sharvilak/WebstormProjects/cab9-chat-vite/node_modules/vite-plugin-vue2/dist/utils/descriptorCache.js:62:15)
      at Context.load (/Users/sharvilak/WebstormProjects/cab9-chat-vite/node_modules/vite-plugin-vue2/dist/index.js:65:54)
      at Object.load (/Users/sharvilak/WebstormProjects/cab9-chat-vite/node_modules/vite/dist/node/chunks/dep-0071bc7e.js:52580:50)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
      at async transformRequest (/Users/sharvilak/WebstormProjects/cab9-chat-vite/node_modules/vite/dist/node/chunks/dep-0071bc7e.js:58796:24)
      at async /Users/sharvilak/WebstormProjects/cab9-chat-vite/node_modules/vite/dist/node/chunks/dep-0071bc7e.js:58922:32

sharvilak11 avatar Jan 10 '21 12:01 sharvilak11

Not for sure you are how import .vue files inside node_modules.

If you are import them like this import xx from 'packageName/xx.vue', you will get warn like following.

If the used import is not exported from the package's main entry and can only be attained via deep import, you can explicitly add the deep import path to "optimizeDeps.include" in vite.config.js.

underfin avatar Jan 11 '21 09:01 underfin

It's like main entry contains main component, but sub-components are imported in the main component.

sharvilak11 avatar Jan 11 '21 13:01 sharvilak11

Not sure. Can you give a reproduction?

underfin avatar Jan 12 '21 02:01 underfin

Not sure. Can you give a reproduction?

I also encountered the same problem.

reproduction

https://github.com/liuarui/bug-reproduction-for-vite

error log

[vite] Internal server error: /Users/lm/Desktop/bug-reproduction-for-vite/node_modules/element-ui/packages/progress/src/progress.vue has no corresponding SFC entry in the cache. This is a vite-plugin-vue2 internal error, please open an issue.
      at Object.getDescriptor (/Users/lm/Desktop/bug-reproduction-for-vite/node_modules/vite-plugin-vue2/dist/utils/descriptorCache.js:63:15)
      at Context.load (/Users/lm/Desktop/bug-reproduction-for-vite/node_modules/vite-plugin-vue2/dist/index.js:74:54)
      at Object.load (/Users/lm/Desktop/bug-reproduction-for-vite/node_modules/vite/dist/node/chunks/dep-01eec7aa.js:44732:50)
      at processTicksAndRejections (node:internal/process/task_queues:93:5)
      at async transformRequest (/Users/lm/Desktop/bug-reproduction-for-vite/node_modules/vite/dist/node/chunks/dep-01eec7aa.js:59057:24)
      at async viteTransformMiddleware (/Users/lm/Desktop/bug-reproduction-for-vite/node_modules/vite/dist/node/chunks/dep-01eec7aa.js:59256:32)

liuarui avatar Jun 03 '21 07:06 liuarui

@underfin

liuarui avatar Jun 03 '21 09:06 liuarui

Same problem occured. Hope there is a solution.

EverChan6 avatar Jul 01 '21 07:07 EverChan6

Same for me, but as far as I know I am not importing myself those sort of components. I am using vite 2.3.8 and nuxt-vite 0.1.1, but also with the latest vite version 2.4.4 is affacted

ERROR  /.nuxt/components/nuxt-error.vue has no corresponding SFC entry in the cache. This is a vite-plugin-vue2 internal error, please open an issue.
spa-next_1                           | 
spa-next_1                           |   at Object.getDescriptor (node_modules/vite-plugin-vue2/dist/utils/descriptorCache.js:63:15)
spa-next_1                           |   at Context.load (node_modules/vite-plugin-vue2/dist/index.js:74:54)
spa-next_1                           |   at Object.load (node_modules/vite/dist/node/chunks/dep-0ed4fbc0.js:44777:50)
spa-next_1                           |   at async transformRequest (node_modules/vite/dist/node/chunks/dep-0ed4fbc0.js:60206:24)
spa-next_1                           |   at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:386:5)
spa-next_1                           |   at async Promise.all (index 0)
spa-next_1                           |   at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:388:5)
spa-next_1                           |   at async Promise.all (index 7)
spa-next_1                           |   at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:388:5)
spa-next_1                           |   at async Promise.all (index 4)
spa-next_1                           |   at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:388:5)
spa-next_1                           |   at async Promise.all (index 0)
spa-next_1                           |   at async warmupViteServer (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:390:3)

Patrick-Remy avatar Aug 03 '21 08:08 Patrick-Remy

same here

zcmk123 avatar Aug 30 '21 09:08 zcmk123

same here

It happens when i upgrade vite to the latest version 2.5.6

image

yzqdev avatar Sep 12 '21 08:09 yzqdev

In a sfc , it seems if you link the style file with "src" attribute will cause this problem, while inline style won't.

<template>
</template>
<script>
</script>
<style scoped src="./index.less" lang="less"></style>

I downgrade vite-plugin-vue2 to versionn 1.7.3 , and it works fine for me.

@underfin @yzqdev @sharvilak11

mutongwu avatar Sep 27 '21 01:09 mutongwu

  • bll_script.js

export default { setup() { return {} } }

  • index.vue

`

test js
`

appbest avatar Nov 08 '21 10:11 appbest

With version 1.9.0 I get

[vite-plugin-vue2] D:\rep\Kogut\src\Kuropatwa\vue\App.vue has no corresponding SFC entry in the cache. This is a vite-plugin-vue2 internal error, please open an issue.
file: D:/rep/Kogut/src/Kuropatwa/vue/App.scss?vue&type=style&index=0&from=D:\rep\Kogut\src\Kuropatwa\vue\App.vue&src&lang.scss
error during build:
Error: D:\rep\Kogut\src\Kuropatwa\vue\App.vue has no corresponding SFC entry in the cache. This is a vite-plugin-vue2 internal error, please open an issue.
    at getDescriptor (D:\rep\Kogut\src\WebCommonUI\node_modules\vite-plugin-vue2\dist\utils\descriptorCache.js:63:15)
    at Object.transform (D:\rep\Kogut\src\WebCommonUI\node_modules\vite-plugin-vue2\dist\index.js:108:68)
    at D:\rep\Kogut\src\WebCommonUI\node_modules\vite\node_modules\rollup\dist\shared\rollup.js:22683:25
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

downgrading to 1.8.1 helps

kskalski avatar Dec 09 '21 18:12 kskalski

I'm encountering with this error with the version 2.0.2:

@underfin

1:54:55 AM [vite] Internal server error: /Users/mac/newdev/platform-frontend/src/components/pages/RecoverPassword/RecoverPassword.vue has no corresponding SFC entry in the cache. This is a vite-plugin-vue2 internal error, please open an issue.
      at getDescriptor (/Users/mac/newdev/platform-frontend/node_modules/vite-plugin-vue2/dist/utils/descriptorCache.js:67:15)
      at Context.load (/Users/mac/newdev/platform-frontend/node_modules/vite-plugin-vue2/dist/index.js:68:72)
      at Object.load (/Users/mac/newdev/platform-frontend/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:39293:50)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async doTransform (/Users/mac/newdev/platform-frontend/node_modules/vite/dist/node/chunks/dep-c9998dc6.js:49976:24) (x2)
      

wriozumi avatar Aug 05 '22 00:08 wriozumi