TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Is it possible to write framework agnostic ES6 components?

1 点作者 wheresvic3超过 7 年前
We were looking to create a widget library and were wondering if it would be possible to create completely framework agnostic components (i.e. using only ES2015 syntax + html5 + css)<p>These widgets would be used in React, Angular, Vue applications.<p>Is creating web components the only answer? Integrating web components into a React&#x2F;Angular application is not trivial either.

1 comment

kylecordes超过 7 年前
This is a suddenly, extremely busy area, in the form of web components. Using web components is quite easy from Angular already, and from several other frameworks including Vue. Web components is the standard in this area, I can&#x27;t imagine an alternative would possibly get traction now that web components are here. I don&#x27;t know what integration difficulty you&#x27;re thinking of, but regardless, the answer will be to get the JavaScript from your web components on the page, in addition to the JavaScript from your main library&#x2F;framework.<p>React has some irritations consuming web components in the current version (because it favors attributes over properties, which seemed like a good idea at the time), but in the next version that will be resolved also.<p>Some starting points:<p>Polymer - the upcoming version of that will be quite convenient to use with es2015 classes. Polymer is pretty much ready for production work today (including the new enormous YouTube revamp, which they are rolling out) but aimed at an older syntax.<p><a href="https:&#x2F;&#x2F;www.polymer-project.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.polymer-project.org&#x2F;</a><p>Skate might be closer to what you&#x27;re looking for today, although it also has a significant revamp in progress that changes lots of things.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;skatejs&#x2F;skatejs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;skatejs&#x2F;skatejs</a><p>The latest entrant is Stencil. It&#x27;s not quite exactly the stack you described, rather it uses TypeScript. Stencil is extremely promising.<p><a href="https:&#x2F;&#x2F;stenciljs.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;stenciljs.com&#x2F;</a>
评论 #15355652 未加载