<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: shripada</title>
    <description>The latest articles on DEV Community by shripada (@shripada).</description>
    <link>https://dev.to/shripada</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1118748%2F1d0afecc-ea7e-4bad-935a-13b91d70d858.png</url>
      <title>DEV Community: shripada</title>
      <link>https://dev.to/shripada</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shripada"/>
    <language>en</language>
    <item>
      <title>Building a TypeScript library in a mono repo setup</title>
      <dc:creator>shripada</dc:creator>
      <pubDate>Thu, 13 Jul 2023 12:32:20 +0000</pubDate>
      <link>https://dev.to/shripada/building-a-typescript-library-in-a-mono-repo-setup-2j8m</link>
      <guid>https://dev.to/shripada/building-a-typescript-library-in-a-mono-repo-setup-2j8m</guid>
      <description>&lt;h2&gt;
  
  
  TypeScript library
&lt;/h2&gt;

&lt;p&gt;Creating a library is like assembling a toolbox of code snippets. These can be shared across multiple apps - whether they're backend-heavy, frontend-centric, or a blend of both. You might want to share a clever string processing script, a custom algorithm, or a unique data structure. &lt;/p&gt;

&lt;p&gt;Libraries let you package and share these resources efficiently, reducing repetition and keeping your codebase streamlined. TypeScript is a popular language that encourages writing safe code with great developer experience. In this article, we'll delve into the creation and usage of a TypeScript library within a mono repository. &lt;/p&gt;

&lt;p&gt;This setup hosts multiple apps, providing the convenience to develop and locally test libraries in concert with these apps. &lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Ensure you have node version v18 onwards&lt;/li&gt;
&lt;li&gt;We will use &lt;a href="https://pnpm.io/"&gt;pnpm &lt;/a&gt; package manager. Please have it installed.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://code.visualstudio.com/"&gt;Visual Studio Code IDE&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create a mono repo using &lt;a href="https://turbo.build/repo/docs/getting-started/create-new"&gt;Turbo build&lt;/a&gt; system.
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-turbo@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;When prompted give the name to the monorepo. We shall give &lt;code&gt;test-lib&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Choose &lt;a href="https://pnpm.io/installation"&gt;pnpm&lt;/a&gt; package manager as it has a very good support for linking to libs locally.&lt;/li&gt;
&lt;li&gt;once monorepo is created open it in vs code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd test-lib
code .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating the library using &lt;a href="https://vitejs.dev/"&gt;Vite&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;We shall use a modern tooling called &lt;a href="https://vitejs.dev/"&gt;Vite&lt;/a&gt; to create and setup our library.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fire up a terminal inside vs code.&lt;/li&gt;
&lt;li&gt;cd into the &lt;code&gt;packages&lt;/code&gt; folder inside monorepo and run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd packages
npm create vite@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;When it prompts for name, give &lt;code&gt;test-lib&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;and choose &lt;code&gt;Vanilla&lt;/code&gt; framework,&lt;/li&gt;
&lt;li&gt;and &lt;code&gt;TypeScript&lt;/code&gt; variant.&lt;/li&gt;
&lt;li&gt;Once you press Enter, you should see the test-lib project created in &lt;code&gt;packages&lt;/code&gt; folder.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Examine the vanilla test-lib package created
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;cd test-lib&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Examine the folder structure&lt;/li&gt;
&lt;li&gt;We have a basic venilla js project.&lt;/li&gt;
&lt;li&gt;first, install dependencies. &lt;code&gt;pnpm install&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;We can build this package using &lt;code&gt;pnpm build&lt;/code&gt;, and it will create a built web site in &lt;code&gt;/dist&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;But we want a library and not the website. For that we need to configure the Vite to convert the package into a library&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Convert the Vanilla project into a library
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;First delete files in the &lt;code&gt;/src&lt;/code&gt; folder except &lt;code&gt;vite-env.d.ts&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Delete the public folder as well.&lt;/li&gt;
&lt;li&gt;Create a file called &lt;code&gt;math.ts&lt;/code&gt; with following content:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function add(a: number, b: number): number {
  return a + b;
}

export { add };

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create another file called index.ts and add the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export { add } from './math';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now we need to convert this into a library. Vite supports a &lt;a href="https://vitejs.dev/guide/build.html#library-mode"&gt;library mode&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Create a &lt;code&gt;vite.config.js&lt;/code&gt; file in the root of &lt;code&gt;test-lib&lt;/code&gt; package&lt;/li&gt;
&lt;li&gt;Copy the Vite config in the &lt;a href="https://vitejs.dev/guide/build.html#library-mode"&gt;documentation&lt;/a&gt; above to our config file. Remove the &lt;code&gt;rollup&lt;/code&gt; object from it.&lt;/li&gt;
&lt;li&gt;make the lib object to look like so where we have given our library name as TestLib, and file name as test-lib:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    lib: {
      // Could also be a dictionary or array of multiple entry points
      entry: resolve(__dirname, 'lib/main.js'),
      name: 'TestLib',
      // the proper extensions will be added
      fileName: 'test-lib',
    },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If you try building now, it will fail complaining the mentioned entry point in config is not found. Lets fix that.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;entry: resolve(__dirname, 'src/index.ts'),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now if you build using &lt;code&gt;pnpm build&lt;/code&gt;, you should see the build library in &lt;code&gt;/dist&lt;/code&gt; folder. You will see ES6, and UMD modules.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Configuring the vite to generate ES6 and common js
