Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
artemave committed Jan 31, 2023
1 parent 9b095fe commit 42fd077
Show file tree
Hide file tree
Showing 25 changed files with 53 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ <h4 id="custom-loader" style="position:relative"><a href="#custom-loader" aria-l
<span class="token keyword">import</span> <span class="token punctuation">{</span> fileURLToPath <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&#x27;node:url&#x27;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> transformSync <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&#x27;@swc/core&#x27;</span>

<span class="token keyword">const</span> extensionsRegex <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\.m?ts</span><span class="token regex-delimiter">/</span></span>
<span class="token keyword">const</span> extensionsRegex <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\.m?ts$</span><span class="token regex-delimiter">/</span></span>

<span class="token keyword">export</span> <span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">load</span><span class="token punctuation">(</span><span class="token parameter">url<span class="token punctuation">,</span> context<span class="token punctuation">,</span> nextLoad</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span>extensionsRegex<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>url<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
Expand Down Expand Up @@ -260,7 +260,9 @@ <h3 id="type-checking" style="position:relative"><a href="#type-checking" aria-l
<span class="token punctuation">}</span></code></pre></div>
<p>It’s the last two settings - added in typescript 5 - that allow <code class="language-text">tsc</code> to understand imports with <code class="language-text">.ts</code>/<code class="language-text">.tsm</code>/<code class="language-text">.tsx</code> extensions.</p>
<h3 id="it-scales" style="position:relative"><a href="#it-scales" aria-label="it scales permalink" class="anchor before"><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>It scales</h3>
<p>I plugged this loader into a mid sized javascript project (30k loc) and it seemed to cope remarkably well. Time increase for a random unit test (the one that doesn’t import a lot of modules) stayed comfortably within 100ms. A god integration test (loads A LOT of the project) increased by about 200ms. Those are totally unscientific numbers, but it’s a promising start.</p></div></div></div><div style="background-color:#f5f6f4;padding-left:0;padding-right:0" class="Content__Container-sc-1g3f5s5-0 Content-sc-1g3f5s5-1 Content__ContentFull-sc-1g3f5s5-3 gVWHDU"><div class="Content__Container-sc-1g3f5s5-0 MarkdownContainer-sc-1s12zg4-0 bgoDDE"><div id="disqus_thread"></div></div></div><div style="background-color:#ebede8;padding-left:0;padding-right:0" class="Content__Container-sc-1g3f5s5-0 Content-sc-1g3f5s5-1 Content__ContentFull-sc-1g3f5s5-3 gVWHDU"><div class="Content__Container-sc-1g3f5s5-0 MarkdownContainer-sc-1s12zg4-0 bgoDDE"><div class="PrevNext__Wrapper-sc-fknkt2-0 dntuTT"><div class="PrevNext__Next-sc-fknkt2-2 mmpKp"><a style="display:flex;align-items:center;justify-content:center" duration="0.55" hex="#07141d" href="/blog/hosting-rails-apps-for-free-on-oracle-cloud-with-dokku/"><div><span class="PrevNext__Label-sc-fknkt2-3 jgXSkq">Next:</span>Hosting Rails apps for free on Oracle Cloud with Dokku</div><svg viewBox="0 0 24 24" size="64" style="margin-left:0.5rem" class="CircleIcon__Wrapper-sc-1igkh6j-0 fcEJLH"><circle cx="12" cy="12" r="11" fill="none" stroke="currentColor" stroke-width="0.75" class="CircleIcon__Circle-sc-1igkh6j-1 kkyNDe"></circle><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="0.55"><path d="M8.751 6l6.498 6.015L8.751 18"></path></g></svg></a></div></div></div></div></div><div class="layout__FooterBackground-sc-2sv4ue-0 kNTPos"><div class="Content__Container-sc-1g3f5s5-0 FooterContent__Footer-sc-14lp62o-0 hkWMSW"><div class="Content__Inner-sc-1g3f5s5-4 FooterContent__FooterInner-sc-14lp62o-1 hqzNIg"><div class="FooterContent__Copyright-sc-14lp62o-2 iOqZkn">©<!-- -->2023<!-- --> Featurist Ltd.</div><div class="FooterContent__SocialWrapper-sc-14lp62o-3 iNQBQW"><div class="FooterContent__List-sc-14lp62o-4 iProPY"><a href="https://github.com/featurist" target="_blank" alt="Github @featurist" class="FooterContent__ListItem-sc-14lp62o-5 emjNbC"><svg viewBox="0 0 24 24" size="42" class="CircleIcon__Wrapper-sc-1igkh6j-0 bLYTqr"><circle cx="12" cy="12" r="11" fill="none" stroke="currentColor" stroke-width="0.75" class="CircleIcon__Circle-sc-1igkh6j-1 kkyNDe"></circle><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="0.55"><path d="M12 3.883a8.02 8.02 0 0 0-2.535 15.628c.401.074.53-.174.53-.385v-1.493c-2.23.485-2.695-.947-2.695-.947-.365-.926-.891-1.173-.891-1.173-.727-.498.056-.487.056-.487.805.056 1.229.826 1.229.826.715 1.226 1.876.872 2.333.667.072-.518.28-.872.51-1.072-1.781-.204-3.654-.892-3.654-3.963 0-.877.314-1.592.826-2.153-.083-.202-.357-1.018.078-2.122 0 0 .674-.215 2.206.822A7.668 7.668 0 0 1 12 7.761a7.69 7.69 0 0 1 2.009.27c1.531-1.037 2.203-.822 2.203-.822.436 1.104.162 1.92.079 2.122.514.561.825 1.277.825 2.153 0 3.079-1.876 3.758-3.661 3.956.287.249.55.737.55 1.485v2.201c0 .213.128.463.535.384A8.02 8.02 0 0 0 12 3.883z"></path></g></svg></a><a href="https://twitter.com/featurists" target="_blank" alt="Twitter @featurists" class="FooterContent__ListItem-sc-14lp62o-5 emjNbC"><svg viewBox="0 0 24 24" size="42" class="CircleIcon__Wrapper-sc-1igkh6j-0 bLYTqr"><circle cx="12" cy="12" r="11" fill="none" stroke="currentColor" stroke-width="0.75" class="CircleIcon__Circle-sc-1igkh6j-1 kkyNDe"></circle><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="0.55"><path d="M18.505 7.965a5.29 5.29 0 0 1-1.533.42 2.67 2.67 0 0 0 1.174-1.477 5.352 5.352 0 0 1-1.695.648 2.672 2.672 0 0 0-4.549 2.434A7.578 7.578 0 0 1 6.4 7.202a2.674 2.674 0 0 0 .826 3.564 2.654 2.654 0 0 1-1.208-.334c-.03 1.236.857 2.393 2.141 2.651a2.68 2.68 0 0 1-1.206.045 2.671 2.671 0 0 0 2.494 1.854 5.367 5.367 0 0 1-3.952 1.106 7.556 7.556 0 0 0 4.091 1.199c4.957 0 7.757-4.186 7.587-7.94a5.418 5.418 0 0 0 1.332-1.382z"></path></g></svg></a></div></div></div></div></div></div><div id="gatsby-announcer" style="position:absolute;top:0;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0" aria-live="assertive" aria-atomic="true"></div></div><script>
<p>I plugged this loader into a mid sized javascript project (30k loc) and it seemed to cope remarkably well. Time increase for a random unit test (the one that doesn’t import a lot of modules) stayed comfortably within 100ms. A god integration test (loads A LOT of the project) increased by about 200ms. Those are totally unscientific numbers, but it’s a promising start.</p>
<hr/>
<p>Discuss this post on <a href="https://www.reddit.com/r/javascript/comments/10pujhj/node_swc_make_a_lightning_fast_typescript_runtime/" target="_blank" rel="nofollow">Reddit</a>.</p></div></div></div><div style="background-color:#f5f6f4;padding-left:0;padding-right:0" class="Content__Container-sc-1g3f5s5-0 Content-sc-1g3f5s5-1 Content__ContentFull-sc-1g3f5s5-3 gVWHDU"><div class="Content__Container-sc-1g3f5s5-0 MarkdownContainer-sc-1s12zg4-0 bgoDDE"><div id="disqus_thread"></div></div></div><div style="background-color:#ebede8;padding-left:0;padding-right:0" class="Content__Container-sc-1g3f5s5-0 Content-sc-1g3f5s5-1 Content__ContentFull-sc-1g3f5s5-3 gVWHDU"><div class="Content__Container-sc-1g3f5s5-0 MarkdownContainer-sc-1s12zg4-0 bgoDDE"><div class="PrevNext__Wrapper-sc-fknkt2-0 dntuTT"><div class="PrevNext__Next-sc-fknkt2-2 mmpKp"><a style="display:flex;align-items:center;justify-content:center" duration="0.55" hex="#07141d" href="/blog/hosting-rails-apps-for-free-on-oracle-cloud-with-dokku/"><div><span class="PrevNext__Label-sc-fknkt2-3 jgXSkq">Next:</span>Hosting Rails apps for free on Oracle Cloud with Dokku</div><svg viewBox="0 0 24 24" size="64" style="margin-left:0.5rem" class="CircleIcon__Wrapper-sc-1igkh6j-0 fcEJLH"><circle cx="12" cy="12" r="11" fill="none" stroke="currentColor" stroke-width="0.75" class="CircleIcon__Circle-sc-1igkh6j-1 kkyNDe"></circle><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="0.55"><path d="M8.751 6l6.498 6.015L8.751 18"></path></g></svg></a></div></div></div></div></div><div class="layout__FooterBackground-sc-2sv4ue-0 kNTPos"><div class="Content__Container-sc-1g3f5s5-0 FooterContent__Footer-sc-14lp62o-0 hkWMSW"><div class="Content__Inner-sc-1g3f5s5-4 FooterContent__FooterInner-sc-14lp62o-1 hqzNIg"><div class="FooterContent__Copyright-sc-14lp62o-2 iOqZkn">©<!-- -->2023<!-- --> Featurist Ltd.</div><div class="FooterContent__SocialWrapper-sc-14lp62o-3 iNQBQW"><div class="FooterContent__List-sc-14lp62o-4 iProPY"><a href="https://github.com/featurist" target="_blank" alt="Github @featurist" class="FooterContent__ListItem-sc-14lp62o-5 emjNbC"><svg viewBox="0 0 24 24" size="42" class="CircleIcon__Wrapper-sc-1igkh6j-0 bLYTqr"><circle cx="12" cy="12" r="11" fill="none" stroke="currentColor" stroke-width="0.75" class="CircleIcon__Circle-sc-1igkh6j-1 kkyNDe"></circle><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="0.55"><path d="M12 3.883a8.02 8.02 0 0 0-2.535 15.628c.401.074.53-.174.53-.385v-1.493c-2.23.485-2.695-.947-2.695-.947-.365-.926-.891-1.173-.891-1.173-.727-.498.056-.487.056-.487.805.056 1.229.826 1.229.826.715 1.226 1.876.872 2.333.667.072-.518.28-.872.51-1.072-1.781-.204-3.654-.892-3.654-3.963 0-.877.314-1.592.826-2.153-.083-.202-.357-1.018.078-2.122 0 0 .674-.215 2.206.822A7.668 7.668 0 0 1 12 7.761a7.69 7.69 0 0 1 2.009.27c1.531-1.037 2.203-.822 2.203-.822.436 1.104.162 1.92.079 2.122.514.561.825 1.277.825 2.153 0 3.079-1.876 3.758-3.661 3.956.287.249.55.737.55 1.485v2.201c0 .213.128.463.535.384A8.02 8.02 0 0 0 12 3.883z"></path></g></svg></a><a href="https://twitter.com/featurists" target="_blank" alt="Twitter @featurists" class="FooterContent__ListItem-sc-14lp62o-5 emjNbC"><svg viewBox="0 0 24 24" size="42" class="CircleIcon__Wrapper-sc-1igkh6j-0 bLYTqr"><circle cx="12" cy="12" r="11" fill="none" stroke="currentColor" stroke-width="0.75" class="CircleIcon__Circle-sc-1igkh6j-1 kkyNDe"></circle><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="0.55"><path d="M18.505 7.965a5.29 5.29 0 0 1-1.533.42 2.67 2.67 0 0 0 1.174-1.477 5.352 5.352 0 0 1-1.695.648 2.672 2.672 0 0 0-4.549 2.434A7.578 7.578 0 0 1 6.4 7.202a2.674 2.674 0 0 0 .826 3.564 2.654 2.654 0 0 1-1.208-.334c-.03 1.236.857 2.393 2.141 2.651a2.68 2.68 0 0 1-1.206.045 2.671 2.671 0 0 0 2.494 1.854 5.367 5.367 0 0 1-3.952 1.106 7.556 7.556 0 0 0 4.091 1.199c4.957 0 7.757-4.186 7.587-7.94a5.418 5.418 0 0 0 1.332-1.382z"></path></g></svg></a></div></div></div></div></div></div><div id="gatsby-announcer" style="position:absolute;top:0;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0" aria-live="assertive" aria-atomic="true"></div></div><script>

function gaOptout(){document.cookie=disableStr+'=true; expires=Thu, 31 Dec 2099 23:59:59 UTC;path=/',window[disableStr]=!0}var gaProperty='UA-34932868-1',disableStr='ga-disable-'+gaProperty;document.cookie.indexOf(disableStr+'=true')>-1&&(window[disableStr]=!0);
if(!(parseInt(navigator.doNotTrack) === 1 || parseInt(window.doNotTrack) === 1 || parseInt(navigator.msDoNotTrack) === 1 || navigator.doNotTrack === "yes")) {
Expand Down
Loading

0 comments on commit 42fd077

Please sign in to comment.