Re:Ways to make a web component
by olex on Friday July 17, 2020 @01:30PM
(#23873094)
This is exactly how vue.js "single file components" work - a <template> with the "bunch of html", <script> and optional <style> blocks.
[ Parent
| on HN ]
that's pretty close to what i'm thinking of, but still has some limitations (from https://vuejs.org/v2/guide/single-file-components.html):
• Global definitions force unique names for every component
• String templates lack syntax highlighting and require ugly slashes for multiline HTML
• No CSS support means that while HTML and JavaScript are modularized into components, CSS is conspicuously left out
• No build step restricts us to HTML and ES5 JavaScript, rather than preprocessors like Pug (formerly Jade) and Babel
You may be misunderstanding (or I’m not understanding your intent). Single-file components were made specifically to overcome those issues, as mentioned on the page you linked.