{"id":511,"date":"2013-05-02T22:29:31","date_gmt":"2013-05-02T20:29:31","guid":{"rendered":"https:\/\/kari.world.ikari.fi\/?p=511"},"modified":"2013-05-02T22:29:31","modified_gmt":"2013-05-02T20:29:31","slug":"javascript-dependency-hell","status":"publish","type":"post","link":"https:\/\/kari.world.ikari.fi\/?p=511","title":{"rendered":"Javascript dependency hell"},"content":{"rendered":"<p>Okey,<\/p>\n<p>Scenario is this: There is two competing libraries for &#8221;_&#8221; (aka. underscore) global variable. Libraries in question are &#8221;<a href=\"http:\/\/underscorejs.org\/\">underscore<\/a>&#8221; and &#8221;<a href=\"http:\/\/lodash.com\/\">lodash<\/a>&#8221;. Problem is that due to javascript compatibility dependency hell, it&#8217;s quite difficult to have only one of them.<\/p>\n<p>For example. in simple test project (either using <a href=\"http:\/\/jamjs.org\">Jam<\/a> or <a href=\"http:\/\/bower.io\/\">Bower<\/a>) I&#8217;m failing to accomplish target.<\/p>\n<p><strong>Case 1: Jam<\/strong><br \/>\nJam insists on getting underscore, no clear easy way around it. Hmm&#8230; not good, jam is using its&#8217; own <strong>customized<\/strong> version of <a href=\"http:\/\/requirejs.org\">require.js<\/a>. Well, that ain&#8217;t really good, I don&#8217;t whole black box, I just want dependency management.<\/p>\n<p><strong>Case 2: Bower<\/strong><br \/>\nSame issue seemingly here. Actually I had here get slightly newer version of &#8221;backbone.layoutmanager&#8221;, which is seemingly breaking my deck. Notes for 0.8.x version of this library states that &#8221;Lo-Dash is no longer supported, use the lodash.underscore build instead.&#8221;. Okey, no problem, wait&#8230;, there ain&#8217;t &#8221;lodash.underscore&#8221; available via Bower. Oh, duh, hitting dead end.<\/p>\n<p>Thus even if lodash is supposedly &#8221;better&#8221; than underscore, mixing these two libraries concurrently can pose issues.<\/p>\n<p>Btw, situation ain&#8217;t helped by the fact that there is at least two different backbone versions in Bower:<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/documentcloud\/backbone\">backbone<\/a> (apparently backbone with underscore dependency)<\/li>\n<li><a href=\"https:\/\/github.com\/nibblebot\/backbone\">backbone-amd-lodash<\/a> (apparently backbone with AMD and lodash dependency)<\/li>\n<\/ol>\n<p>This really makes me to miss standard Java JDK libraries, which could be also easily extended without global dependency mess. I guess so this is called &#8221;progress&#8221; (aka. reinventing wheel in 10 year cycles).<\/p>\n<p>Enough of that, now back to editor to figure out how I can command Bower. At first impression, Bower feels better than Jam. Primarily because it doesn&#8217;t try to make &#8221;do it all&#8221; blackbox, but simply &#8221;fetch defined dependencies&#8221;. Which means that I&#8217;ve control over how actual require.js config is done. No fighting against the will of Jam.<\/p>\n<p><strong>References:<\/strong><br \/>\n<a href=\"http:\/\/wibblycode.wordpress.com\/2013\/01\/01\/the-state-of-javascript-package-management\/\">The State of Javascript Package Management<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Okey, Scenario is this: There is two competing libraries for &#8221;_&#8221; (aka. underscore) global variable. Libraries in question are &#8221;underscore&#8221; and &#8221;lodash&#8221;. Problem is that due to javascript compatibility dependency hell, it&#8217;s quite difficult to have only one of them. For example. in simple test project (either using Jam or Bower) I&#8217;m failing to accomplish&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,23],"tags":[],"class_list":["post-511","post","type-post","status-publish","format-standard","hentry","category-javascript","category-web"],"_links":{"self":[{"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=\/wp\/v2\/posts\/511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=511"}],"version-history":[{"count":0,"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=\/wp\/v2\/posts\/511\/revisions"}],"wp:attachment":[{"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kari.world.ikari.fi\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}