Common SDK Component Library
- Creating a common SDK component library is helpful to keep the DRY principle & not repeat code. Especially when we have multiple repos utlizing the same components.
Summaryof setting up Building a common sdk component library includes the following:
1. New folder & init
2. Install react & typescript
3. Update .tsconfig.json
4. Create folder structure & component
5. Rollup bundling & packaging
Details of setting up common sdk component library includes the following:
1. Create a new folder & npm init
Create a new folder where we want our project to be; then navigate there and run "npm init". This create a simple node app.2. Install react & typescript
Install react & typescript with the following command:Terminal>npm install react typescript @types/react --save-dev> Output:installed..
3. Update our tsconfig.json file
We have to update our configuration for typescript. #todo add code details here4. Create folder structure & sample component
We can create a simple component as a 1st one and create the folder structure with index files including the exports. #todo add code details here5. Rollup bundling & packaging; Update rollup.config.js
We add rollup. Need to install multiple packages & run the rollup. #todo add code details herenpm install rollup @rollup/plugin-node-resolve @rollup/plugin-commonjs @rollup/plugin-typescript rollup-plugin-peer-deps-external @rollup/plugin-terser rollup-plugin-dts --save-devWe need to update our rollup.config.js; #todo add code details here
As we see we can leverage creating a common sdk component library.