In order for other people to install and use this component, you can publish the package to npm.
You will first need to have an npmjs account with permissions to push to your package name.
If this is your first time, here are the recommended steps:
- Ensure the package.json "name" matches what you want it to be called. It
should either be like
my-packageor@my-org/my-package. If it's the latter, ensure you have an npmjs account with permissions to push tomy-org. npm loginto login to npmjs.npm run cleanto clean your/distdirectory.npm cito install the dependencies with the versions specified inpackage-lock.json.npm run buildto build the package fresh.- (Optional)
npm run typecheckto typecheck the package. - (Optional)
npm run lintto lint the package. - (Optional)
npm run testto test the package. - (Optional)
npm packwill create a .tgz file of the package. You can then try installing it in another project withnpm install ./path/to/your-package.tgzto sanity check that it works as expected. You can remove the .tgz file after. npm publish --access publicto publish the package to npm.git tag v0.1.0to tag the new version.git push --follow-tagsto push the tags to the repository. This way, other contributors can always see what code was published with each version. Runningnpm version ...will create these tags and commits automatically.
After the initial publish, you can use the release scripts documented below, which will do steps 3-12 automatically (except the sanity check in step 9).
In package.json, there are some scripts that are useful for doing releases.
preversionwill run the tests and typecheck the code before marking a new version.versionwill open the changelog in vim and then save it before committing the new version.prepublishOnlywill make a clean build of the package before publishing.
These are not required and can be modified or removed if desired. They will all be run automatically when using one of the deployment commands.
npm run alphaThis will create a prerelease version with an @alpha tag. It will then publish
the package to npm and push the code and new tag. Users can install the package
with npm install @your-package@alpha.
npm run releaseThis will create a patch version and publish as latest. It will then publish
the package to npm and push the code and new tag. To publish a new minor or
major version, you can run the commands manually:
npm version minor # or major
npm publish
git push --follow-tagsnpm run clean
npm run build
npm packYou can then provide the .tgz file to others to install via
npm install ./path/to/your-package.tgz.