This repo lets you create a module using react and typescript with minimal build configuration.
- Clone this repo, remove origin and install modules
git clone https://github.com/dumbape/react-typescript-module.git <Your Module Name>cd <Your Module Name>git remote remove originnpm install
- Build your React Typescript module as usual in the
srcfolder. - Make a separate
.tsfile which would have all the exports from the module. For convenience, anindex.tshas been provided, however, you may make your own anywhere. - Open
rollup.config.jsand adjust theinputparameter (by default points to sec/index.ts) so that it points to the.tsfile containing all the exports. - Run
npm run build. A build folder will be generated. - Open
package.jsonand changenameandversionto your module name and version. Optionally, you may add adescription. Pointtypesto the.d.tsfile generated in build folder, which contains all exports. Do not changemain,moduleandjsnext:main. - Your module is ready to be used.
- Create a new react project (with or wihout typescript).
npx create-react-app testapp && cd testappORnpx create-react-app testapp --typescript && cd testapp
- Install the created module.
npm install <Path to the root folder of your module>
- Try using your component as any other module by including it in any
.tsxor.jsxfile.import { <Your Component> } from 'your-module'
- The module is ready to be published for react users (with and without typescript!).
- Login to npm and publish
npm loginnpm publish
You are free to raise issues and PR's to improve the repo and help people build modules with ease :)