README
npm React module
Version: Basarat Ali
Process of creation
1. typescript npm module
npm initCreatepackage.jsonnpm i -D typescriptInstall compilernpx tsc --initInitializetsconfig.json.
- Target es5
- module commonjs
- strict true
- esModuleInterop true
- declaration: true
- declarationMap: true
- sourceMap: true
- outDir: lib
- add include in src
touch src/index.tsand add export some functiontweak
package.json
- Ensure unique package name
- main should point to "lib/index.js"
- add types pointing to lib
- add build script
tsc -p .where the flag points to the project to compile
2. Enhance adding React
npm i react @types/react -DInpackage.jsonadd peerDependencies indicating that the project using this library should use a react with version at least 16.0.0Enable
jsxtoreactintsconfig.jsonmv src/index.ts src/index.tsxand modify it to export a componentrun
npm run build
Derived from:
- Twitter | @basarat
- GitHub | Basarat Ali Syed
- YouTube | Basarat Ali
- Website | basarat.com