&lt;/h2&gt;

&lt;p&gt;We want the output in two formats, one in ES6 for all modern browsers and runtimes. CommoJS for node run time.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In vite.config.js, we need to add formats in &lt;code&gt;lib&lt;/code&gt; section:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;formats:['es', 'cjs']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Build and check if you see both es6 and CommonJS modules getting generated in &lt;code&gt;/dist&lt;/code&gt; folder.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Integrate the library in the &lt;code&gt;apps/web&lt;/code&gt; next js project.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Fire up another terminal for web app&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cd apps/web&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Run the app in dev mode &lt;code&gt;pnpm dev&lt;/code&gt; and then hit &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You should see the page with some text and button&lt;/li&gt;
&lt;li&gt;we want to install our lib as a dependency to this app.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;npm install test-lib&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;You will notice pnpm will end up installing an existing package from npm registry with name test-lib. We don't want that. To ensure we don't conflict with npm registry entry, create a unique name using namespace such as @abccomp&lt;/li&gt;
&lt;li&gt;Change the &lt;code&gt;name&lt;/code&gt; in packages/test-lib/package.json to &lt;code&gt;@abccomp/test-lib&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;fire up another terminal and cd into apps/web&lt;/li&gt;
&lt;li&gt;now install the &lt;code&gt;@abccomp/test-lib&lt;/code&gt; by running
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm install @abccomp/test-lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;pnpm is clever and it will create a symlink to to our local lib module and you can see it in its output:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+ @abccomp/test-lib 0.0.0 &amp;lt;- ../../packages/test-lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Use the library
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;open the app/page.tsx&lt;/li&gt;
&lt;li&gt;import &lt;code&gt;add&lt;/code&gt; function from our library
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { add } from '@abccomp/test-lib';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and in page.tsx, add this below the :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;div&amp;gt;{add(10, 30)}&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;When you go back to browser and check, you will see an error saying module not found.&lt;/li&gt;
&lt;li&gt;This is because, the &lt;code&gt;package.json&lt;/code&gt; of our library is not giving enough information as to where to find the real module code in the package.&lt;/li&gt;
&lt;li&gt;lets do that now by referring this &lt;a href="https://vitejs.dev/guide/build.html#library-mode"&gt;recommended package.json&lt;/a&gt; for lib.&lt;/li&gt;
&lt;li&gt;Copy the following code into package.json of test-lib
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"
  files": ["dist"],
  "main": "./dist/my-lib.umd.cjs",
  "module": "./dist/my-lib.js",
  "exports": {
    ".": {
      "import": "./dist/my-lib.js",
      "require": "./dist/my-lib.umd.cjs"
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;modify main to point to the common js, and module to es6 module paths generated in the dist folder. Also fix the &lt;code&gt;export&lt;/code&gt; entries. Now the entries should look like:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; "files": [
    "dist"
  ],
  "main": "./dist/test-lib.cjs",
  "module": "./dist/test-lib.js",
  "exports": {
    ".": {
      "import": "./dist/test-lib.js",
      "require": "./dist/test-lib.cjs"
    }
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now go back in your browser and check the page, it should be displaying 35. Great! Library integration works successfully!.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Generating type declaration d.ts file for VSCode to help with type completion with our code.
&lt;/h2&gt;

&lt;p&gt;You might observe that when we try to use our &lt;code&gt;add&lt;/code&gt; function in the app, we don't get any code completion hints. This is because, VSCode is not able to locate the type declarations for our library. Generally type declarations are made available in the form of &lt;code&gt;&amp;lt;module-name&amp;gt;.d.ts&lt;/code&gt; files right along with our generated modules.&lt;/p&gt;

&lt;p&gt;Vite can help us to generate these via &lt;code&gt;tsc&lt;/code&gt; using a plugin called &lt;a href="https://www.npmjs.com/package/vite-plugin-dts"&gt;vite-plugin-dts&lt;/a&gt;. Lets install that plugin&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install the vite-plugin-dts in test-lib package
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    pnpm i vite-plugin-dts -D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;in &lt;code&gt;vite.config.js&lt;/code&gt;, import the dts plugin
&lt;code&gt;import dts from 'vite-plugin-dts'&lt;/code&gt;
and add this in the config:
&lt;code&gt;plugins:[dts()]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;the config should look like so:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { resolve } from 'path';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
export default defineConfig({
  build: {
    lib: {
      entry: resolve(__dirname, 'src/index.ts'),
      name: 'TestLib',
      // the proper extensions will be added
      fileName: 'test-lib',
      formats: ['es', 'cjs'],
    },
  },
  plugins:[dts()]
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now if we build the library using &lt;code&gt;pnpm build&lt;/code&gt; we should see the d.ts files getting created inside &lt;code&gt;/dist&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;We are not done yet!. We need to add a &lt;code&gt;types&lt;/code&gt; entry into package.json of test-lib as well. Add the following to the package.json of the test-lib:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"types": "./dist/index.d.ts"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now go back to the app, and observe that VSCode no longer warns on not finding types. And also if you will start seeing type hints when you type the function name &lt;code&gt;add&lt;/code&gt; in the VSCode editor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrating library into a node js project as ESM and also CommonJS package.
&lt;/h2&gt;

&lt;p&gt;Our library can be used by even a backend code written in node. You can also integrate the library even from a JavaScript code. To experiment this, lets go ahead and create a node app inside /apps folder in our mono-repo. Run the following commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd apps
mkdir node-app
cd node-app
pnpm init
touch index.js
touch index.cjs
pnpm install @abccomp/test-lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we run the above commands, we should see package.json, and index.js, and index.cjs files created inside node-app folder. &lt;br&gt;
If you inspect the package.json, you will see an entry:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "type": "module"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which indicates, by default all js files are ESM modules. However we can tell a particular file is a common js module, by giving &lt;code&gt;cjs&lt;/code&gt; extension.&lt;/p&gt;

&lt;p&gt;Add the following code to index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { add } from '@codecraft/test-lib';
console.log(add(40, 50));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following code to index.cjs file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { add } = require('@codecraft/test-lib');
console.log(add(19, 34));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Observe how we use different ways of importing symbols in ESM, and CommonJS.&lt;/p&gt;

&lt;p&gt;One nice thing about our library is it comes with type declarations, and even inside a JavaScript file, you will get nice code completion hints indicating each argument and type of it.&lt;/p&gt;

&lt;p&gt;Test your node files and see both of them successfully use our library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❯ node index.js
90
❯ node index.cjs
53
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  unit testing typescript code using vitest
&lt;/h2&gt;

&lt;p&gt;Before apps can integrate our libraries, it is important we test the code thoroughly. &lt;a href="https://vitest.dev/guide/"&gt;Vitest&lt;/a&gt; is a blazing fast unit test framework powered by Vite. we shall use this to write unit tests for our math module. &lt;/p&gt;

&lt;p&gt;First, install vitest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm add -D vitest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a test file called &lt;code&gt;math.test.ts&lt;/code&gt; in the same src folder where &lt;code&gt;math.ts&lt;/code&gt; is located. If you have already written jest tests in other projects, you already know how to write tests using vtest. Add the following code to math.test.ts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { it, expect } from 'vitest';
import { add } from './math';

it('must add two integers correctly', () =&amp;gt; {
  const actual = add(10, 25);
  const expected = 35;
  expect(actual).toEqual(expected);
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  running tests
&lt;/h3&gt;

&lt;p&gt;Add the following script to the package.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;test: vitest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run the tests, invoke&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you should see the console output that shows that tests are passing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Debugging the code via tests.
&lt;/h2&gt;

&lt;p&gt;Ability to debug our code in VSCode is vital to troubleshoot our code.  Vite has very good out of the box support for enabling debugging. All you have to do is invoke the &lt;a href="https://vitest.dev/guide/debugging.html"&gt;Javascript Debug Terminal in VSCode&lt;/a&gt;. Add some breakpoints in your test. In the command line of debug terminal, simply run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the breakpoint that you have set in your tests  will become active with debugger pausing there. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we explored, how we can use a mono repo setup to create a TypeScript based library, and demonstrate how to integrate it in a next js app, and also a node application. In the process, we got to know how the tools like Turbo, pnpm, Vite and Vitest can facilitate a comfortable developer experience in building and testing the library. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/shripada/typescript-lib"&gt;Github source of the built repo&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An &lt;a href="https://www.youtube.com/watch?v=XDip9onOTps&amp;amp;t=1139s"&gt;excellent tutorial&lt;/a&gt; on the same topic of creating typescript library by Alvaro Dev Labs&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=YX5yoApjI3M"&gt;Turbo mono repo demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vitejs.dev/guide/"&gt;Vite documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vitest.dev/guide/"&gt;Setting up unit testing using Vitest&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
