简体   繁体   English

使用什么框架来构建 Web 组件:lit-element vs stencil vs SkateJS?

[英]What framework to use in order to build web components: lit-element vs stencil vs SkateJS?

I want to start leveraging http://webcomponents.me W3C standard which is now supported by all major web browsers.我想开始利用http://webcomponents.me W3C 标准,现在所有主要的 Web 浏览器都支持该标准。

I researched the internet and so far I found following frameworks:我研究了互联网,到目前为止,我发现了以下框架:

  1. Stencil - Created by ionic. Stencil - 由离子创建。 All ionic components use this framework/compiler in order to build native supported web components.所有 ionic 组件都使用此框架/编译器来构建原生支持的 Web 组件。

  2. lit-element - Created by Google and is part of Polymer framework. lit-element - 由 Google 创建,是 Polymer 框架的一部分。

  3. SkateJS - Don't know how is behind this but it is in top 3 popular web components framework. SkateJS - 不知道这背后的原因,但它是前 3 大流行的 Web 组件框架。

Can someone give me advice or opinion which framework is best?有人可以给我建议或意见哪个框架最好?

If you want to build:如果你想构建:

  • Fast快速地
  • Easy-to-debug易于调试
  • Cross-browser跨浏览器
  • Framework-agnostic框架无关

web components you could also consider using您也可以考虑使用 Web 组件香草JS framework :框架 :

http://vanilla-js.com/ http://vanilla-js.com/

As I've been working with native vanilla JS web components for the past 4.5 years as my main subject, I would like to add my opinion as a seasoned web developer with almost 30 years of experience.由于过去 4.5 年来我一直在使用原生 vanilla JS Web 组件作为我的主要主题,因此我想作为一名拥有近 30 年经验的经验丰富的 Web 开发人员补充我的看法。

As with all development tooling, these tools share a common problem.与所有开发工具一样,这些工具有一个共同的问题。 Either they要么他们

  • evolve - forcing you into an undesirable update loop, keeping you busy with stuff that's long-finished just to keep the tooling fresh and secure,进化——强迫你进入一个不受欢迎的更新循环,让你忙于那些早已完成的东西,只是为了保持工具的新鲜和安全,
  • or they just "die" - check SkateJS eg The last commit on that repo is now 3 years old and open issues from 2019 exist that haven't even been commented on.或者他们只是“死” - 检查SkateJS例如,该回购的最后一次提交现在已经 3 年了,并且存在 2019 年的未解决问题,甚至没有被评论。 The latest release is from 2017!!最新版本是 2017 年的!!

This is not only true for authoring tools like the three suggestions you mentioned - this is also true for the whole build stack tooling .这不仅适用于您提到的三个建议之类的创作工具,也适用于整个构建堆栈工具

Last year I took a dive to see what kind of modern build tools would be nice to work with for authoring web component libs.去年,我深入研究了哪种现代构建工具可以很好地用于创作 Web 组件库。 When doing the research, I stumbled upon Snowpack and Vite.js .在进行研究时,我偶然发现了SnowpackVite.js。 We started out with Snowpack, but at the time it still seemed to have a number of stability issues, so we decided to switch to Vite.js.我们开始使用 Snowpack,但当时它似乎仍然存在一些稳定性问题,因此我们决定切换到 Vite.js。 Last week I decided to give Snowpack another shot, only to find it deprecated in favor of Vite.js:上周我决定再试一次 Snowpack,结果发现它被 Vite.js弃用了:

在此处输入图像描述

Stuff like this happens way too often, and while tooling should help you get stuff done faster and better, more often than not you find yourself dealing with the shortcomings of the tooling, incompatibilities with addons when updating the main library, security issues... rather than focussing on doing your business coding.像这样的事情经常发生,虽然工具可以帮助您更快更好地完成工作,但您往往会发现自己处理工具的缺点,更新主库时与插件的不兼容,安全问题......而不是专注于进行业务编码。

This is also true for popular tools like Storybook.对于 Storybook 等流行工具也是如此。

Once you start relying only on ECMAScript itself, and the browser API, you'll learn that most things like eg routing for SPAs are quite easy to develop yourself.一旦你开始只依赖 ECMAScript 本身和浏览器 API,你就会发现大多数东西,例如 SPA 的路由,都是很容易自己开发的。

You probably won't need a build stack any more very soon.您可能很快就不再需要构建堆栈了。 We have widespread support for HTTP/2, making bundling undesirable anyway, so just work with native ES modules .我们对 HTTP/2 有广泛的支持,无论如何都不希望捆绑,所以只需使用原生 ES 模块即可。 Not using a build tool and not bundling also has the huge benefit of not having to generate and rely on maps any more;不使用构建工具和不捆绑还有一个巨大的好处,那就是不再需要生成和依赖地图; let alone the fact that it immensely improves the development experience by keeping turnaround times in no-matter-how-complex projects in the ms realm.更不用说它通过在ms领域的任何复杂项目中保持周转时间来极大地改善开发体验这一事实。 Code-you-write-is-code-that-runs - how amazing is that?你写的代码就是运行的代码——这有多神奇? No third-party-black boxes when your debugging leads you into code that would take you years to understand.当您的调试引导您进入需要数年时间才能理解的代码时,没有第三方黑匣子。

Instead of CSS preprocessors, work with native CSS and custom properties - native CSS nesting is coming to browsers as well .代替 CSS 预处理器,使用原生 CSS 和自定义属性-原生 CSS 嵌套也将出现在浏览器中

To go fully build-less, there's unfortunately still some bits and pieces missing, but those are in progress.为了完全无构建,不幸的是仍然缺少一些零碎的东西,但这些都在进行中。 The most important ones are:最重要的是:

Some libraries are already picking up on this, eg ficus.js .一些库已经开始关注这一点,例如ficus.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM