<?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: D/S</title>
    <description>The latest articles on DEV Community by D/S (@intercoder).</description>
    <link>https://dev.to/intercoder</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%2F1291%2F10117664.png</url>
      <title>DEV Community: D/S</title>
      <link>https://dev.to/intercoder</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/intercoder"/>
    <language>en</language>
    <item>
      <title>Difference between Node dependencies using emojis 🤷‍♂️ 🤷‍♀️</title>
      <dc:creator>D/S</dc:creator>
      <pubDate>Sun, 26 May 2019 20:04:10 +0000</pubDate>
      <link>https://dev.to/intercoder/difference-between-node-dependencies-using-emojis-43ne</link>
      <guid>https://dev.to/intercoder/difference-between-node-dependencies-using-emojis-43ne</guid>
      <description>&lt;p&gt;Node dependencies come in different forms: &lt;code&gt;dependencies&lt;/code&gt;, &lt;code&gt;devDependencies&lt;/code&gt;, &lt;code&gt;peerDependencies&lt;/code&gt;, &lt;code&gt;bundleDependencies&lt;/code&gt; and  &lt;code&gt;optionalDependencies&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We’ll be tackling the first three in this blog post, which are the ones which interests us the most, but I’ll briefly explain what &lt;code&gt;bundleDependecies&lt;/code&gt; and &lt;code&gt;optionalDependencies&lt;/code&gt; are.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;bundleDependencies&lt;/code&gt;: these dependencies are the dependencies that will be bundled alongside your library if you run npm pack. From the folks @npm themselves:&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;"This defines an array of package names that will be bundled when publishing the package."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;optionalDependencies&lt;/code&gt;: are dependencies which are, well, optional. I’ll let myself out 😀. Dependencies installed here will not make the installation of your library fail if they can’t be found. I consider them as the alternate version of dependencies without being so strict. From your friends @npm:&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;“If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the optionalDependencies object.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;🚨 Keep in mind that you have to specify either dependencies or optionalDependencies but not both 🚨&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Entries in optionalDependencies will override entries of the same name in dependencies, so it’s usually best to only put in one place.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;With that out of the way, let’s get rolling with the other three sort of dependencies node give us.&lt;/p&gt;




&lt;p&gt;If you have come across a &lt;code&gt;package.json&lt;/code&gt; in your programming day(s), you’ll probably have seen a &lt;code&gt;dependencies&lt;/code&gt;, &lt;code&gt;devDependencies&lt;/code&gt; and/or even perhaps their step cousin, the &lt;code&gt;peerDependencies&lt;/code&gt; object, a.k.a 🍐Dependencies.&lt;/p&gt;

&lt;p&gt;…get it, get it ?…cause it sounds like 🍐… ok, I’ll stop now... 🙂&lt;/p&gt;

&lt;p&gt;This last one, usually comes in the flavor of a warning while you try to install x package. Usually in the form of:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;the package 'x' has an unmet peerDependency of 'y@1.0.0'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You might be wondering, how are these things even related? Let’s look at all three of them by creating our own “Making a Burger 🍔” library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// pseudo package.json with some emojis

{
 “name”: “making-a-burger”,
 “version”: “1.0.0”,
 “description”: “🍔 lib”,
 “main”: “index.js”,
 “author”: “🙋‍♂️”,
 “license”: “MIT”,
 “dependencies”: {
   “🥩”: “meat@2.0.0”
  },
 “devDependencies”: {
   “🥚”: “egg-yolk@1.O.O”
  },
 “peerDependencies”: {
   “🍞”: “&amp;gt;= bread@1.x”
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In actual words this could be translated onto …&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dependencies: hey, to make this 🍔 library (a.k.a run a burger) you must have 🥩 on hand. The library runs on it… (except if you are making a veggie burger 🚫 🐮, of course).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good example would be things like &lt;code&gt;vue&lt;/code&gt;, &lt;code&gt;react&lt;/code&gt;, &lt;code&gt;react-native&lt;/code&gt;, &lt;code&gt;eslint&lt;/code&gt; (if making a shareable eslint-config file), etc.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;devDependencies: yo, while developing that 🍔 you better have an 🥚 on hand since this will ease the process… (and give flavor to your food 😋…and maybe salmonella if you don’t cook it right… ?).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Packages that work on the modification/manipulation/testing of your original code are a good example for this type of dependency: &lt;code&gt;@babel/*&lt;/code&gt;, &lt;code&gt;webpack&lt;/code&gt;, &lt;code&gt;jest&lt;/code&gt;, etc.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;peerDependencies: bro/bro-ette(…🤔 ?), don’t be trying to make this 🍔 library without having some 🍞 also in hand at equal or greater than version 1.x….(version gluten-free, normal, whole-grain…ok, this one is actually a pretty bad joke).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This last one is the most interesting one. We specify &lt;code&gt;peerDependencies&lt;/code&gt; to let users of your library know that they must have this minimum version of this other dependency also installed, because the overall library runs on them. In other words:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;package ‘x’ also depends on having package ‘y@1’ installed.&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;And just to do a complete circle, 🙂 if we were going to add &lt;code&gt;optionalDepedencies&lt;/code&gt; and &lt;code&gt;bundleDependencies&lt;/code&gt; to this library they will be on the form of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 “name”: “making-a-burger”,
 “version”: “1.0.0”,
 “description”: “🍔 lib”,
 “main”: “index.js”,
 “author”: “🙋‍♂️”,
 “license”: “MIT”,
 “dependencies”: {
   “🥩”: “meat@2.0.0”
  },
 “devDependencies”: {
   “🥚”: “egg-yolk@1.O.O"
  },
 “peerDependencies”: {
   “🍞”: “&amp;gt;= bread@1.x”
  }
 “optionalDependencies”: {
   “🥬”: “lettuce@3.2.x”
  },
 “bundleDependencies”: [
   “🍟”, "🥤"
  ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I guess that’s it, I hope this have been somewhat helpful or at the very least fun.&lt;/p&gt;

&lt;p&gt;If you want to learn more about node dependencies and all the goodies that go inside a package.json, don’t forget to take a look at the &lt;a href="https://docs.npmjs.com/files/package.json"&gt;npm-docs&lt;/a&gt; cause it’s filled with useful info.&lt;/p&gt;

&lt;p&gt;Thanks for reading and if something is not clear shoot me a comment. All feedback is welcome.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; As I finished writing this, I realized that a better example for &lt;code&gt;devDependencies&lt;/code&gt; would have been a meat grinder (?), but I couldn’t find that emoji 😔 .&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>packagejson</category>
      <category>dependencies</category>
    </item>
    <item>
      <title>Hi, I'm D/S</title>
      <dc:creator>D/S</dc:creator>
      <pubDate>Wed, 04 Jan 2017 16:24:48 +0000</pubDate>
      <link>https://dev.to/intercoder/hi-im-ds</link>
      <guid>https://dev.to/intercoder/hi-im-ds</guid>
      <description>&lt;p&gt;I have been coding for [number] years.&lt;/p&gt;

&lt;p&gt;You can find me on GitHub as &lt;a href="https://github.com/dantesolis" rel="noopener noreferrer"&gt;dantesolis&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I live in [city].&lt;/p&gt;

&lt;p&gt;I work for [company]&lt;/p&gt;

&lt;p&gt;I mostly program in these languages: [languages].&lt;/p&gt;

&lt;p&gt;I am currently learning more about [topic].&lt;/p&gt;

&lt;p&gt;Nice to meet you.&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
