<?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: Jason</title>
    <description>The latest articles on DEV Community by Jason (@jg).</description>
    <link>https://dev.to/jg</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%2F78438%2Fc446051f-8de7-42f8-8cf6-a00f85928d6a.jpeg</url>
      <title>DEV Community: Jason</title>
      <link>https://dev.to/jg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jg"/>
    <language>en</language>
    <item>
      <title>Double Depping: Use import maps and deps.ts together</title>
      <dc:creator>Jason</dc:creator>
      <pubDate>Sat, 15 Oct 2022 14:18:16 +0000</pubDate>
      <link>https://dev.to/jg/double-depping-use-import-maps-and-depsts-together-39ae</link>
      <guid>https://dev.to/jg/double-depping-use-import-maps-and-depsts-together-39ae</guid>
      <description>&lt;h2&gt;
  
  
  Import Maps !== Deno Dependency Management
&lt;/h2&gt;

&lt;p&gt;Import maps serve as an &lt;strong&gt;import alias&lt;/strong&gt; and not necessarily as a manifest for&lt;br&gt;
dependencies.&lt;/p&gt;

&lt;p&gt;Import map keys are to add some sex-appeal: shortcuts, aliases, mirror/redirect URLs, client-side usage, scopes, file system paths, so on and etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"imports"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"@/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./where-its-at"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;deps.ts&lt;/code&gt;: Just a Typical Script
&lt;/h2&gt;

&lt;p&gt;The practice of using &lt;code&gt;deps.ts&lt;/code&gt; is for &lt;strong&gt;adding &lt;em&gt;logic&lt;/em&gt;&lt;/strong&gt;. This script's primary&lt;br&gt;
purpose is to &lt;strong&gt;export&lt;/strong&gt; your modules and types together from external&lt;br&gt;
dependencies and local libraries.&lt;/p&gt;

&lt;p&gt;It's a bit like putting &lt;code&gt;./node_modules&lt;/code&gt; and &lt;code&gt;module.exports&lt;/code&gt; together. Mix that&lt;br&gt;
with modern &lt;code&gt;export&lt;/code&gt; declarations, and –🎉– the real beauty and purpose of Deno becomes more apparent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Package and Lock
&lt;/h2&gt;

&lt;p&gt;Use these two files in tandem to manage dependency versions. Whether you want to set your version numbers in the &lt;code&gt;deps.ts&lt;/code&gt; or &lt;code&gt;import_maps.json&lt;/code&gt; file is up to you. It could even be irrelevant, depending upon the dependency usage. A single-use helper function, for example, does not need to be updated alongside its parent module.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is this Bad for Bundles?
&lt;/h3&gt;

&lt;p&gt;The article &lt;em&gt;&lt;a href="https://dev.to/wongjiahau/why-deps-ts-and-mod-ts-is-bad-in-deno-bjo"&gt;Why &lt;code&gt;deps.ts&lt;/code&gt; is Bad in Deno&lt;/a&gt;&lt;/em&gt; points out that the practice of using &lt;code&gt;deps.ts&lt;/code&gt; prevents tree-shaking; however, Deno's Bundler output is &lt;strong&gt;&lt;a href="https://deno.land/manual@v1.26.1/tools/bundler#bundling-for-the-web"&gt;intended for consumption in Deno&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  But it Slows Down Compilation
&lt;/h4&gt;

&lt;p&gt;bUt It sLoWs DoWn CoMpiL— Who cares? Its compilation time is negligible when your project is hosted by &lt;strong&gt;servers powerful enough for edge computing&lt;/strong&gt;, like Deno Deploy, Netlify and GitHub Actions. Your local development process can be sped up by utilizing Deno's built-in tools like &lt;code&gt;deno test&lt;/code&gt; and &lt;code&gt;deno info&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Independence
&lt;/h2&gt;

&lt;p&gt;This mix-and-match method of composing dependencies may seem haphazard, but Deno's compiler &lt;em&gt;does not mind&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;You do you. The best practice is whatever feels right for your project. Create your own convention with collaborators. Or don't, because it doesn't matter for a random, one-time sandbox repository without much code review.&lt;/p&gt;

&lt;p&gt;Or do, because you can be opinionated and unconventional. Your method could lead by example, or you can find many great examples to follow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OSS FTW!&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  TLDR
&lt;/h3&gt;

&lt;p&gt;Ryan Dahl explained this in the &lt;a href="https://www.youtube.com/watch?v=M3BM9TB-8yA"&gt;10 Things I Regret About Node.js presentation&lt;/a&gt;...probably. (I don't know. It was too long. I didn't watch it.)&lt;/p&gt;

</description>
      <category>deno</category>
      <category>typescript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
