<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>js Archives - Yumasoft</title>
	<atom:link href="https://blog.yumasoft.pl/tag/js/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.yumasoft.pl/tag/js/</link>
	<description>Software development blog</description>
	<lastBuildDate>Mon, 28 Jun 2021 04:41:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.yumasoft.pl/wp-content/uploads/2021/05/cropped-yumasoft_icon_transparent-32x32.png</url>
	<title>js Archives - Yumasoft</title>
	<link>https://blog.yumasoft.pl/tag/js/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Migrating JavaScript React App to TypeScript</title>
		<link>https://blog.yumasoft.pl/2021/06/migrating-javascript-react-app-to-typescript/</link>
					<comments>https://blog.yumasoft.pl/2021/06/migrating-javascript-react-app-to-typescript/#respond</comments>
		
		<dc:creator><![CDATA[Dawid Sibiński]]></dc:creator>
		<pubDate>Mon, 28 Jun 2021 07:15:00 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript to typescript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[react]]></category>
		<category><![CDATA[reactjs]]></category>
		<category><![CDATA[ts]]></category>
		<category><![CDATA[typescript]]></category>
		<guid isPermaLink="false">https://blog.yumasoft.pl/?p=342</guid>

					<description><![CDATA[<p>In one of our biggest projects, we develop and maintain a React web application. Last year, we decided to migrate it to TypeScript. How did it go? How did we migrate JavaScript to TypeScript? Was it worth it? What struggles we met and are we still having any issues? I&#8217;ll try to address these questions&#8230;</p>
<p>The post <a rel="nofollow" href="https://blog.yumasoft.pl/2021/06/migrating-javascript-react-app-to-typescript/">Migrating JavaScript React App to TypeScript</a> appeared first on <a rel="nofollow" href="https://blog.yumasoft.pl">Yumasoft</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In one of our biggest projects, we develop and maintain a React web application. Last year, we decided to migrate it to TypeScript. How did it go? How did we migrate JavaScript to TypeScript? Was it worth it? What struggles we met and are we still having any issues? I&#8217;ll try to address these questions in this article.</p>



<p><em>Disclaimer: I&#8217;m not describing the migration process step-by-step or TypeScript itself in this article. You can find many resources on that online, including <a href="https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html">official TS docs</a>.</em></p>



<span id="more-342"></span>



<h2 class="wp-block-heading">JavaScript to TypeScript migration strategy</h2>



<p>If you search online, you will find many possible strategies of migrating JavaScript to TypeScript. We considered two of them:</p>



<ul class="wp-block-list"><li>converting the whole JavaScript codebase to TypeScript at once</li><li>starting to use TypeScript compiler and migrate step-by-step.</li></ul>



<p>After a short discussion, we decided to go with the <strong>step-by-step migration strategy</strong>. Why? First, it&#8217;s less time-consuming. Today, we know that it would kill us if we decided to convert all our JS codebase to TS at once. It would also freeze our codebase for a while &#8211; until every <code>.JS(X)</code> file is renamed to <code>.TS(X)</code> and all compile errors are fixed.</p>



<p>Thanks to the fact that TypeScript is a superset of JavaScript, <code>.JS(X)</code> and <code>.TS(X)</code> files can co-exist even if you switch to use TypeScript compiler. That&#8217;s because <strong>every JavaScript is also a valid TypeScript code</strong> and TS compiler can handle it.</p>



<p>That&#8217;s very comfortable. Just think about that &#8211; <strong>you can switch your project to TypeScript without actually having to change any code</strong>. We decided to immediately re-write a few of our recently-added functionalities to TypeScript and convert the rest gradually.</p>



<h2 class="wp-block-heading">What TypeScript gave us</h2>



<p>Before I tell you about the struggles, I want to really <strong>encourage you to migrate JavaScript to TypeScript</strong>. After 1 year since we switched to TypeScript, I&#8217;m telling you <strong>it&#8217;s the best thing you can do to your web app</strong> ?</p>



<p>Let&#8217;s see what you&#8217;ll gain if you decide to migrate JavaScript to TypeScript.</p>



<h3 class="wp-block-heading">Types in new code</h3>



<p>As soon as you switch your compiler to <em>ts-loader</em>, you can start creating files with TypeScript extensions (<code>.TS</code>, <code>.TSX</code>). It means that all your new code can now leverage types:</p>



<script src="https://gist.github.com/dsibinski/3e82afea66834d58d9c146213978af83.js"></script>



<p>Enjoy ?</p>



<h3 class="wp-block-heading">Typing information for existing libraries</h3>



<p>Have you been wondering what about the external libraries you are already using? How to get types for them? I was thinking exactly about this before migration.</p>



<p>It turns out that after you migrate JavaScript to TypeScript, most of the <code>npm</code> packages you use already have built-in typing information. You can check it on your package&#8217;s <code>npm</code> page:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="804" height="158" src="https://blog.yumasoft.pl/wp-content/uploads/2021/06/npm_typescript_icon.png" alt="" class="wp-image-350" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/06/npm_typescript_icon.png 804w, https://blog.yumasoft.pl/wp-content/uploads/2021/06/npm_typescript_icon-300x59.png 300w, https://blog.yumasoft.pl/wp-content/uploads/2021/06/npm_typescript_icon-768x151.png 768w" sizes="(max-width: 804px) 100vw, 804px" /></figure></div>



<p>If it doesn&#8217;t, you can try installing <code>npm</code> package called &#8220;@types/your_library_name&#8221;, e.g. <code>npm i @types/backbone</code>.</p>



<p>As a last resort, you can <a href="https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html">create the declaration files yourself</a>.</p>



<h3 class="wp-block-heading">JavaScript-TypeScript coexistence</h3>



<p>A huge benefit of TypeScript is that JavaScript code can co-exist with it. If you are like we were a year ago, with a lot of legacy JavaScript code and are afraid of switching to TS &#8211; don&#8217;t be. TypeScript makes it very easy to maintain your JS codebase or even mix it altogether.</p>



<p>There are no issues in using JavaScript code in TypeScript and otherwise. You can even <a href="https://blog.yumasoft.pl/2021/06/how-to-use-javascript-component-in-react-component/">use JS components in TypeScript</a>. We used to have a <code>services.js</code> file where we kept &#8220;services&#8221; exported as follows:</p>



<script src="https://gist.github.com/dsibinski/91250a9da08780129b7dd4e7b056f62c.js"></script>



<p>After migrating it to TypeScript (meaning renaming to <code>services.ts</code>) it turns out that these two definitions can co-exist, even in the same file:</p>



<script src="https://gist.github.com/dsibinski/13b1ba20c4c7fb03171550cbd1b04f0c.js"></script>



<p>As you can see, we added typing information to the legacy <code>StockService</code> as well. That&#8217;s because we have <code>noImplicitAny</code> enabled in our <a href="https://www.typescriptlang.org/tsconfig/#noImplicitAny">TypeScript configuration</a>. It doesn&#8217;t allow leaving any variables which are of <code>any</code> type. In any case, if you don&#8217;t know what type to use for a given variable/function, you can always type it explicitly as <code>any</code>, while moving the new code to fully-typed equivalents. That&#8217;s the power of TypeScript ?</p>



<h3 class="wp-block-heading">Compile errors</h3>



<p>I should have started with that! It might be obvious, but not for people who only worked with JavaScript on the frontend before ? Sure, you could get suggestions and warnings with <a href="https://eslint.org/">ESLint</a>, but that&#8217;s not the same as really enforced types checking on compilation level:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" width="804" height="141" src="https://blog.yumasoft.pl/wp-content/uploads/2021/06/TypeScript_webpack_compilation_error.png" alt="" class="wp-image-358" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/06/TypeScript_webpack_compilation_error.png 804w, https://blog.yumasoft.pl/wp-content/uploads/2021/06/TypeScript_webpack_compilation_error-300x53.png 300w, https://blog.yumasoft.pl/wp-content/uploads/2021/06/TypeScript_webpack_compilation_error-768x135.png 768w" sizes="(max-width: 804px) 100vw, 804px" /></figure></div>



<h3 class="wp-block-heading">Many TS compiler options</h3>



<p>TypeScript compiler has many useful <a href="https://www.typescriptlang.org/tsconfig#noImplicitAny">configuration options</a>. If you want to support JavaScript alongside TypeScript, you should enable <code>allowJs</code>. We have already mentioned the <code>noImplicitAny</code> setting that forces you to always explicitly specify types in your code. There&#8217;s much more stuff helpful in various scenarios of JS-TS migration. We were having some issues with imports from modules without default exports &#8211; enabling <code>allowSyntheticDefaultImports</code> saved us there.</p>



<p>What I&#8217;d like to emphasize here is that TypeScript compiler is really helpful ? It allows you to set your &#8220;typing&#8221; level by enforcing less or more rules. Thanks to that, you can slowly move towards more strict type checking rules like <code>noImplicitAny</code>. You&#8217;re not forced to do that from the beginning.</p>



<h3 class="wp-block-heading">Better coding experience</h3>



<p>This is definitely the best thing about TypeScript. It just feels more right to use it than coding in plain JavaScript. I see no reason to start a new project with vanilla JS today. I&#8217;d say even more &#8211; I see no reason to not migrate your JavaScript app to TypeScript. The sooner, the better!</p>



<p>You can catch your errors earlier. No need to debug the code to see if the property you used actually exists on an object. Your IDE gives you code completion suggestions. It&#8217;s a pure pleasure ?</p>



<h2 class="wp-block-heading">Migration challenges</h2>



<p>Of course, we met some challenges during migration. I don&#8217;t call them issues, because they are all manageable. Many people have already done those things, so you can find solutions to almost any issue online. Let&#8217;s see what we had to overcome.</p>



<h3 class="wp-block-heading">webpack configuration</h3>



<p>If there&#8217;s something I don&#8217;t like about web development, it&#8217;s definitely <a href="https://webpack.js.org/">webpack.</a>.. This is a typical &#8220;fighting with machines&#8221; case. Poor documentation, lack of well-described solutions online and some specificity in every project.</p>



<p>We had problems with <code>babel-loader</code> which we used to transpile JavaScript files before switching to TypeScript. Initially, afraid of introducing a regression, we wanted to keep <code>babel-loader</code> for legacy JS files. We couldn&#8217;t make it work, so we decided to switch completely to <code>ts-loader</code> for all files (including JavaScript ones).</p>



<p>Next issue was a lack of proper source maps and problems in debug mode. The breakpoints were often not hit. After a bit of searching and trial-error sessions, we found a solution. It was necessary to modify <code>webpack.config.js</code> and set <code>devtool</code> webpack setting to <code>eval-source-map</code>. We also had to use <a href="https://www.npmjs.com/package/source-map-loader">source-map-loader</a> for JavaScript files. Finally, this webpack configuration solved the debugging problems:</p>



<script src="https://gist.github.com/dsibinski/2cb3c4c10fe63a9020508c20fa31eef3.js"></script>



<p>You need to be really patient with webpack&#8230; But if you have already worked with it, I guess you know that very well ?</p>



<h3 class="wp-block-heading">Adding types to legacy JS code</h3>



<p>Adding types information with <code>noImplicitAny</code> set to <code>true</code> is sometimes challenging. Especially if you have some bigger JS files with no typing information at all. Sometimes you need to search for function&#8217;s calls to find out of what types are its parameters. In other cases, you might need to run your app and see that at runtime ? </p>



<p>Fortunately, as we already said, TypeScript doesn&#8217;t force you doing that. You can play with <a href="https://www.typescriptlang.org/tsconfig#noImplicitAny">tsconfig</a> or use <a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-6.html#suppress-errors-in-ts-files-using--ts-ignore-comments">@ts-ignore</a> as a last resort. </p>



<h3 class="wp-block-heading">Handling libraries without types</h3>



<p>Some of the libraries we used don&#8217;t provide any typing information. It makes working with them a bit difficult, especially if your TS compiler is already configured in a bit stricter mode. In such case, you might get an error similar to the following one:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" width="1024" height="184" src="https://blog.yumasoft.pl/wp-content/uploads/2021/06/formio_missing_types-1024x184.png" alt="" class="wp-image-365" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/06/formio_missing_types-1024x184.png 1024w, https://blog.yumasoft.pl/wp-content/uploads/2021/06/formio_missing_types-300x54.png 300w, https://blog.yumasoft.pl/wp-content/uploads/2021/06/formio_missing_types-768x138.png 768w, https://blog.yumasoft.pl/wp-content/uploads/2021/06/formio_missing_types.png 1062w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<p>Your options here are to either write the declaration files yourself, or import the library differently. You can, for instance, <code>require</code> it:</p>



<pre class="wp-block-code"><code>const FormIO = require('react-formio');</code></pre>



<p>and then use this <code>FormIO</code> variable which is typed as <code>any</code>. Again &#8211; that works because of TypeScript&#8217;s flexibility, but might not be very comfortable to live with.</p>



<h2 class="wp-block-heading">Migrate JavaScript to TypeScript &#8211; should I do it?</h2>



<p>Of course! There&#8217;s only one right answer. Don&#8217;t wait too long &#8211; start being more productive with TypeScript as soon as you can ? Believe me &#8211; you will not regret it.</p>
<p>The post <a rel="nofollow" href="https://blog.yumasoft.pl/2021/06/migrating-javascript-react-app-to-typescript/">Migrating JavaScript React App to TypeScript</a> appeared first on <a rel="nofollow" href="https://blog.yumasoft.pl">Yumasoft</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.yumasoft.pl/2021/06/migrating-javascript-react-app-to-typescript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How To Replace npm Library With Your Own Implementation?</title>
		<link>https://blog.yumasoft.pl/2021/05/how-to-replace-npm-library-with-your-own-implementation/</link>
					<comments>https://blog.yumasoft.pl/2021/05/how-to-replace-npm-library-with-your-own-implementation/#respond</comments>
		
		<dc:creator><![CDATA[Dawid Sibiński]]></dc:creator>
		<pubDate>Wed, 05 May 2021 12:51:00 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[npm]]></category>
		<guid isPermaLink="false">http://blog.yumasoft.pl/?p=20</guid>

					<description><![CDATA[<p>In one of our projects at Yumasoft we needed to replace npm library&#8217;s implementation with a custom one. This was needed because one of the components we use created their own version (fork) of this npm package (the component uses this library internally). In order to make the component working correctly, we had to use&#8230;</p>
<p>The post <a rel="nofollow" href="https://blog.yumasoft.pl/2021/05/how-to-replace-npm-library-with-your-own-implementation/">How To Replace npm Library With Your Own Implementation?</a> appeared first on <a rel="nofollow" href="https://blog.yumasoft.pl">Yumasoft</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-black-color has-text-color">In one of our projects at Yumasoft we needed to replace npm library&#8217;s implementation with a custom one. This was needed because one of the components we use created their own version (fork) of this npm package (the component uses this library internally). In order to make the component working correctly, we had to use the component&#8217;s authors version of the library, instead of using the original npm package. It turned out to not be an easy task, but finally we found a nice and easy solution.</p>



<span id="more-20"></span>



<h2 class="wp-block-heading">The problem</h2>



<p>Let&#8217;s say that we install&nbsp;<em>@ckeditor/ckeditor5-build-classic</em>&nbsp;npm package to our web app. This is a kind of package that has many forks. Some companies or individuals fork&nbsp;<a href="https://github.com/ckeditor/ckeditor5-build-classic" target="_blank" rel="noreferrer noopener">ckeditor5-build-classic repository</a>&nbsp;and create their own versions of it, adjusted for use with their products.</p>



<p>The problem is that if you use such a product that has their own fork of&nbsp;<em>@ckeditor/ckeditor5-build-classic</em>, you might want to use this fork as npm package, not the&nbsp;<a href="https://www.npmjs.com/package/@ckeditor/ckeditor5-build-classic" target="_blank" rel="noreferrer noopener">original npm library</a>. However, in most cases there&#8217;s no npm package published for the forked repository.</p>



<p>We need a way to replace the contents (source code) of the original npm library with contents (source code) from the forked library (custom version). Let&#8217;s see how to replace npm library with our own code.</p>



<h2 class="wp-block-heading">The solution</h2>



<p>The first idea that comes to mind could be to create a modified&nbsp;<a href="https://docs.npmjs.com/creating-and-publishing-private-packages" target="_blank" rel="noreferrer noopener">private npm package</a>&nbsp;and use it in our project. However, it requires some maintenance and forking the original library. We found a better solution.</p>



<p>If we go to&nbsp;<em>node_modules</em>&nbsp;folder looking&nbsp;<em>@ckeditor/ckeditor5-build-classic</em>&nbsp;package&#8217;s source, we can see that its source files (bundles) are present in&nbsp;<em>node_modules\@ckeditor\ckeditor5-build-classic\build\</em>&nbsp;folder:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="700" height="273" src="http://blog.yumasoft.pl/wp-content/uploads/2021/05/Ckeditor_node_modules_content.png" alt="" class="wp-image-21" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/05/Ckeditor_node_modules_content.png 700w, https://blog.yumasoft.pl/wp-content/uploads/2021/05/Ckeditor_node_modules_content-300x117.png 300w" sizes="auto, (max-width: 700px) 100vw, 700px" /></figure></div>



<p>If you check some forks of this library on GitHub, there are also bundles present there, e.g.&nbsp;<a href="https://github.com/formio/ckeditor5-build-classic/tree/master/build" target="_blank" rel="noreferrer noopener">here</a>&nbsp;or&nbsp;<a href="https://github.com/freeshineit/ckeditor5-build-classic/tree/master/dist" target="_blank" rel="noreferrer noopener">here</a>. Let&#8217;s say that we need to take the forked version of&nbsp;<em>ckeditor.js</em>&nbsp;file and replace this file in our original npm library. How do we do that?</p>



<h3 class="wp-block-heading">patch-package</h3>



<p>To achieve this, we need to install&nbsp;<a href="https://www.npmjs.com/package/patch-package" target="_blank" rel="noreferrer noopener">patch-package</a>&nbsp;npm package. This is an awesome, life-saving tool created just for what we need. Kudos to our teammate Przemek who recommended this gold tool to me ?</p>



<p>After installing the package with&nbsp;<strong>npm i patch-package</strong>, we can simply go to our npm library&#8217;s source and modify it. In our case, we replace&nbsp;<em>node_modules\@ckeditor\ckeditor5-build-classic\build\ckeditor.js</em>&nbsp;file contents with the contents of&nbsp;<em>ckeditor.js</em>&nbsp;file from our forked library (for example with&nbsp;<a href="https://github.com/formio/ckeditor5-build-classic/blob/master/build/ckeditor.js" target="_blank" rel="noreferrer noopener">this one</a>). After that, we save the file.</p>



<p>The last step is to generate a patch for our original npm library. We do it by executing the following command:&nbsp;<strong>npx patch-package @ckeditor/ckeditor5-build-classic</strong>&nbsp;(replace&nbsp;<strong>@ckeditor/ckeditor5-build-classic</strong>&nbsp;with your package name). This is how it looks:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="854" height="206" src="http://blog.yumasoft.pl/wp-content/uploads/2021/05/npx_patch-package_output.png" alt="" class="wp-image-22" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/05/npx_patch-package_output.png 854w, https://blog.yumasoft.pl/wp-content/uploads/2021/05/npx_patch-package_output-300x72.png 300w, https://blog.yumasoft.pl/wp-content/uploads/2021/05/npx_patch-package_output-768x185.png 768w" sizes="auto, (max-width: 854px) 100vw, 854px" /></figure></div>



<p>We can now see that a new folder called&nbsp;<em>patches</em>&nbsp;was created in our web app&#8217;s directory. In our case, it contains only a single patch file:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="859" height="136" src="http://blog.yumasoft.pl/wp-content/uploads/2021/05/patches_ckeditor_patch_file.png" alt="" class="wp-image-23" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/05/patches_ckeditor_patch_file.png 859w, https://blog.yumasoft.pl/wp-content/uploads/2021/05/patches_ckeditor_patch_file-300x47.png 300w, https://blog.yumasoft.pl/wp-content/uploads/2021/05/patches_ckeditor_patch_file-768x122.png 768w" sizes="auto, (max-width: 859px) 100vw, 859px" /></figure></div>



<p>What&#8217;s interesting, this file is basically a&nbsp;<em>git diff</em>&nbsp;between the original and modified&nbsp;<em>ckeditor.js</em>&nbsp;files:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="362" src="http://blog.yumasoft.pl/wp-content/uploads/2021/05/patch_file_contents_git_diff-1024x362.png" alt="" class="wp-image-24" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/05/patch_file_contents_git_diff-1024x362.png 1024w, https://blog.yumasoft.pl/wp-content/uploads/2021/05/patch_file_contents_git_diff-300x106.png 300w, https://blog.yumasoft.pl/wp-content/uploads/2021/05/patch_file_contents_git_diff-768x271.png 768w, https://blog.yumasoft.pl/wp-content/uploads/2021/05/patch_file_contents_git_diff.png 1237w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure></div>



<p>When we now execute&nbsp;<strong>npx patch-package</strong>&nbsp;command, the changes we&#8217;ve made before are applied to the actual npm library&#8217;s files:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="419" height="82" src="http://blog.yumasoft.pl/wp-content/uploads/2021/05/patch-package_applying_patches.png" alt="" class="wp-image-25" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/05/patch-package_applying_patches.png 419w, https://blog.yumasoft.pl/wp-content/uploads/2021/05/patch-package_applying_patches-300x59.png 300w" sizes="auto, (max-width: 419px) 100vw, 419px" /></figure></div>



<p>This is great, because we can now add this command&nbsp;<strong>patch-package</strong>&nbsp;to our build script, so our custom changes to the libraries are applied on every build. It&#8217;s very quick and works like a charm. That&#8217;s how we managed to easily replace npm library with our own implementation ?</p>



<p>We should check in the patch files to our GitHub repository, so our teammates have them locally and our build server can also apply the patches.</p>



<p>Since this moment, we modified the npm library&#8217;s code, so everyone who imports and uses this library in our app will be actually using our modified version of it.</p>



<p>If needed, we can easily revert the changes with&nbsp;<strong>npx patch-package &#8211;reverse</strong>. It restores the npm libraries to their original versions (thanks to the patch file stored as&nbsp;<em>git diff</em>).</p>



<h2 class="wp-block-heading">Summary</h2>



<p>I hope you found this article helpful. You can use the&nbsp;<em>patch-package</em>&nbsp;library not only to replace the npm library&#8217;s source files, but also as a quick-fix for bugs found in these libraries. No need to wait for the open-source community to fix the issue or the PR to be merged. You can make the patch quickly and at the same time report the issue on the concerned package&#8217;s GitHub. The tool even offers a feature to create a GH issue in the original repo with the diff containing your changes by using command&nbsp;<strong>npx patch-package package-name &#8211;create-issue</strong>.</p>



<p>For us at Yumasoft, the&nbsp;<a href="https://www.npmjs.com/package/patch-package" target="_blank" rel="noreferrer noopener">patch-package</a>&nbsp;is a life-saver. Maybe it also saves you some headache? ?</p>
<p>The post <a rel="nofollow" href="https://blog.yumasoft.pl/2021/05/how-to-replace-npm-library-with-your-own-implementation/">How To Replace npm Library With Your Own Implementation?</a> appeared first on <a rel="nofollow" href="https://blog.yumasoft.pl">Yumasoft</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.yumasoft.pl/2021/05/how-to-replace-npm-library-with-your-own-implementation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Resources to learn JavaScript</title>
		<link>https://blog.yumasoft.pl/2020/04/resources-to-learn-javascript/</link>
					<comments>https://blog.yumasoft.pl/2020/04/resources-to-learn-javascript/#comments</comments>
		
		<dc:creator><![CDATA[Grzesiek]]></dc:creator>
		<pubDate>Mon, 20 Apr 2020 07:46:00 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[front end]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[web development]]></category>
		<guid isPermaLink="false">https://blog.yumasoft.pl/?p=56</guid>

					<description><![CDATA[<p>When starting your journey with JavaScript, you should have knowledge about valuable information sources. In my opinion, having such lore can save you a lot of time and it can greatly accelerate your learning process. In this article I will try to present you some web pages with JavaScript resources, from widely renowned to slightly&#8230;</p>
<p>The post <a rel="nofollow" href="https://blog.yumasoft.pl/2020/04/resources-to-learn-javascript/">Resources to learn JavaScript</a> appeared first on <a rel="nofollow" href="https://blog.yumasoft.pl">Yumasoft</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When starting your journey with JavaScript, you should have knowledge about valuable information sources. In my opinion, having such lore can save you a lot of time and it can greatly accelerate your learning process. In this article I will try to present you some web pages with JavaScript resources, from widely renowned to slightly underrated ones. I hope that it will help you to increase your skill without pointless wandering through internet depths.</p>



<span id="more-56"></span>



<h3 class="wp-block-heading" id="mdnwebdocs">MDN web docs</h3>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://strapi.yumasoft.pl/uploads/d801a4e496064859bcbed3c9fed16aa9.jpg" alt="text"/><figcaption><em><strong>Photo credit: developer.mozilla.org</strong></em></figcaption></figure></div>



<p>The most recognized JavaScript resource is MDN web docs (MDN stands for Mozilla Developer Network) provided and maintained by Mozilla Corporation. While other programming languages usually have their official documentation, JS doesn’t have one (It actually depends od how do you treat ECMAScript, because it has official documetation). And the reason behind it is that a few teams worked on developing JS. But nevertheless, we have MDN web docs website, which is almost treated like official documentation for the JavaScript community. Information provided by maintainers is truly comprehensive. In my developer career, I have never experienced lack of crucial information on subjects of interest. What is more, this website provides sufficient tutorials for web development including JavaScript, HTML and CSS, divided into different levels of expertise.</p>



<p>Links:<br>MDN:&nbsp;<a href="https://developer.mozilla.org/pl/">https://developer.mozilla.org/pl/</a><br>Tutorials:&nbsp;<a href="https://developer.mozilla.org/pl/docs/Web/Tutorials">https://developer.mozilla.org/pl/docs/Web/Tutorials</a></p>



<h3 class="wp-block-heading" id="ecmascriptdocs">ECMAScript docs</h3>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://strapi.yumasoft.pl/uploads/2b29ac5fbb324758be8cf01525f124e7.png" alt="text"/><figcaption><strong><em>Photo credit: ecma-international.org</em></strong></figcaption></figure></div>



<p>ECMAScript was created to simply standardize JavaScript, because maintaining multiple independent implementations would be unbelievably hard without some sort of a standard. In ECMAScript docs you can find what JavaScript should look like and in almost every case it does. For example the latest official release of ECMAScript is named ES2020. Ecma international also provides information about future additions to the standard under the name ESNext. Technically the ECMAscript docs are the closest you can get to the official JavaScript docs. I personally wouldn’t recommend reading them for beginners, because complicated language and covered subjects might seem a little underwhelming.</p>



<p>Links:<br>Newest ECMAScript Docs:&nbsp;<a href="https://tc39.es/ecma262/#sec-fundamental-objects">https://tc39.es/ecma262/#sec-fundamental-objects</a></p>



<h3 class="wp-block-heading" id="javascriptinfo">Javascript.info</h3>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://strapi.yumasoft.pl/uploads/3802aea22e0047cf82cb88209785abe7.png" alt="text"/><figcaption><em><strong>Photo credit: javascript.info</strong></em></figcaption></figure></div>



<p>Javascript.info is a great and clearly made tutorial website. The tutorial itself covers JavaScript as a programming language and matter of working with a browser. The amount of information crucial to gain essential knowledge is perfect. I would say, if you want to maximize your learning speed, javascript.info is a right choice. In comparison to MDN docs, it is easier to get essentials and don’t get overloaded with information. Additionally, almost every topic has some bonus, usually it is some trick that is hard to invent on your own or explanation of unusual JavaScript behaviour. In my honest opinion, this site is the best way to start learning JavaScript &#8211; In my case it was a turning point.</p>



<p>Links:<br>Javascript.info:&nbsp;<a href="https://javascript.info/">https://javascript.info/</a></p>



<h3 class="wp-block-heading" id="codecademy">Codecademy</h3>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://strapi.yumasoft.pl/uploads/5df2756104cd4b22a8b87e1bb63c9884.png" alt="text"/><figcaption><em><strong>Photo credit: codecademy.com</strong></em></figcaption></figure></div>



<p>Codecademy is an interactive learning site. You can take courses on a large amount of languages, but we are interested in JavaScript. If you are starting from scratch it is a way to go. Easy and well explained tasks will softly inaugurate you. The biggest advantage of this site is that you don’t need any code environment, you just write your code inside a special container right on the website. At the beginning, you already have some code written and you just have to change something or insert some variable or value, which sets the entry threshold really low. The downside of codecademy is “PRO” content, if you want to have access to everything, you must upgrade your account to PRO status and the lowest-priced upgrade costs 19.99$ a month.</p>



<p>Links:<br>Codecademy:&nbsp;<a href="https://www.codecademy.com/">https://www.codecademy.com/</a></p>



<h3 class="wp-block-heading" id="udemy">Udemy</h3>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://strapi.yumasoft.pl/uploads/722779c8f6d640b78599d74b0a72bef2.png" alt="text"/><figcaption><em><strong>Photo credit: udemy.com</strong></em></figcaption></figure></div>



<p>Video based tutorials have gained huge popularity in recent years. This form of studying is known as the easiest and really effective, so the huge increase in popularity is understandable. Udemy is a great online learning platform with a wide range of courses. It doesn&#8217;t only have videos, online tests, zip packages with source code and community conversations are a huge part of Udemy success. There are some free courses, but the better ones are paid. The prices are really high, but you can encounter 90% discounts almost every two weeks.</p>



<p>Links:<br>Udemy:&nbsp;<a href="https://www.udemy.com/">https://www.udemy.com/</a></p>



<p>Some valuable udemy courses:<br><a href="https://yumasoft.pl/blogpost/[https://www.udemy.com/course/modern-javascript/">https://www.udemy.com/course/modern-javascript/</a><br><a href="https://www.udemy.com/course/modern-javascript-from-the-beginning/">https://www.udemy.com/course/modern-javascript-from-the-beginning/</a><br><a href="https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/">https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/</a><br><a href="https://www.udemy.com/course/javascript-beginners-complete-tutorial/">https://www.udemy.com/course/javascript-beginners-complete-tutorial/</a></p>



<h3 class="wp-block-heading" id="codewars">Codewars</h3>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://strapi.yumasoft.pl/uploads/b52c50ef101f4fd3afd05f995de1749b.png" alt="text"/><figcaption><em><strong>Photo credit: codewars.com</strong></em></figcaption></figure></div>



<p>Learning by doing is pretty good, but if you ask me, learning by doing and competing is just amazing! Codewars is an online learning site, where you can complete challenges, get points for it and compare your solution to others. The challenges are divided into different levels of expertise and your account has a level itself to give you proper tasks. You can get better by completing challenges, but the amount of knowledge gained through studying solutions made by more advanced people is huge. Some code pieces you will find there will change your way of thinking and present you unthinkable actions. You can’t miss codewars!</p>



<p>Links:<br>Codewars:&nbsp;<a href="https://www.codewars.com/">https://www.codewars.com/</a></p>



<h3 class="wp-block-heading" id="w3schools">W3Schools</h3>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://strapi.yumasoft.pl/uploads/5bda54f36b624b39aeec0dc07cb56deb.jpg" alt="text"/><figcaption><em><strong>Photo credit: w3schools.com</strong></em></figcaption></figure></div>



<p>W3Schools is an old-school tutorial page. You can start your web development path using this webpage, but you will run out of resources quickly. Topics are explained quite well for beginners, but explanations are simple and minimalistic. Lack of crucial topics are enough to say W3Schools is insufficient for more advanced people. Nevertheless, this webpage is worth checking.</p>



<p>Links:<br>W3Schools:&nbsp;<a href="https://www.w3schools.com/">https://www.w3schools.com/</a><br>JS tutorial:&nbsp;<a href="https://www.w3schools.com/js/default.asp">https://www.w3schools.com/js/default.asp</a></p>



<h3 class="wp-block-heading" id="youtubechannels">Youtube channels</h3>



<p>It is an unlimited source of knowledge. You can find a huge amount of tutorials, explanations and examples on youtube. Some youtubers even upload some of their content from Udemy, so it is good to pay attention to several channels. I personally really enjoy crash courses on youtube, you can choose some technology and get essentials in under two hours.</p>



<p>Good channels:</p>



<p>Fun Fun Function:&nbsp;<a href="https://www.youtube.com/channel/UCO1cgjhGzsSYb1rsB4bFe4Q">https://www.youtube.com/channel/UCO1cgjhGzsSYb1rsB4bFe4Q</a><br>Traversy Media:&nbsp;<a href="https://www.youtube.com/user/TechGuyWeb">https://www.youtube.com/user/TechGuyWeb</a><br>freeCdeCamp.org:&nbsp;<a href="https://www.youtube.com/channel/UC8butISFwT-Wl7EV0hUK0BQ">https://www.youtube.com/channel/UC8butISFwT-Wl7EV0hUK0BQ</a><br>Udemy Tech:&nbsp;<a href="https://yumasoft.pl/blogpost/[https://www.youtube.com/channel/UCU6e4MJtvlcX5DBLP1cq8hQ">https://www.youtube.com/channel/UCU6e4MJtvlcX5DBLP1cq8hQ</a><br>Academind:&nbsp;<a href="https://www.youtube.com/channel/UCSJbGtTlrDami-tDGPUV9-w">https://www.youtube.com/channel/UCSJbGtTlrDami-tDGPUV9-w</a><br>Dev Ed:&nbsp;<a href="https://www.youtube.com/channel/UClb90NQQcskPUGDIXsQEz5Q">https://www.youtube.com/channel/UClb90NQQcskPUGDIXsQEz5Q</a><br>The Net Ninja:&nbsp;<a href="https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg">https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg</a><br>Techsith:&nbsp;<a href="https://www.youtube.com/user/techSithTube">https://www.youtube.com/user/techSithTube</a></p>



<h3 class="wp-block-heading" id="summary">Summary</h3>



<p>There are a lot of javascript resources. They may vary within the quality, but all of them are worth trying. In my opinion, dividing your time into different resources gives the best results in the studying process, because you avoid monotony. I will try to pick the best choices in some categories and write them below.</p>



<p><strong>Most comprehensive docs and tutorials:</strong>&nbsp;MDN web docs / ECMAScript docs<br><strong>Most efficient tutorial:</strong>&nbsp;Javascript.info<br><strong>Best for beginners:</strong>&nbsp;Codecademy</p>
<p>The post <a rel="nofollow" href="https://blog.yumasoft.pl/2020/04/resources-to-learn-javascript/">Resources to learn JavaScript</a> appeared first on <a rel="nofollow" href="https://blog.yumasoft.pl">Yumasoft</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.yumasoft.pl/2020/04/resources-to-learn-javascript/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
