|
23 | 23 | <meta property="og:site_name" content="Danni.cool - Daniel's Blog">
|
24 | 24 | <meta property="og:description" content="Installation size and time between package managers, and some thoughts in Github Actions">
|
25 | 25 | <meta property="og:locale" content="en_US">
|
26 |
| -<meta property="og:image" content="http://example.com/cdn.danni.cool/file/b3413585214fbe5e53f701d88cd8bdd3.jpg"> |
| 26 | +<meta property="og:image" content="https://cdn.danni.cool/file/b3413585214fbe5e53f701d88cd8bdd3.jpg"> |
27 | 27 | <meta property="article:published_time" content="2023-10-15T16:00:00.000Z">
|
28 | 28 | <meta property="article:modified_time" content="2024-05-06T14:50:00.000Z">
|
29 | 29 | <meta property="article:author" content="Daniel Chan">
|
30 | 30 | <meta property="article:tag" content="Yarn">
|
31 | 31 | <meta property="article:tag" content="Pnpm">
|
32 | 32 | <meta property="article:tag" content="Github Actions">
|
33 | 33 | <meta name="twitter:card" content="summary_large_image">
|
34 |
| -<meta name="twitter:image" content="http://example.com/cdn.danni.cool/file/b3413585214fbe5e53f701d88cd8bdd3.jpg"> |
| 34 | +<meta name="twitter:image" content="https://cdn.danni.cool/file/b3413585214fbe5e53f701d88cd8bdd3.jpg"> |
35 | 35 |
|
36 | 36 |
|
37 | 37 | <meta name="referrer" content="no-referrer-when-downgrade">
|
|
265 | 265 |
|
266 | 266 |
|
267 | 267 | <div id="banner" class="banner" parallax=true
|
268 |
| - style="background: url('/cdn.danni.cool/file/b3413585214fbe5e53f701d88cd8bdd3.jpg') no-repeat center center; background-size: cover;"> |
| 268 | + style="background: url('https://cdn.danni.cool/file/b3413585214fbe5e53f701d88cd8bdd3.jpg') no-repeat center center; background-size: cover;"> |
269 | 269 | <div class="full-bg-img">
|
270 | 270 | <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.5)">
|
271 | 271 | <div class="banner-text text-center fade-in-up">
|
@@ -374,10 +374,10 @@ <h1 id="A-Discussion-Of-Dockerfile"><a href="#A-Discussion-Of-Dockerfile" class=
|
374 | 374 | <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs bash">FROM node:18-alpine<br><br>WORKDIR /app<br><br>COPY package.json pnpm-lock.yaml ./<br><br>RUN npm install -g pnpm && pnpm install && pnpm store prune && npm uninstall pnpm -g<br></code></pre></td></tr></table></figure>
|
375 | 375 |
|
376 | 376 |
|
377 |
| -<h1 id="Pnpm-Improves-Nothing"><a href="#Pnpm-Improves-Nothing" class="headerlink" title="Pnpm Improves Nothing?"></a>Pnpm Improves Nothing?</h1><p><img src="/cdn.danni.cool/file/7b31bc2ab1890888ba0a53199fafe44b.png" srcset="/img/loading.gif" lazyload alt="Untitled.png"></p> |
| 377 | +<h1 id="Pnpm-Improves-Nothing"><a href="#Pnpm-Improves-Nothing" class="headerlink" title="Pnpm Improves Nothing?"></a>Pnpm Improves Nothing?</h1><p><img src="https://cdn.danni.cool/file/7b31bc2ab1890888ba0a53199fafe44b.png" srcset="/img/loading.gif" lazyload alt="Untitled.png"></p> |
378 | 378 | <p>We know, pnpm <strong>uses symbol links point to a global space to resolve the node_modules in every project</strong>, <strong>so that each project installs modules only once in specific version, that’s one of the advantages why pnpm takes little space and install node_modules so quick.</strong></p>
|
379 | 379 | <p>With the high expectation of pnpm’s magic, I found the docker build speed is almost unchanged in Github Actions. 🤨</p>
|
380 |
| -<p><img src="/cdn.danni.cool/file/21ce41b0678696e994551a72f63a4409.jpg" srcset="/img/loading.gif" lazyload alt="Jietu20231206-154642.jpg"></p> |
| 380 | +<p><img src="https://cdn.danni.cool/file/21ce41b0678696e994551a72f63a4409.jpg" srcset="/img/loading.gif" lazyload alt="Jietu20231206-154642.jpg"></p> |
381 | 381 | <p>Why was that? In Github Runner, each building task owns a new environment. it means whether to choose npm , yarn or pnpm , they all need to reinstall again. </p>
|
382 | 382 | <h1 id="Github-Actions-Cache"><a href="#Github-Actions-Cache" class="headerlink" title="Github Actions Cache"></a>Github Actions Cache</h1><p>If you install node_modules in Github Actions workflow, there comes a way to cache dependencies and build outputs 👉 <a target="_blank" rel="noopener" href="https://github.com/actions/cache">https://github.com/actions/cache</a>.</p>
|
383 | 383 | <p>What my workflow does is to build dockerfile, upload to dockerHub, and then push a release PR. The <code>npm install</code> step is only running in docker building progress. So this cache method is helpless.</p>
|
@@ -430,7 +430,7 @@ <h3 id="No-cache-and-no-lock-file"><a href="#No-cache-and-no-lock-file" class="h
|
430 | 430 | <h3 id="No-cache-but-with-lock-file"><a href="#No-cache-but-with-lock-file" class="headerlink" title="No cache but with lock file"></a>No cache but with lock file</h3><p>like the most common build scene, the installation time is roughly similar, but the size is still minimal via yarn installed, pnpm is at the bottom</p>
|
431 | 431 | <h3 id="Clear-cache-and-remove-package-manage"><a href="#Clear-cache-and-remove-package-manage" class="headerlink" title="Clear cache and remove package manage"></a>Clear cache and remove package manage</h3><p><strong>yarn</strong> is ahead over others in installation size, however, the node_modules that installed via pnpm comes an error when I try to launch my project. but I found it was my fault after I carefully debug the reason. </p>
|
432 | 432 | <p>I was tried to import the module called “<strong>file-box”</strong> which is not declared in the package.json**.** Actually, it’s a dependency of <a target="_blank" rel="noopener" href="https://github.com/wechaty/wechaty"><strong>Wechaty</strong></a>. </p>
|
433 |
| -<p><img src="/cdn.danni.cool/file/18a602bd544140a79ea214530bb70ce9.png" srcset="/img/loading.gif" lazyload alt="Untitled.png"></p> |
| 433 | +<p><img src="https://cdn.danni.cool/file/18a602bd544140a79ea214530bb70ce9.png" srcset="/img/loading.gif" lazyload alt="Untitled.png"></p> |
434 | 434 | <p><strong>Pnpm helped me find an potential issues, it called “</strong><a target="_blank" rel="noopener" href="https://broadcrunch.com/technology/computing/phantom-dependencies-in-nodejs-and-how-pnpm-prevents-them/"><strong>phantom dependencies</strong></a><strong>”.</strong></p>
|
435 | 435 | <p>Phantom dependencies is dangerous because it will cause error or crash if “Wechaty” don’t depends “file-box” anymore. Although it runs well in local dev.</p>
|
436 | 436 | <h1 id="Final-Thoughts"><a href="#Final-Thoughts" class="headerlink" title="Final Thoughts"></a><strong>Final Thoughts</strong></h1><ol>
|
|
0 commit comments