5 ms·
I might be wrong, but the way I see it is that Web Components give the basic blocks of writing those frameworks easier. Of course, most of those frameworks are
by selectnull 3y ago
I might be wrong, but the way I see it is that Web Components give the basic blocks of writing those frameworks easier. Of course, most of those frameworks are older than WCs and they made their own choices about how to implement components and probably (I don't really know) don't use WC (or use only parts of it).
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.
- auggierose 3y agoWhat kind of functionality is "runs natively in the browser"? JSX also runs in every browser. Edit: Just rename "Web Components" into "Web Tags" and it's all good.
- selectnull 3y agoI don't know what browser you use, but when I do: const el = <p>Hello, world!</p>; I get `Uncaught SyntaxError: Unexpected token '<'`. I even tried in several browsers, no luck.
- auggierose 3y agoIt seems the problem here is not the browser, but your lack of knowledge.
- dtagames 3y agoYou're just missing two things. First, install Lit. Then write it as: 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/Reference/Template_literals https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- troupo 3y agoBoth are non-standard DSLs that need an external library to work
- afavour 3y ago1) that’s not JSX, it just looks like it 2) it’s still an external library, which is OPs point
- dtagames 3y agoI don't think Lit counts as a framework. It's much lower-level plumbing. And tagged template literals are part of the browser.
- troupo 3y agoBut lit's DSL isn't a part of the browser. Neither is lit's data binding/reactivity. Nor lit's rules on directives. Nor lit's tasks. Nor lit's context. Nor...
- auggierose 3y agoYes, I would agree with that. And that's why "running natively in the browser" is not a remarkable feature of web components, because you will need something like lit anyway for using web components in a productive way. So you might as well use React, or any of the other billion frameworks.
- troupo 3y ago> Web Components give the basic blocks of writing those frameworks easier. 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-future-hfh 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 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-2cia 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 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.
- earthboundkid 3y ago> Web Components give the basic blocks of writing those frameworks easier. 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.