hunyan-io / vite-plugin-vue-nested-sfc

Nest SFCs within your SFC.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when using Multiple Components

louiss0 opened this issue · comments

The exporting of components do work. But I get this error from my editor.

Screenshot 2023-05-07 115543

If I don't export a script or a template tag. Or when I use script setup I get this error from vite.

[plugin:vite:vue] At least one <template> or <script> is required in a single file component.
C:/Users/louis/Desktop/web-projects/ui/vue-nested-sfc-test/src/components/ComponentSets.vue
    at Object.parse$4 [as parse] (C:\Users\louis\Desktop\web-projects\ui\vue-nested-sfc-test\node_modules\.pnpm\@vue+compiler-sfc@3.2.47\node_modules\@vue\compiler-sfc\dist\compiler-sfc.cjs.js:5269:21)
    at createDescriptor (file:///C:/Users/louis/Desktop/web-projects/ui/vue-nested-sfc-test/node_modules/.pnpm/@vitejs+plugin-vue@4.2.1_vite@4.3.4_vue@3.2.47/node_modules/@vitejs/plugin-vue/dist/index.mjs:70:43)
    at handleHotUpdate (file:///C:/Users/louis/Desktop/web-projects/ui/vue-nested-sfc-test/node_modules/.pnpm/@vitejs+plugin-vue@4.2.1_vite@4.3.4_vue@3.2.47/node_modules/@vitejs/plugin-vue/dist/index.mjs:2114:26)
    at async handleHMRUpdate (file:///C:/Users/louis/Desktop/web-projects/ui/vue-nested-sfc-test/node_modules/.pnpm/vite@4.3.4/node_modules/vite/dist/node/chunks/dep-f7d05e3f.js:39972:33)
    at async onHMRUpdate (file:///C:/Users/louis/Desktop/web-projects/ui/vue-nested-sfc-test/node_modules/.pnpm/vite@4.3.4/node_modules/vite/dist/node/chunks/dep-f7d05e3f.js:63335:17)
    at async FSWatcher.<anonymous> (file:///C:/Users/louis/Desktop/web-projects/ui/vue-nested-sfc-test/node_modules

Link to minimal reproducible example
https://github.com/louiss0/vue-nested-sfc-test

The example repo you linked works fine here. I'm guessing you updated the package but didn't reload your IDE. Try reloading it and let me know if it's still not working.

Regarding the vite issue, it's currently the intended behavior, vite-plugin-vue by default doesn't support empty SFCs (a component without template and script is considered empty). I'm not sure if this is something I can tweak, I'll investigate it, but for now it's out of the scope of this plugin.

The example repo you linked works fine here. I'm guessing you updated the package but didn't reload your IDE. Try reloading it and let me know if it's still not working.

Regarding the vite issue, it's currently the intended behavior, vite-plugin-vue by default doesn't support empty SFCs (a component without template and script is considered empty). I'm not sure if this is something I can tweak, I'll investigate it, but for now it's out of the scope of this plugin.

Things are working fine I'll have to bring this issue to the vite team. But in the meantime, you could take the time to do some researrch on how Volar works. The fact that I have to specify a language every time sucks.
The script or template error needs to be suppressed by this plugin.

I was told that this is a compiler error that was created due to this issue. vuejs/core#6676. You need to find a way to catch vue compiler errors not vite errors.

The first problem is solved. I think you need to talk to the team about the second problem. This library is good enough for my use cases and I think I may start promoting it soon. I love using vue directives.