<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: natseg</title>
    <description>The latest articles on DEV Community by natseg (@natseg).</description>
    <link>https://dev.to/natseg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F117100%2F604d3922-00bb-4e30-af06-7c8e51045c06.gif</url>
      <title>DEV Community: natseg</title>
      <link>https://dev.to/natseg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/natseg"/>
    <language>en</language>
    <item>
      <title>How to make your life easier when developing a front-end library </title>
      <dc:creator>natseg</dc:creator>
      <pubDate>Thu, 07 Feb 2019 12:21:57 +0000</pubDate>
      <link>https://dev.to/natseg/how-to-make-your-life-easier-when-developing-a-front-end-library--4pjk</link>
      <guid>https://dev.to/natseg/how-to-make-your-life-easier-when-developing-a-front-end-library--4pjk</guid>
      <description>&lt;p&gt;Let's say you have a good use case to develop a front-end library.&lt;/p&gt;

&lt;p&gt;It could be that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you're re-using a lot of similar components in different apps&lt;/li&gt;
&lt;li&gt;you want to decouple your apps from an external api&lt;/li&gt;
&lt;li&gt;you want to play around with javascript for the fun of it&lt;/li&gt;
&lt;li&gt;...&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;You set up your repository with git using the provider you prefer (github, gitlab, ...)&lt;/li&gt;
&lt;li&gt;You can choose to use a boilerplate for the framework you wish to use (Typescript, React, both, ...)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once you have done this, you realize that in order to integrate with your app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you need to run a build depending on the bundling manager you use (rollup, webpack, ...)&lt;/li&gt;
&lt;li&gt;you need to tell your app where to find the package being developed&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;At this point, I would advise using &lt;code&gt;link&lt;/code&gt;, a command which exists both for  &lt;a href="https://yarnpkg.com/lang/en/docs/cli/link/" rel="noopener noreferrer"&gt; yarn&lt;/a&gt; and &lt;a href="https://docs.npmjs.com/cli/link.html" rel="noopener noreferrer"&gt;npm&lt;/a&gt;.&lt;br&gt;
This creates a symbolic link between your app and the library you're working on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To avoid having to "manually" rebuild after each code change in the library, use your bundler cli with the  &lt;a href="https://webpack.js.org/api/cli/#watch-options"&gt;&lt;code&gt;watch&lt;/code&gt;&lt;/a&gt; flag to watch the files recursively&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose a test framework and you're ready to go!&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Gotchas: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;running &lt;code&gt;install&lt;/code&gt; at any point after this will overwrite the link.&lt;/li&gt;
&lt;li&gt;be mindful of what locks the version in your &lt;code&gt;package.json&lt;/code&gt; in doubt, you could switch from &lt;code&gt;caret&lt;/code&gt; to &lt;code&gt;tilde&lt;/code&gt; or lock onto exact versions (with &lt;a href="https://docs.npmjs.com/cli/install"&gt;the --save-exact flag&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CODE, SWEAT, SWEAR AND TEST&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before deploying and publishing a package that needs code-review and QA:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build the latest version of your code&lt;/li&gt;
&lt;li&gt;Use &lt;a href="https://docs.npmjs.com/cli/pack.html"&gt;&lt;code&gt;npm pack&lt;/code&gt;&lt;/a&gt; in the repository of your library&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This creates a tarball file you can move to the repository of the app you want QA to test it with.&lt;br&gt;
Run &lt;code&gt;mv nameoftarball ../wherever/your_app/lives&lt;/code&gt;&lt;br&gt;
Then &lt;code&gt;cd ../wherever/your_app/lives &amp;amp;&amp;amp; npm i nameoftarball&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Commit, push, deploy to a staging/test environment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you get the all clear, whatever you deploy will be spot-on! &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
  </channel>
</rss>
