Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using Multiple Components #4

Closed
louiss0 opened this issue May 7, 2023 · 4 comments
Closed

Error when using Multiple Components #4

louiss0 opened this issue May 7, 2023 · 4 comments

Comments

@louiss0
Copy link

louiss0 commented May 7, 2023

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

@hunyan-io
Copy link
Owner

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.

@louiss0
Copy link
Author

louiss0 commented May 7, 2023

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.

@louiss0
Copy link
Author

louiss0 commented May 8, 2023

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.

@louiss0
Copy link
Author

louiss0 commented May 12, 2023

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.

@louiss0 louiss0 closed this as completed May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants