By comparison your complains seem like those faced by the kind of people making the Lit framework. IMO neither viewpoint is invalid.
By comparison your complains seem like those faced by the kind of people making the Lit framework. IMO neither viewpoint is invalid.
Once you've reached for a framework that papers over all the issues, and offers you a nice interface, it's no different if you reach for React, Preact, Vue, Svelte, or lit :)
But, if someone wanted to make a new framework, today, I see no reason why they wouldn't use WCs. And let's not have an argument about JSX being a nicer developer experience, because sure it is nicer to use JSX and have autocompletion and all, but JSX does not run natively in the browser. WCs do. There are compromises.
JSX also runs in every browser.
Edit: Just rename "Web Components" into "Web Tags" and it's all good.
const el = <p>Hello, world!</p>;
I get `Uncaught SyntaxError: Unexpected token '<'`. I even tried in several browsers, no luck.const el = html`<p>Hello, world!</p>`
And you're done. These are called "tagged template literals[0]". Lit gives you the html "tag" for the literal that you're looking for.
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
2) it’s still an external library, which is OPs point
No, they don't. Both for the fact that they need 20 more web specs to fix issues that none of the frameworks have, to the fact that they are actually pretty bad as basic building blocks: you can't control their rendering (once a web component is on the page, it will eagerly render, and will pull in and render whatever imports it has); shadow dom breaks all sorts of expectations; each is an isolated rendering block, so you can't control for batch rendering; there's no server-side rendering story to speak of, and that's only off the top of my head.
There are many more tehcnical reasons than I listed, but I'd have to hunt them down. There are many, many, many reasons why even the authors which originally really rooted for web components, and modeled their frameworks after them now moved awaya from them completely (Solid, Svelte, Vue).
There are also many, many, many reasons why even the new framework overwhelmingly _don't_ use web components for anything.
There are a few thoughts^
- Ryan Carniato (Solid): https://dev.to/ryansolid/maybe-web-components-are-not-the-fu...
- Ryan Carniato's stream on web components: https://www.youtube.com/watch?v=BEWkLXU1Wlc (you can skip to 1:37:17 for a specific discussion)
- Rich Harris (Svelte): https://dev.to/richharris/why-i-don-t-use-web-components-2ci...
- All these issues are still there, 4 years later: https://twitter.com/Rich_Harris/status/1198332398561353728
and so on and so forth.
> but JSX does not run natively in the browser. WCs do. There are compromises.
JSX is probably the absolute last thing frameworks care about. They do care about things like not jumping through hoops to make things work.
The argument of the post is that they should but don't really, and some new building blocks should be added to help with that.