DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on • Updated on

Why are we using single file components in the first place?

Be it Vue, Svelte or Riot; I feel that VSCode has hard time check for TypeScript inside it...

Vue's Vetur is shit. It doesn't support monorepos at the very least.

JavaScript-based, e.g. JSX, hyperscript, have none of these problems...

Angular, being multiple files in a single folder, doesn't have these problems also.

Top comments (7)

Collapse
 
alainvanhout profile image
Alain Van Hout

There is nothing inherently better or worse in using single file components. Editors like VSCode understand what they are programmed so understand, no more no less. The fact that JSX is better supported than e.g. Vue or Svelte is because people have done the work for JSX but not (yet) for Vue or Svelte.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

You might argue that the best support is for single files such as CSS, JS and HTML having been around the longest and would be on the core support list for the editor development team. So yes any DSL is going to be worse for support depending on the community.

For typescript the fault is the integration between the Typescript language server and the author of the plugin.

Collapse
 
dmondev profile image
dmondev

We can create single file components in angular as well, with inline style and template. Thats pretty neat and I like to use it as an additional way to force myself to break components into smaller pieces as they get bigger. The support for html is ok, but for css is meh. That is not a big deal if we keep the components small, which should be the case anyway.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

I agree sometimes. SFC's can get unmanageable pretty fast but then to solve that you spilt up into smaller SFC's. A separate file approach cool too, probably easier to reuse.

Collapse
 
18735443937 profile image
18735443937

DVDVDVDB

Collapse
 
18735443937 profile image
18735443937

FFB

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Webstorm license holders club 🤘

Some comments may only be visible to logged-in visitors. Sign in to view all comments.