3 ms·
How easy would it be to "hook into" Svelte's compilation pipeline so that users can create their own optimisations? I ask that because I work in a huge codebase
by eliseumds 7y ago
How easy would it be to "hook into" Svelte's compilation pipeline so that users can create their own optimisations? I ask that because I work in a huge codebase with many layers of component abstraction and performance is starting to take a hit. For example, most of these components:
<Box flex flexAlignItems="center" marginTop={5}>
<Heading level={2} caret="down">
Profile info
</Heading>
<Media>
<Avatar id={avatarId} size="small" lazy />
<Media.Block marginLeft={2}>
{displayName}
</Media.Block>
</Media>
</Box>
would be compiled into their simplest forms:
<div className="flex flex-align-items-center margin-top-5">
<h2>
Profile info <span className="caret-down" />
</h2>
<div className="media">
<img src="https://www.cdn.com/avatar/{avatarId}" className="avatar-small" lazyload="on" />
<div className="media-block margin-left-2">
{displayName}
</div>
</div>
</div>
I believe the technique is called "component folding". I tried to do it with Babel but it's a real pain.
Thanks for putting so much work into exploring alternative ways of making the web faster, because, at the moment, it still requires an immense effort.
- artemir 7y agoYeah, I search the same solution. Because, I don't like write CSS and prefer use component abstraction layer, which allow write much simple code and it's really nice to read