Script for the example sourced from: https://github.com/MichaelDimmitt/ship-my-component-npm
## Important for the init command:
## specify the entrypoint: build/index.js
## specify test: webpack
npm init &&
mkdir build &&
curl -L -o webpack.config.js https://raw.githubusercontent.com/MichaelDimmitt/ship-my-component-npm/master/webpack.config.js &&
npm install [email protected] [email protected] &&
npm install -D [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] &&
npm test &&
npm publish
## cleanup
rm -rf node_modules package.json package-lock.json webpack.config.js
// normal class component implementation is version #7
npm install --save hello-world-npm-component@1.0.7
import HelloWorld from 'hello-world-npm-component';
// functional component implementation is version #6
npm install --save hello-world-npm-component@1.0.6
import { HelloWorld } from 'hello-world-npm-component';
git checkout react-class-component;
git checkout react-functional-component;
success reached through the following helpful document:
https://medium.com/@BrodaNoel/how-to-create-a-react-component-and-publish-it-in-npm-668ad7d363ce