<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jasper De Moor on Medium]]></title>
        <description><![CDATA[Stories by Jasper De Moor on Medium]]></description>
        <link>https://medium.com/@jasperdemoor?source=rss-efd0bc8ea84c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*t1HdgxKDCBDary4MWYuimg.jpeg</url>
            <title>Stories by Jasper De Moor on Medium</title>
            <link>https://medium.com/@jasperdemoor?source=rss-efd0bc8ea84c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 19:11:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jasperdemoor/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introducing Stylish-Components]]></title>
            <link>https://medium.com/@jasperdemoor/introducing-stylish-components-62c8a0467ea1?source=rss-efd0bc8ea84c------2</link>
            <guid isPermaLink="false">https://medium.com/p/62c8a0467ea1</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[styled]]></category>
            <category><![CDATA[components]]></category>
            <dc:creator><![CDATA[Jasper De Moor]]></dc:creator>
            <pubDate>Sat, 05 May 2018 12:27:02 GMT</pubDate>
            <atom:updated>2018-05-05T12:34:45.858Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gjb6Ux6fD81RV6rXcmElEw.png" /><figcaption>Stylish Components</figcaption></figure><p>Stylish components is a lightweight alternative to styled-components, with the same core functionality and functions at 1/10 of the size.</p><h3>How does it work?</h3><p>Like mentioned in the intro, stylish works kind of the same as styled components, so you simply create a component using stylish.&lt;html tag&gt;`/*some css*/` the css follows standard css syntax with some slight variations, like &amp; as a placeholder for the class hash the component will get.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3a1d25cc30be9b9c08f8b1a104a2546/href">https://medium.com/media/e3a1d25cc30be9b9c08f8b1a104a2546/href</a></iframe><h3>How tiny is it?</h3><p>Well I’ve replaced styled-components in my personal website (<a href="http://jasperdemoor.me/">http://jasperdemoor.me</a>) with stylish-components and it changed the JavaScript bundle’s size from 185.89kB to 139.80kB that seems to be pretty significant to me. (this is including minification and other build optimisations)</p><p>I’ve also added stylish-components and styled-components under each other in my visual studio code which reports import file sizes…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*72jat-JTUfXt5N7SGpeVUQ.png" /><figcaption>VSCODE import file size comparison</figcaption></figure><p>Like originally mentioned it reports to be 1/10th of the styled-components size.</p><h3>So what can it do?</h3><p>Well the functionality is pretty limited compared to styled-components, and it’s not really a drop-in replacement either. It could be as long as the only features u use are styled and css. You could simply set up an alias to do this.</p><h4>Using CSS Events</h4><p>You can use &amp; for css events, this basically gets replaced by the classname the component will get.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3590e6f2308de0b408a6a4a944103136/href">https://medium.com/media/3590e6f2308de0b408a6a4a944103136/href</a></iframe><h4>It can handle media queries</h4><p>Stylish components can handle media queries just like styled-components</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90021468d59a52c884a70dec24bcd2e4/href">https://medium.com/media/90021468d59a52c884a70dec24bcd2e4/href</a></iframe><h4>You can extend the components</h4><p>If you want to extend a component you can! You can also chain is as much as you want.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/242eb78fb23b1689785c681941c52817/href">https://medium.com/media/242eb78fb23b1689785c681941c52817/href</a></iframe><h4>You can use props and all the fancy features template strings have to offer</h4><p>The core reason for using css-in-js in my personal opinion is the ability to actually utilise JavaScript functions and props in your stylish components, therefore stylish-components supports both props and the standard template strings syntax.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7653ed2de4e1b56e0365bf5150efceab/href">https://medium.com/media/7653ed2de4e1b56e0365bf5150efceab/href</a></iframe><h3>Get it now using npm (or yarn)!</h3><p><a href="https://www.npmjs.com/package/tiny-stylish-components">tiny-stylish-components</a></p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62c8a0467ea1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing a parcel plugin]]></title>
            <link>https://medium.com/@jasperdemoor/writing-a-parcel-plugin-3936271cbaaa?source=rss-efd0bc8ea84c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3936271cbaaa</guid>
            <category><![CDATA[parcel-bundler]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[plugins]]></category>
            <dc:creator><![CDATA[Jasper De Moor]]></dc:creator>
            <pubDate>Thu, 03 May 2018 11:07:45 GMT</pubDate>
            <atom:updated>2018-05-03T11:07:45.677Z</atom:updated>
            <content:encoded><![CDATA[<p>Today I rewrote my plugin parcel-plugin-svelte and thought it was a good time to do a little write-up on how to tackle creating a parcel plugin, ready? Let’s dive right in!</p><h3>Getting started</h3><p>To get started create a new project:</p><pre>mkdir parcel-plugin-myplugin &amp;&amp; cd parcel-plugin-myplugin<br>yarn init -y</pre><p>After that install parcel as a dev and peer dependency, as well as any compiler you need to compile the actual code (in this tutorial I’ll use svelte)</p><p>Your compiler could also be set as a regular dependency (if the user doesn’t require it for writing the actual code)</p><pre>yarn add parcel-bundler svelte -P<br>yarn add parcel-bundler svelte -D</pre><h4>The entrypoint</h4><p>When parcel loads a plugin it calls the default export as a function and passes the bundler as a parameter, inside the function you then register the asset types to the bundler. (The default export can also be an async function)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a2bdd90fc2229d5078e4c03660a7eea/href">https://medium.com/media/1a2bdd90fc2229d5078e4c03660a7eea/href</a></iframe><h4>The Asset</h4><p>The core of the plugin of course is the asset you are adding support for, parcel supports something called a pipeline this makes it possible for your asset types to export more than one asset type, comes in handy for assets like Vue or Svelte in this case.</p><p>Parcel exports the Asset class we’ll be extending, you can import it like this</p><pre>const { Asset } = require(&#39;parcel-bundler&#39;);</pre><p>In the constructor you declare the asset type if it differs from the file extension, otherwise you can skip this part. Keep in mind the type is being used for creating the bundles. So if the output is JS you better change the type to JS.</p><pre>class SvelteAsset extends Asset {<br>  constructor(name, pkg, options) {<br>    super(name, pkg, options);<br>    this.type = &#39;js&#39;;<br>  }<br>}</pre><p>For processing the Asset, parcel calls the function generate()</p><pre>async generate() {</pre><pre>}</pre><p>Parcel’s Asset class contains a function called getConfig this function returns the config object if a config is found, but also watches the config file for changes to invalidate cache. As most asset types have some sort of config, it’s useful to get the config, before processing the asset.</p><pre>let config = await this.getConfig([&#39;.configrc&#39;, &#39;asset.config.js&#39;]);</pre><p>After you have fetched the config inside the generate function you can continue to process the content. This code snippet shows how it works inside Svelte, look at the docs of the compiler you are using as this differs per language.</p><pre>let compiled = compile(this.contents, config);</pre><p>This is pretty much it, now you can return the output of the compiled code to be processed further by parcel and bundled.</p><pre>let compiled = compile(this.contents, config);<br>let code = compiled.js.code;<br>let map = compiled.js.map;<br>let css = compiled.css.code;</pre><pre>return [<br>  {<br>    type: &#39;js&#39;,<br>    value: code,<br>    sourceMap: this.options.sourceMaps ? map : undefined<br>  },<br>  {<br>    type: &#39;css&#39;,<br>    value: css<br>  }<br>];</pre><p>The whole Asset code looks like this inside the Svelte plugin</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc44db3dcc18449ef8d9d5102cfe5b32/href">https://medium.com/media/dc44db3dcc18449ef8d9d5102cfe5b32/href</a></iframe><h3>Testing</h3><p>In this example I’ll use mocha for testing.</p><pre>yarn add mocha -D</pre><p>Creating a test</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8cba674c87a096704ee8c5e311c8f6eb/href">https://medium.com/media/8cba674c87a096704ee8c5e311c8f6eb/href</a></iframe><p>Inside the test you first have to create a bundler, the recommended bundler settings for testing are the ones I defined in the gist, as these don’t clutter the test environment and simply just bundle the code.</p><p>After creating the bundler you can register your plugin to the bundler, you do this by simply passing the bundler to the entry point function of the plugin, as explained in the very beginning of this post.</p><p>It’s important to have your environment variable set to test this way parcel throws errors instead of catching them and logging them.</p><pre>&quot;scripts&quot;: {<br>  &quot;test&quot;: &quot;NODE_ENV=test mocha --timeout 50000&quot;<br>}</pre><p>For comparing the output bundle with the expected output you can utilise the package <a href="https://www.npmjs.com/package/parcel-assert-bundle-tree">parcel-assert-bundle-tree</a> this package is a function that has been copied from the parcel-bundler test environment, for comparing bundles.</p><h4>Thank you</h4><p>That’s it, thank you for reading and hopefully you can now hack together a parcel plugin without any issues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3936271cbaaa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>