<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eduards Egle on Medium]]></title>
        <description><![CDATA[Stories by Eduards Egle on Medium]]></description>
        <link>https://medium.com/@eduardsegle?source=rss-28fa8875d46c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2uiOSXYvg8yWF6UjQr4ugg.jpeg</url>
            <title>Stories by Eduards Egle on Medium</title>
            <link>https://medium.com/@eduardsegle?source=rss-28fa8875d46c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 21:10:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eduardsegle/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Adding shared TypeScript types to a ‘create-react-app’ project in a monorepo]]></title>
            <link>https://medium.com/@eduardsegle/adding-shared-typescript-types-to-a-create-react-app-project-in-a-monorepo-9311daa45fdf?source=rss-28fa8875d46c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9311daa45fdf</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[monorepo]]></category>
            <category><![CDATA[typescript-with-react]]></category>
            <category><![CDATA[create-react-app]]></category>
            <dc:creator><![CDATA[Eduards Egle]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 18:25:37 GMT</pubDate>
            <atom:updated>2020-09-14T18:27:08.390Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*IvtN8DAGb11oh9jEKmqI-A.png" /></figure><h3>TL;DR</h3><p>Use <a href="https://github.com/oklas/react-app-rewire-alias">oklas/react-app-rewire-alias</a>, it works.</p><h3>Setup</h3><p>Let’s say you have a monorepo that includes a <a href="https://create-react-app.dev/docs/getting-started">CRA (create-react-app)</a> project, Node.js API service as well as a shared Typescript types package next to it:</p><pre>./app<br>   ./types<br>   ./react-ui<br>   ./api</pre><p>You want to share types between react-ui and api. CRA can make this difficult. At the time of writing, CRA doesn&#39;t support tsconfig.json paths property and thus far none of the <em>hacks </em>found around the web work without some kind of CRA config customization. In fact, if you try to add paths, CRA will remove it on service start.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FURvcjuZA9mA3hV1OpN%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FURvcjuZA9mA3hV1OpN%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FURvcjuZA9mA3hV1OpN%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="235" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e8da7fd73d9490568abeec3de9df42b/href">https://medium.com/media/9e8da7fd73d9490568abeec3de9df42b/href</a></iframe><h3>Solution</h3><p>We’re gonna need some packages to make this work:</p><ul><li>timarney/<a href="https://github.com/timarney/react-app-rewired">react-app-rewired</a></li></ul><blockquote><em>Allows one to</em> “Tweak the create-react-app webpack config(s) without using ‘eject’ and without creating a fork of the react-scripts”.</blockquote><ul><li><a href="https://github.com/oklas/react-app-rewire-alias">oklas/react-app-rewire-alias</a></li></ul><blockquote>Alias and multi-source solution for CRA</blockquote><pre><strong>yarn add -D react-app-rewired react-app-rewire-alias</strong><br>or<br><strong>npm install -save-dev react-app-rewired react-app-rewire-alias</strong></pre><p>Usually, we would put our paths aliases in tsconfig.json . CRA won&#39;t allow this as we saw before. We&#39;re gonna create two more files:</p><pre>./app<br>  ./types<br>  ./react-ui<br>    ...<br><strong>    ./config-overrides.js <br></strong>    ./<strong>tsconfig.paths.json</strong><br>./api</pre><p>First, <em>tsconfig.paths.json, </em>where<em> </em>path aliases<em> </em>are<em> </em>located<em>:</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a6208e188adbd0cdf6dcedf19f3f19e/href">https://medium.com/media/0a6208e188adbd0cdf6dcedf19f3f19e/href</a></iframe><p>By itself, this will not do everything, we&#39;ll use <em>tsconfig.json</em>&#39;s <a href="https://www.typescriptlang.org/tsconfig#extends">extends</a> property to reference it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9afb634b91462c3c8a2b3ad8b7745205/href">https://medium.com/media/9afb634b91462c3c8a2b3ad8b7745205/href</a></iframe><p>And second, <em>config-overrides.js, </em>where our CRA override logic resides:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/49b6a94d507b4a1373929562f28eaf70/href">https://medium.com/media/49b6a94d507b4a1373929562f28eaf70/href</a></iframe><p>We also need to update our <em>package.json </em>scripts section for our overrides to take effect:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/278efdfc1e29ed07466e367af4abd560/href">https://medium.com/media/278efdfc1e29ed07466e367af4abd560/href</a></iframe><p>And that&#39;s it. If VSCode doesn&#39;t register your path, try reloading the project or window. If you know a better way to achieve this, please let me know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9311daa45fdf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>