<?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: liajoy</title>
    <description>The latest articles on DEV Community by liajoy (@liajoy).</description>
    <link>https://dev.to/liajoy</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%2F161738%2Facbf3276-6b7f-4540-8273-f975ab2f7e28.jpeg</url>
      <title>DEV Community: liajoy</title>
      <link>https://dev.to/liajoy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/liajoy"/>
    <language>en</language>
    <item>
      <title>How to extract features from a library</title>
      <dc:creator>liajoy</dc:creator>
      <pubDate>Mon, 29 Apr 2019 02:29:34 +0000</pubDate>
      <link>https://dev.to/liajoy/extract-file-from-a-fat-library-4kgp</link>
      <guid>https://dev.to/liajoy/extract-file-from-a-fat-library-4kgp</guid>
      <description>

&lt;p&gt;I've tried to extract features from open source library for a long time, i.e. &lt;code&gt;PIXI.Transform&lt;/code&gt; from pixi.js or component of component library. In most cases, it's not difficult thing because most of these files haven't a complicated dependence tree. But I have some trouble when extract &lt;code&gt;THREE.TextGeometry&lt;/code&gt; from three.js recently. You know, three.js is a fat library.&lt;br&gt;
In fact, it's a simple work. There are some of implementations in open source community already, but I didn't find one of them can do these things directly. So I have to write a tool, it has features as follow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find dependencies of file.&lt;/li&gt;
&lt;li&gt;Copy these dependencies as output according to the original directory structure.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Find dependencies
&lt;/h2&gt;

&lt;p&gt;There are a number of libraries that can detect dependencies of file, but most of them return relative path to the dependency. For further work, an absolute path should be a better choice. So I resolve the relative path to an absolute path.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Copy dependencies
&lt;/h2&gt;

&lt;p&gt;When we got absolute paths of all the dependent files, the rest work is so simple. Just need to copy all of them to the output directory. But there are something we need to pay attention to, for ensuring the directory structure is correct after copied, we should get the topmost level directory of these dependent files, base on that directory, we can build down the whole structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;After these steps, a negligible tool comes. It saved me from extracting 30+ dependencies of &lt;code&gt;THREE.TextGeometry&lt;/code&gt;. I can't image how much time will be taken without this tool. In daily work, it can helps a lot when migrate some file with dependence to another place.&lt;/p&gt;

&lt;p&gt;If you are interested in it, you can find more information about it in &lt;a href="https://github.com/liajoy/hiway"&gt;hiway&lt;/a&gt;.&lt;/p&gt;


</description>
      <category>javascript</category>
      <category>node</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
