<?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 techiekarthick on Medium]]></title>
        <description><![CDATA[Stories by techiekarthick on Medium]]></description>
        <link>https://medium.com/@techiekarthick?source=rss-62db95a16d35------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FQOzsjjTnU1lxnpcLOxJnw.jpeg</url>
            <title>Stories by techiekarthick on Medium</title>
            <link>https://medium.com/@techiekarthick?source=rss-62db95a16d35------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:44:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@techiekarthick/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[Vi⚙️ Migrating from Webpack to Vite: A Practical Guide from Pain to Performance]]></title>
            <link>https://techiekarthick.medium.com/vi-%EF%B8%8F-migrating-from-webpack-to-vite-a-practical-guide-from-pain-to-performance-e08b0323ea68?source=rss-62db95a16d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/e08b0323ea68</guid>
            <category><![CDATA[vitest]]></category>
            <category><![CDATA[vitejs]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[webpack-5]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[techiekarthick]]></dc:creator>
            <pubDate>Thu, 17 Apr 2025 12:02:37 GMT</pubDate>
            <atom:updated>2025-04-17T12:02:37.651Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>By </em><a href="https://github.com/techiekarthick"><em>techiekarthick</em></a><em> | April 2025</em></blockquote><figure><img alt="Vite" src="https://cdn-images-1.medium.com/max/1024/1*sXDWme1U0YDZz0cgYI5HZw.jpeg" /></figure><h3>🚀 TL;DR</h3><ul><li>✅ <strong>Vite</strong> offers blazing-fast dev startup, out-of-the-box ES module support, and native support for modern JS features.</li><li>⚠️ Migration from <strong>Webpack</strong> can be painful — especially if you’re using legacy Node APIs or bundling non-ESM libraries.</li><li>✅ I share how I solved real-world issues like crypto.subtle support, polyfilling Buffer, fixing lodash issues in Vitest, and optimizing complex build setups.</li></ul><h3>🧠 Background: Why We Migrated</h3><p>We had a monorepo project using:</p><ul><li>Webpack 5</li><li>Crypto APIs</li><li>Lodash, Moment.js, and other legacy-friendly libraries</li><li>Complex React component system</li><li>Vitest for tests</li></ul><p>Webpack was stable — but <strong>slow</strong>. Dev builds took 15–30 seconds to boot, HMR wasn’t consistent, and tree-shaking was hit or miss.</p><p>We wanted:</p><ul><li>⚡ Near-instant startup</li><li>📦 Better ESM support</li><li>🧪 Modern test environment with <strong>Vitest</strong></li></ul><p>So, we picked <strong>Vite</strong>.</p><h3>🏗️ Initial Setup: Vite + React + Ruby</h3><p>We used:</p><pre>npm i -D vite @vitejs/plugin-react vite-plugin-ruby vite-plugin-pwa</pre><p>And added:</p><pre>// vite.config.ts<br>import { defineConfig } from &#39;vite&#39;<br>import react from &#39;@vitejs/plugin-react&#39;<br>import ruby from &#39;vite-plugin-ruby&#39;<br><br>export default defineConfig({<br>  plugins: [react(), ruby()],<br>  define: {<br>    global: &#39;globalThis&#39;, // critical for Buffer polyfills<br>  },<br>  optimizeDeps: {<br>    include: [&#39;lodash&#39;, &#39;moment&#39;], // explicitly pre-bundled<br>  },<br>  test: {<br>    environment: &#39;jsdom&#39;,<br>    setupFiles: &#39;./vitest.setup.js&#39;,<br>  },<br>})</pre><h3>🔐 Crypto Woes: crypto.subtle was Undefined</h3><h3>❌ Problem</h3><p>In the browser, we used window.crypto.subtle. But in Vitest, it threw:</p><pre>TypeError: Cannot read properties of undefined (reading &#39;subtle&#39;)</pre><h3>✅ Solution</h3><p>We polyfilled it manually in vitest.setup.js:</p><pre>if (!global.crypto?.subtle) {<br>  const { webcrypto } = await import(&#39;node:crypto&#39;)<br>  global.crypto = webcrypto<br>}</pre><p>In Vite, we avoided vite-plugin-node-polyfills (too heavy) and used @esbuild-plugins/node-globals-polyfill instead:</p><pre>// vite.config.ts<br>plugins: [<br>  NodeGlobalsPolyfillPlugin({<br>    buffer: true,<br>    process: true,<br>    crypto: true,<br>  }),<br>]</pre><h3>🪵 Lodash + _ is not defined?</h3><p>We faced this error in test runs:</p><pre>ReferenceError: _ is not defined</pre><p>Even though we had:</p><pre>import _ from &#39;lodash&#39;;</pre><p>It failed because of module hoisting and ESM quirks in Vite+Vitest.</p><h3>✅ Fix</h3><p>Use explicit imports:</p><pre>import debounce from &#39;lodash/debounce&#39;</pre><p>This gave:</p><ul><li>Smaller bundle</li><li>No _ global issues</li><li>ESM-friendly tree-shaking</li></ul><h3>🧪 Test Optimizations with Vitest</h3><p>Migrating from Jest to Vitest revealed a few things:</p><ul><li><strong>Mocks are isolated per file</strong>, not shared by default</li><li><strong>Time mocking</strong> needs vi.useFakeTimers() vs jest.useFakeTimers()</li><li><strong>Import.meta.env</strong> works out-of-the-box, unlike Webpack’s process.env</li></ul><p>We also had to move our polyfills and time mocking into vitest.setup.js.</p><h3>🧨 Crypto.createDecryptor Undefined?</h3><p>One of the trickiest bugs was this:</p><pre>Cannot read properties of undefined (reading &#39;createDecryptor&#39;)</pre><p>This occurred because crypto-js wasn’t fully ESM-compatible and Vite couldn’t optimize it cleanly in dev.</p><h3>✅ Workaround</h3><p>We:</p><ul><li>Switched to native Web Crypto APIs (window.crypto.subtle)</li><li>Deferred instantiations into useEffect or dynamic imports</li></ul><h3>🧾 Lessons Learned</h3><pre>Challenge                            Fix<br><br>crypto.subtle undefined              Use node:crypto in test or browser-compatible shim<br>Buffer undefined                     Use NodeGlobalsPolyfillPlugin<br>Lodash _ not defined                 Use named imports (like import debounce)<br>crypto-js compatibility              Use native Web APIs instead, or defer imports<br>Dev server too aggressive            Disable pre-optimization for edge libraries (e.g. noExternal)</pre><h3>🆚 Vite vs Webpack: Real Developer Experience</h3><pre>Feature                    Vite                           Webpack<br>Dev startup speed          ⚡ ~1s.                         🐢 10–30s<br>HMR performance            ✅ Instant, reliable           ⚠️ Sometimes buggy<br>ESM/modern JS support.     ✅ Native                      🔧 Needs config<br>Tree-shaking               ✅ Works with named imports    ⚠️ Often includes dead code<br>Test integration (Vitest). ✅ Smooth                      🔧 Needs extra setup<br>Plugin ecosystem           🆕 Still growing               ✅ Mature &amp; vast<br>Polyfill support           🔧 Needs care (Buffer, crypto) ✅ Handled via webpack config</pre><h3>🧘 Final Thoughts</h3><p>Migrating to Vite isn’t plug-and-play. You’ll:</p><ul><li>Debug weird ESM vs CommonJS issues</li><li>Patch missing polyfills</li><li>Rewrite old code patterns</li></ul><p>But the <strong>payoff is huge</strong>:</p><ul><li>Instant dev server</li><li>Native browser behavior</li><li>Better DX in modern frameworks like React, Vue, and Svelte</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e08b0323ea68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Simple Global Store in React using useSyncExternalStore]]></title>
            <link>https://techiekarthick.medium.com/usesyncexternalstore-b462ea031c68?source=rss-62db95a16d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/b462ea031c68</guid>
            <category><![CDATA[useexternalsyncstore]]></category>
            <category><![CDATA[singleton-design-pattern]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[objects]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[techiekarthick]]></dc:creator>
            <pubDate>Thu, 17 Apr 2025 10:31:27 GMT</pubDate>
            <atom:updated>2025-04-17T12:04:47.960Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*syhPYzwzsj_UT_QnwvQviA.png" /></figure><p>React’s useSyncExternalStore hook is a powerful yet underused API that allows you to <strong>subscribe to external data sources</strong> — like a custom store — without needing state management libraries like Redux or Zustand.</p><p>Here’s how you can build your own minimal global store using plain JavaScript and useSyncExternalStore</p><h3>🧠 The Store Logic</h3><p>Create a file called store.js (or index.js if you&#39;re bundling things) with the following logic:</p><pre>// index.js<br>const state = {<br>  name: &quot;Karthick&quot;,<br>  age: 25<br>};<br><br>let listeners = new Set(); // Store subscribers (components)<br><br>function updateState(newData) {<br>  Object.assign(state, newData); // Update state<br>  listeners.forEach((listener) =&gt; listener()); // Notify all subscribers<br>}<br><br>// Subscribe function for React components<br>function subscribe(listener) {<br>  listeners.add(listener);<br>  return () =&gt; listeners.delete(listener); // Unsubscribe on unmount<br>}<br><br>// Get the latest snapshot of state<br>function getSnapshot() {<br>  return { ...state }; // Return a copy<br>}<br><br>export { updateState, subscribe, getSnapshot };// implementation.js<br>// Use can use this in any components;<br>import { subscribe, getSnapshot, updateState } from &quot;...&quot;;<br><br>const Component = () =&gt; {<br>  const state = useSyncExternalStore(subscribe, getSnapshot);<br><br>  const onUpdateState = () =&gt; {<br>    const newState = { ...state, name: &#39;...&#39;, age: &#39;...&#39; }<br>    updateState(newState);<br>  }<br>}</pre><h3>🧩 Using It in a React Component</h3><p>You can now use this global store in any component with useSyncExternalStore.</p><pre>// Component.jsx<br>import { useSyncExternalStore } from &#39;react&#39;;<br>import { subscribe, getSnapshot, updateState } from &#39;./store&#39;;<br><br>const MyComponent = () =&gt; {<br>  const state = useSyncExternalStore(subscribe, getSnapshot);<br><br>  const onUpdateState = () =&gt; {<br>    updateState({ name: &quot;John Doe&quot;, age: 30 });<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Name: {state.name}&lt;/p&gt;<br>      &lt;p&gt;Age: {state.age}&lt;/p&gt;<br>      &lt;button onClick={onUpdateState}&gt;Update State&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><h3>✅ Why This Works Well</h3><ul><li><strong>No </strong><strong>forceUpdate needed</strong> — Components re-render automatically.</li><li><strong>Multiple components stay in sync</strong> — No extra wiring.</li><li><strong>Efficient and scalable</strong> — Only re-renders components that consume the store.</li></ul><h3>🎯 When to Use This</h3><p>This pattern is great when you:</p><ul><li>Want lightweight shared state without external dependencies.</li><li>Need fine-grained control over updates.</li><li>Prefer native React solutions.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b462ea031c68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Way To Become More Mature]]></title>
            <link>https://techiekarthick.medium.com/the-way-to-become-more-mature-f82e21bb07f7?source=rss-62db95a16d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/f82e21bb07f7</guid>
            <category><![CDATA[silence]]></category>
            <category><![CDATA[discipline]]></category>
            <category><![CDATA[talent]]></category>
            <category><![CDATA[maturity]]></category>
            <dc:creator><![CDATA[techiekarthick]]></dc:creator>
            <pubDate>Sun, 05 May 2024 14:29:25 GMT</pubDate>
            <atom:updated>2024-05-05T14:29:25.102Z</atom:updated>
            <content:encoded><![CDATA[<h3>Accept The Reality</h3><p>Reality is that which, when you stop believing in it, doesn’t go away</p><h3>Don’t Judge Too Early</h3><p>Don’t judge everyone else by your own limited experience</p><h3>Control Your Emotions</h3><p>Be careful in an emotional moment not to allow your temper to control your actions leading to poor choices that you will later regret</p><h3>Take Care Of Your Mental Health</h3><p>Not until we are lost do we begin to understand ourselves</p><h3>Be Silent Over Nonsense Fight</h3><p>It is better either to be silent or to say things of more value than silence</p><h3>Don’t Depend Others For Your Happiness</h3><p>Those who are not looking for happiness are the most likely to find it, because those who are searching forget that the surest way to be happy is to seek happiness for others</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f82e21bb07f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native Automated Fastfile for Android]]></title>
            <link>https://techiekarthick.medium.com/react-native-automated-fastfile-for-android-7927c53a65e3?source=rss-62db95a16d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/7927c53a65e3</guid>
            <category><![CDATA[fastlane]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[play-store]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[techiekarthick]]></dc:creator>
            <pubDate>Tue, 05 Mar 2024 06:39:31 GMT</pubDate>
            <atom:updated>2024-03-05T06:39:31.189Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7DJnDBoIBIP-MZmkUj_qw.png" /></figure><p>In this blog, I am going to tell you about Fastfile for Android, and its usage of it.</p><p><strong>Fastlane is an open-source tool that is used to automate releases and deployment of apps.</strong></p><blockquote><em>“fastlane is the easiest way to automate beta deployments and releases for your Android and IOS apps. 🚀 It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application.” </em><a href="https://fastlane.tools/"><em>https://fastlane.tools</em></a></blockquote><pre>def get_version_code<br>  build_gradle_content = File.read(&#39;../app/build.gradle&#39;)<br>  build_gradle_content.match(/versionCode\s+(\d+)/)&amp;.captures&amp;.first<br>end<br><br>def slack_message(message)<br>  slack(message: message, slack_url: &#39;...&#39;)<br>end<br><br>platform :android do<br>  desc &quot;Run Test&quot;<br>  lane :test do<br>    gradle(task: &quot;test&quot;)<br>  end<br><br>  desc &quot;Slack Test&quot;<br>  lane :slack_test do<br>    slack_message(&#39;Slack Test Message from Fastlane file&#39;);<br>  end<br><br>  desc &quot;Build APK in Local&quot;<br>  lane :build_release_local do # apk file<br>    gradle(task: &quot;clean assembleRelease&quot;)<br>  end<br>  <br>  desc &quot;Build ABB Bundle&quot;<br>   lane :build_aab do # aab file<br>     gradle(task: &quot;bundle&quot;)<br>   end<br>  end<br><br>  desc &quot;Get the version code&quot;<br>  lane :version_code do<br>    get_version_code <br>  end<br><br>  desc &quot;Submit a new Internal Build&quot;<br>  lane :internal do |options|<br>    build_number = options[:build_number]<br>    increment_version_code(gradle_file_path: &quot;app/build.gradle&quot;, version_code: build_number.to_i)<br>    gradle(task: &quot;clean&quot;)<br>    gradle(task: &quot;bundle&quot;, build_type: &#39;Release&#39;)<br>    upload_to_play_store(<br>      track: &#39;internal&#39;, <br>      release_status: &quot;completed&quot;,<br>      version_code: build_number,<br>      version_name: &quot;...&quot;, # version name<br>      aab: &quot;...&quot;, # aab file path ../../<br>      metadata_path: &quot;...&quot;, # upload any metadata<br>    )<br>    slack_message(&quot;Successfully distributed a new internal build version #{build_number}&quot;);<br>  end<br><br>  desc &quot;Promote Internal to Alpha&quot;<br>  lane :promote_internal_to_alpha do<br>    upload_to_play_store(track: &#39;internal&#39;, track_promote_to: &#39;alpha&#39;, version_code: get_version_code)<br>    slack_message(&quot;Successfully Promoted Internal to Alpha version #{get_version_code}&quot;);<br>  end<br><br>  desc &quot;Promote Alpha to Beta&quot;<br>  lane :promote_alpha_to_betaz do<br>    upload_to_play_store(track: &#39;alpha&#39;, track_promote_to: &#39;beta&#39;, version_code: get_version_code)<br>    slack_message(&quot;Successfully Promoted Alpha to Beta version #{get_version_code}&quot;);<br>  end<br><br>  desc &quot;Promote Beta to Production&quot;<br>  lane :promote_beta_to_production do<br>    upload_to_play_store(track: &#39;beta&#39;, track_promote_to: &#39;production&#39;, version_code: get_version_code)<br>    slack_message(&quot;Successfully Promoted Beta to Production version #{get_version_code}&quot;);<br>  end<br>end<br></pre><ol><li><strong><em>get_version_code</em>: </strong>It’s a custom function that reads the version code from the build.gradle file.</li><li><strong><em>build_release_local</em></strong>: For the local Android path, it generates the most recent apk build.</li><li><strong><em>build_aab</em></strong>: For the local Android path, it generates the most recent aab build.</li><li><strong><em>internal</em></strong>: Using GitHub activities, Jenkins, or any other technologies, I was able to gradually produce the most recent version of the application by utilizing the custom build_number in this instance.</li></ol><blockquote>bundle exec fastlane internal build_number: build_number</blockquote><p>5. <strong><em>increment_version_code</em></strong>: modifies the gradle file’s versionCode to reflect the most recent build number.</p><p>6. Promote internal to alpha, alpha to beta, and beta to production: this technique advances ideas from one stage to the next and ultimately to production.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7927c53a65e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>